summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-checksec-py
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@gmail.com>2025-11-14 13:58:04 +0100
committerKhem Raj <raj.khem@gmail.com>2025-11-14 07:39:48 -0800
commita78e6d21094eacf338ca8038c05fea24f19b2ddf (patch)
tree4c62444552a8ff1b47150c8c41136ef21f8242f4 /meta-python/recipes-devtools/python/python3-checksec-py
parent38ea8a4617ad395b2addd24bd1f6b57a8242fa0b (diff)
downloadmeta-openembedded-a78e6d21094eacf338ca8038c05fea24f19b2ddf.tar.gz
python3-checksec-py, python3-pylddwrap, python3-icontract: add recipes
they were sent for meta-security long time ago in 2021: https://lists.yoctoproject.org/g/yocto/message/54470 but never merged there, now there are lief, docopt, rich, asttokens already in meta-python and checksec-py depends on lief version, e.g. https://github.com/Wenzel/checksec.py/commit/976d530867756d1393189708aa98308b07b1f3b2 is needed to fixcompatibility with newer lief currently in meta-python Signed-off-by: Martin Jansa <martin.jansa@gmail.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-checksec-py')
-rw-r--r--meta-python/recipes-devtools/python/python3-checksec-py/0001-main-Add-option-to-ignore-symlinks.patch81
1 files changed, 81 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-checksec-py/0001-main-Add-option-to-ignore-symlinks.patch b/meta-python/recipes-devtools/python/python3-checksec-py/0001-main-Add-option-to-ignore-symlinks.patch
new file mode 100644
index 0000000000..3a99ba33e3
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-checksec-py/0001-main-Add-option-to-ignore-symlinks.patch
@@ -0,0 +1,81 @@
1From b540967b87394d855c26375ac5a9a7265f265053 Mon Sep 17 00:00:00 2001
2From: Maximilian Blenk <Maximilian.Blenk@bmw.de>
3Date: Fri, 2 Jul 2021 14:42:25 +0200
4Subject: [PATCH] main: Add option to ignore symlinks
5
6When analyzing a complete rootfs (which might not be the rootfs of the
7analyzing system) symlinks within that rootfs might be broken. In
8particular absolute symlinks. However, if by chance such a symlink
9currently points to a valid binary in your system, this binary pointed
10to is analyzed. This commit adds the possibility to ignore symlinks to
11files (symlinks to dirs are already ignored by default). This allows to
12solve the issue described above, and if the whole rootfs is analyzed
13there shouldn't be a loss of information (because all the binaries will
14be analyzed anyway). Additionally, this also saves some time when
15performing the analysis.
16
17Upstream-Status: Submitted [https://github.com/Wenzel/checksec.py/pull/106]
18---
19 checksec/__main__.py | 12 +++++++-----
20 1 file changed, 7 insertions(+), 5 deletions(-)
21
22diff --git a/checksec/__main__.py b/checksec/__main__.py
23index a14862f..931d850 100644
24--- a/checksec/__main__.py
25+++ b/checksec/__main__.py
26@@ -8,6 +8,7 @@ Options:
27 -w WORKERS --workers=WORKERS Specify the number of process pool workers [default: 4]
28 -j --json Display results as JSON
29 -s LIBC --set-libc=LIBC Specify LIBC library to use to check for fortify scores (ELF)
30+ -i --ignore-symlinks Ignore symlinks to files
31 -d --debug Enable debug output
32 -h --help Display this message
33 """
34@@ -27,18 +28,18 @@ from .pe import PEChecksecData, PESecurity, is_pe
35 from .utils import lief_set_logging
36
37
38-def walk_filepath_list(filepath_list: List[Path], recursive: bool = False) -> Iterator[Path]:
39+def walk_filepath_list(filepath_list: List[Path], recursive: bool = False, ignore_symlinks: bool = False) -> Iterator[Path]:
40 for path in filepath_list:
41 if path.is_dir() and not path.is_symlink():
42 try:
43 if recursive:
44 for f in os.scandir(path):
45- yield from walk_filepath_list([Path(f)], recursive)
46+ yield from walk_filepath_list([Path(f)], recursive, ignore_symlinks)
47 else:
48 yield from (Path(f) for f in os.scandir(path))
49 except OSError:
50 continue
51- elif path.is_file():
52+ elif path.is_file() and (not ignore_symlinks or not path.is_symlink()):
53 yield path
54
55
56@@ -75,6 +76,7 @@ def main(args):
57 json = args["--json"]
58 recursive = args["--recursive"]
59 libc_path = args["--set-libc"]
60+ ignore_symlinks = args["--ignore-symlinks"]
61
62 # logging
63 formatter = "%(asctime)s %(levelname)s:%(name)s:%(message)s"
64@@ -110,7 +112,7 @@ def main(args):
65 # we need to consume the iterator once to get the total
66 # for the progress bar
67 check_output.enumerating_tasks_start()
68- count = sum(1 for i in walk_filepath_list(filepath_list, recursive))
69+ count = sum(1 for i in walk_filepath_list(filepath_list, recursive, ignore_symlinks))
70 check_output.enumerating_tasks_stop(count)
71 with ProcessPoolExecutor(
72 max_workers=workers, initializer=worker_initializer, initargs=(libc_path,)
73@@ -119,7 +121,7 @@ def main(args):
74 check_output.processing_tasks_start()
75 future_to_checksec = {
76 pool.submit(checksec_file, filepath): filepath
77- for filepath in walk_filepath_list(filepath_list, recursive)
78+ for filepath in walk_filepath_list(filepath_list, recursive, ignore_symlinks)
79 }
80 for future in as_completed(future_to_checksec):
81 filepath = future_to_checksec[future]