blint 2.0.4__tar.gz → 2.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {blint-2.0.4 → blint-2.0.6}/PKG-INFO +25 -16
- {blint-2.0.4 → blint-2.0.6}/README.md +24 -15
- {blint-2.0.4 → blint-2.0.6}/blint/binary.py +71 -13
- {blint-2.0.4 → blint-2.0.6}/blint/sbom.py +70 -15
- {blint-2.0.4 → blint-2.0.6}/pyproject.toml +1 -1
- {blint-2.0.4 → blint-2.0.6}/LICENSE +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/__init__.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/analysis.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/android.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/checks.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/cli.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/config.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/cyclonedx/README.md +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/cyclonedx/__init__.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/cyclonedx/spdx.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/cyclonedx/spec.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/__init__.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/__init__.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_entries_generic.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_entries_pe.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_exe_go.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_imports_pe.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_methods_generic.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_methods_mips.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_monero_generic.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_monero_go.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_monero_rust +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_monero_rust.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_rootkits_win.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_symbols_antiforensic.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_symbols_generic.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_symbols_hooka.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_symbols_macho.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/annotations/review_symbols_rust.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/data/rules.yml +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/logger.py +0 -0
- {blint-2.0.4 → blint-2.0.6}/blint/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: blint
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.6
|
|
4
4
|
Summary: Linter and SBOM generator for binary files.
|
|
5
5
|
Home-page: https://github.com/OWASP-dep-scan/blint
|
|
6
6
|
License: MIT
|
|
@@ -30,9 +30,8 @@ Description-Content-Type: text/markdown
|
|
|
30
30
|
|
|
31
31
|
# BLint
|
|
32
32
|
|
|
33
|
-
![blint logo]
|
|
34
|
-
|
|
35
|
-
BLint is a Binary Linter to check the security properties, and capabilities in your executables. It is powered by [lief](https://github.com/lief-project/LIEF). Since version 2, blint can also generate Software Bill-of-Materials (SBOM) for supported binaries.
|
|
33
|
+
![blint logo]
|
|
34
|
+
BLint is a Binary Linter that checks the security properties and capabilities of your executables. It is powered by [lief](https://github.com/lief-project/LIEF). Since version 2, blint can also generate Software Bill-of-Materials (SBOM) for supported binaries.
|
|
36
35
|
|
|
37
36
|
[](https://asciinema.org/a/438138)
|
|
38
37
|
|
|
@@ -43,15 +42,13 @@ Supported binary formats:
|
|
|
43
42
|
- PE (exe, dll)
|
|
44
43
|
- Mach-O (x64, arm64)
|
|
45
44
|
|
|
46
|
-
You can run blint on Linux, Windows and Mac against any of these binary formats.
|
|
45
|
+
You can run blint on Linux, Windows, and Mac against any of these binary formats.
|
|
47
46
|
|
|
48
47
|
## Motivation
|
|
49
48
|
|
|
50
|
-
Nowadays, vendors distribute statically linked binaries produced by
|
|
51
|
-
|
|
52
|
-
The
|
|
53
|
-
|
|
54
|
-
NOTE: The presence of capabilities doesn't imply that the operations are always performed by the binary. Use the output of this tool to get an idea about a binary. Also, this tool is not suitable to review malware and other heavily obfuscated binaries for obvious reasons.
|
|
49
|
+
Nowadays, vendors distribute statically linked binaries produced by Golang, Rust, or Dotnet tooling. Users are used to running antivirus and anti-malware scans while using these binaries in their local devices. Blint augments these scans by listing the technical capabilities of a binary. For example, whether the binary could use network connections or can perform file system operations and so on.
|
|
50
|
+
The binary is first parsed using the lief framework to identify the various properties, such as functions and the presence of symtab and dynamic symbols. Thanks to YAML-based annotation data, this information can be matched against capabilities and presented visually using a rich table.
|
|
51
|
+
NOTE: The presence of capabilities doesn't imply that the binary always performs the operations. Use the output of this tool to get an idea about a binary. Also, this tool is not suitable for reviewing malware and other heavily obfuscated binaries for obvious reasons.
|
|
55
52
|
|
|
56
53
|
## Use cases
|
|
57
54
|
|
|
@@ -69,7 +66,7 @@ pip install blint
|
|
|
69
66
|
|
|
70
67
|
### Single binary releases
|
|
71
68
|
|
|
72
|
-
You can download single binary builds from the [blint-bin releases](https://github.com/OWASP-dep-scan/blint/releases). These executables should work
|
|
69
|
+
You can download single binary builds from the [blint-bin releases](https://github.com/OWASP-dep-scan/blint/releases). These executables should work without requiring python to be installed. The macOS .pkg file is signed with a valid developer account.
|
|
73
70
|
|
|
74
71
|
## Usage
|
|
75
72
|
|
|
@@ -113,7 +110,7 @@ options:
|
|
|
113
110
|
operation.
|
|
114
111
|
```
|
|
115
112
|
|
|
116
|
-
To test any binary including default commands
|
|
113
|
+
To test any binary, including default commands
|
|
117
114
|
|
|
118
115
|
```bash
|
|
119
116
|
blint -i /bin/netstat -o /tmp/blint
|
|
@@ -141,12 +138,24 @@ blint sbom -i /path/to/apk -o bom.json
|
|
|
141
138
|
blint sbom -i /directory/with/apk/aab -o bom.json
|
|
142
139
|
```
|
|
143
140
|
|
|
144
|
-
To parse all files including `.dex` files, pass `--deep` argument.
|
|
141
|
+
To parse all files, including `.dex` files, pass `--deep` argument.
|
|
145
142
|
|
|
146
143
|
```shell
|
|
147
144
|
blint sbom -i /path/to/apk -o bom.json --deep
|
|
148
145
|
```
|
|
149
146
|
|
|
147
|
+
The following binaries are supported:
|
|
148
|
+
|
|
149
|
+
- Android (apk/aab)
|
|
150
|
+
- Dotnet executable binaries
|
|
151
|
+
- Go binaries
|
|
152
|
+
|
|
153
|
+
```shell
|
|
154
|
+
blint sbom -i /path/to/go-binaries -o bom.json --deep
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
For all other binaries, the symbols will be collected and represented as properties with `internal` prefixes for the parent component. Child components and dependencies would be missing.
|
|
158
|
+
|
|
150
159
|
PowerShell example
|
|
151
160
|
|
|
152
161
|

|
|
@@ -157,7 +166,7 @@ Blint produces the following json artifacts in the reports directory:
|
|
|
157
166
|
|
|
158
167
|
- blint-output.html - HTML output from the console logs
|
|
159
168
|
- exename-metadata.json - Raw metadata about the parsed binary. Includes symbols, functions, and signature information
|
|
160
|
-
- findings.json - Contains information from the security properties audit. Useful for CI/CD
|
|
169
|
+
- findings.json - Contains information from the security properties audit. Useful for CI/CD integrations
|
|
161
170
|
- reviews.json - Contains information from the capability reviews. Useful for further analysis
|
|
162
171
|
- fuzzables.json - Contains a suggested list of methods for fuzzing
|
|
163
172
|
|
|
@@ -170,11 +179,11 @@ sbom command generates CycloneDX json.
|
|
|
170
179
|
|
|
171
180
|
## Discord support
|
|
172
181
|
|
|
173
|
-
The developers
|
|
182
|
+
The developers can be reached via the [Discord](https://discord.gg/DCNxzaeUpd) channel.
|
|
174
183
|
|
|
175
184
|
## Sponsorship wishlist
|
|
176
185
|
|
|
177
|
-
If you love blint, you should consider [donating](https://owasp.org/donate?reponame=www-project-dep-scan&title=OWASP+dep-scan) to our project. In addition, consider donating to the below projects which make blint possible.
|
|
186
|
+
If you love blint, you should consider [donating](https://owasp.org/donate?reponame=www-project-dep-scan&title=OWASP+dep-scan) to our project. In addition, consider donating to the below projects, which make blint possible.
|
|
178
187
|
|
|
179
188
|
- [LIEF](https://github.com/sponsors/lief-project/)
|
|
180
189
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# BLint
|
|
2
2
|
|
|
3
|
-
![blint logo]
|
|
4
|
-
|
|
5
|
-
BLint is a Binary Linter to check the security properties, and capabilities in your executables. It is powered by [lief](https://github.com/lief-project/LIEF). Since version 2, blint can also generate Software Bill-of-Materials (SBOM) for supported binaries.
|
|
3
|
+
![blint logo]
|
|
4
|
+
BLint is a Binary Linter that checks the security properties and capabilities of your executables. It is powered by [lief](https://github.com/lief-project/LIEF). Since version 2, blint can also generate Software Bill-of-Materials (SBOM) for supported binaries.
|
|
6
5
|
|
|
7
6
|
[](https://asciinema.org/a/438138)
|
|
8
7
|
|
|
@@ -13,15 +12,13 @@ Supported binary formats:
|
|
|
13
12
|
- PE (exe, dll)
|
|
14
13
|
- Mach-O (x64, arm64)
|
|
15
14
|
|
|
16
|
-
You can run blint on Linux, Windows and Mac against any of these binary formats.
|
|
15
|
+
You can run blint on Linux, Windows, and Mac against any of these binary formats.
|
|
17
16
|
|
|
18
17
|
## Motivation
|
|
19
18
|
|
|
20
|
-
Nowadays, vendors distribute statically linked binaries produced by
|
|
21
|
-
|
|
22
|
-
The
|
|
23
|
-
|
|
24
|
-
NOTE: The presence of capabilities doesn't imply that the operations are always performed by the binary. Use the output of this tool to get an idea about a binary. Also, this tool is not suitable to review malware and other heavily obfuscated binaries for obvious reasons.
|
|
19
|
+
Nowadays, vendors distribute statically linked binaries produced by Golang, Rust, or Dotnet tooling. Users are used to running antivirus and anti-malware scans while using these binaries in their local devices. Blint augments these scans by listing the technical capabilities of a binary. For example, whether the binary could use network connections or can perform file system operations and so on.
|
|
20
|
+
The binary is first parsed using the lief framework to identify the various properties, such as functions and the presence of symtab and dynamic symbols. Thanks to YAML-based annotation data, this information can be matched against capabilities and presented visually using a rich table.
|
|
21
|
+
NOTE: The presence of capabilities doesn't imply that the binary always performs the operations. Use the output of this tool to get an idea about a binary. Also, this tool is not suitable for reviewing malware and other heavily obfuscated binaries for obvious reasons.
|
|
25
22
|
|
|
26
23
|
## Use cases
|
|
27
24
|
|
|
@@ -39,7 +36,7 @@ pip install blint
|
|
|
39
36
|
|
|
40
37
|
### Single binary releases
|
|
41
38
|
|
|
42
|
-
You can download single binary builds from the [blint-bin releases](https://github.com/OWASP-dep-scan/blint/releases). These executables should work
|
|
39
|
+
You can download single binary builds from the [blint-bin releases](https://github.com/OWASP-dep-scan/blint/releases). These executables should work without requiring python to be installed. The macOS .pkg file is signed with a valid developer account.
|
|
43
40
|
|
|
44
41
|
## Usage
|
|
45
42
|
|
|
@@ -83,7 +80,7 @@ options:
|
|
|
83
80
|
operation.
|
|
84
81
|
```
|
|
85
82
|
|
|
86
|
-
To test any binary including default commands
|
|
83
|
+
To test any binary, including default commands
|
|
87
84
|
|
|
88
85
|
```bash
|
|
89
86
|
blint -i /bin/netstat -o /tmp/blint
|
|
@@ -111,12 +108,24 @@ blint sbom -i /path/to/apk -o bom.json
|
|
|
111
108
|
blint sbom -i /directory/with/apk/aab -o bom.json
|
|
112
109
|
```
|
|
113
110
|
|
|
114
|
-
To parse all files including `.dex` files, pass `--deep` argument.
|
|
111
|
+
To parse all files, including `.dex` files, pass `--deep` argument.
|
|
115
112
|
|
|
116
113
|
```shell
|
|
117
114
|
blint sbom -i /path/to/apk -o bom.json --deep
|
|
118
115
|
```
|
|
119
116
|
|
|
117
|
+
The following binaries are supported:
|
|
118
|
+
|
|
119
|
+
- Android (apk/aab)
|
|
120
|
+
- Dotnet executable binaries
|
|
121
|
+
- Go binaries
|
|
122
|
+
|
|
123
|
+
```shell
|
|
124
|
+
blint sbom -i /path/to/go-binaries -o bom.json --deep
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
For all other binaries, the symbols will be collected and represented as properties with `internal` prefixes for the parent component. Child components and dependencies would be missing.
|
|
128
|
+
|
|
120
129
|
PowerShell example
|
|
121
130
|
|
|
122
131
|

|
|
@@ -127,7 +136,7 @@ Blint produces the following json artifacts in the reports directory:
|
|
|
127
136
|
|
|
128
137
|
- blint-output.html - HTML output from the console logs
|
|
129
138
|
- exename-metadata.json - Raw metadata about the parsed binary. Includes symbols, functions, and signature information
|
|
130
|
-
- findings.json - Contains information from the security properties audit. Useful for CI/CD
|
|
139
|
+
- findings.json - Contains information from the security properties audit. Useful for CI/CD integrations
|
|
131
140
|
- reviews.json - Contains information from the capability reviews. Useful for further analysis
|
|
132
141
|
- fuzzables.json - Contains a suggested list of methods for fuzzing
|
|
133
142
|
|
|
@@ -140,10 +149,10 @@ sbom command generates CycloneDX json.
|
|
|
140
149
|
|
|
141
150
|
## Discord support
|
|
142
151
|
|
|
143
|
-
The developers
|
|
152
|
+
The developers can be reached via the [Discord](https://discord.gg/DCNxzaeUpd) channel.
|
|
144
153
|
|
|
145
154
|
## Sponsorship wishlist
|
|
146
155
|
|
|
147
|
-
If you love blint, you should consider [donating](https://owasp.org/donate?reponame=www-project-dep-scan&title=OWASP+dep-scan) to our project. In addition, consider donating to the below projects which make blint possible.
|
|
156
|
+
If you love blint, you should consider [donating](https://owasp.org/donate?reponame=www-project-dep-scan&title=OWASP+dep-scan) to our project. In addition, consider donating to the below projects, which make blint possible.
|
|
148
157
|
|
|
149
158
|
- [LIEF](https://github.com/sponsors/lief-project/)
|
|
@@ -229,7 +229,7 @@ def ignorable_symbol(symbol_name: str | None) -> bool:
|
|
|
229
229
|
"""
|
|
230
230
|
if not symbol_name:
|
|
231
231
|
return True
|
|
232
|
-
for pref in ("$f64.", "__"):
|
|
232
|
+
for pref in ("_$f", "$f64.", "__"):
|
|
233
233
|
if symbol_name.startswith(pref):
|
|
234
234
|
return True
|
|
235
235
|
return False
|
|
@@ -656,18 +656,19 @@ def parse_macho_symbols(symbols):
|
|
|
656
656
|
if not symbol_name or isinstance(symbol_name, lief.lief_errors):
|
|
657
657
|
symbol_name = symbol.name
|
|
658
658
|
symbol_name = symbol_name.replace("..", "::")
|
|
659
|
-
if not
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
659
|
+
if not ignorable_symbol(symbol_name):
|
|
660
|
+
if not exe_type:
|
|
661
|
+
exe_type = guess_exe_type(symbol_name)
|
|
662
|
+
symbols_list.append(
|
|
663
|
+
{
|
|
664
|
+
"name": (f"{libname}::{symbol_name}" if libname else symbol_name),
|
|
665
|
+
"short_name": symbol_name,
|
|
666
|
+
"type": symbol.type,
|
|
667
|
+
"num_sections": symbol.numberof_sections,
|
|
668
|
+
"description": symbol.description,
|
|
669
|
+
"value": symbol_value,
|
|
670
|
+
}
|
|
671
|
+
)
|
|
671
672
|
except (AttributeError, TypeError):
|
|
672
673
|
continue
|
|
673
674
|
return symbols_list, exe_type
|
|
@@ -759,6 +760,8 @@ def add_elf_metadata(exe_file, metadata, parsed_obj):
|
|
|
759
760
|
metadata["functions"] = parse_functions(parsed_obj.functions)
|
|
760
761
|
metadata["ctor_functions"] = parse_functions(parsed_obj.ctor_functions)
|
|
761
762
|
metadata["dotnet_dependencies"] = parse_overlay(parsed_obj)
|
|
763
|
+
metadata["go_dependencies"], metadata["go_formulation"] = parse_go_buildinfo(parsed_obj)
|
|
764
|
+
|
|
762
765
|
return metadata
|
|
763
766
|
|
|
764
767
|
|
|
@@ -927,6 +930,59 @@ def parse_overlay(parsed_obj: lief.Binary) -> dict[str, dict]:
|
|
|
927
930
|
return deps
|
|
928
931
|
|
|
929
932
|
|
|
933
|
+
def parse_go_buildinfo(parsed_obj: lief.Binary) -> (dict[str, dict[str, str]], dict[str, str]):
|
|
934
|
+
"""
|
|
935
|
+
Parse the go build info section to extract go dependencies
|
|
936
|
+
Args:
|
|
937
|
+
parsed_obj (lief.Binary): The parsed object representing the binary.
|
|
938
|
+
|
|
939
|
+
Returns:
|
|
940
|
+
tuple(dict[str, str], dict[str, str]): Tuple representing the dependencies and formulation.
|
|
941
|
+
"""
|
|
942
|
+
formulation = {}
|
|
943
|
+
deps = {}
|
|
944
|
+
build_info_str: str = ""
|
|
945
|
+
# Look for specific buildinfo sections for ELF and MachO binaries
|
|
946
|
+
build_info: lief.Section = None
|
|
947
|
+
if isinstance(parsed_obj, lief.ELF.Binary):
|
|
948
|
+
build_info = parsed_obj.get_section(".go.buildinfo")
|
|
949
|
+
elif isinstance(parsed_obj, lief.MachO.Binary):
|
|
950
|
+
build_info = parsed_obj.get_section("__go_buildinfo")
|
|
951
|
+
if build_info and build_info.size:
|
|
952
|
+
build_info_str = (
|
|
953
|
+
codecs.decode(build_info.content.tobytes(), encoding="utf-8", errors="replace")
|
|
954
|
+
.replace("\0", "")
|
|
955
|
+
.replace("\uFFFD", "")
|
|
956
|
+
.replace("\t", " ")
|
|
957
|
+
).strip()
|
|
958
|
+
build_info_str = build_info_str.encode('ascii', 'ignore').decode('ascii')
|
|
959
|
+
elif isinstance(parsed_obj, lief.PE.Binary):
|
|
960
|
+
# For PE binaries look for .data section
|
|
961
|
+
s: lief.PE.Section = parsed_obj.get_section(".data")
|
|
962
|
+
build_info_str = codecs.decode(s.content.tobytes()[:int(s.size / 32)], encoding="ascii",
|
|
963
|
+
errors="replace").replace("\0", "").replace("\uFFFD", "").replace("\t", " ")
|
|
964
|
+
lines = build_info_str.split("\n")
|
|
965
|
+
for line in lines:
|
|
966
|
+
if line.startswith("Go buildinf:"):
|
|
967
|
+
tmp_a = line.split("Go buildinf:")
|
|
968
|
+
formulation["go_version"] = tmp_a[-1].split("\x19")[0].split(" ")[-1]
|
|
969
|
+
if "path " in line:
|
|
970
|
+
tmp_a = line.split("path ")
|
|
971
|
+
formulation["path"] = tmp_a[-1]
|
|
972
|
+
if line.startswith("mod "):
|
|
973
|
+
tmp_a = line.split("mod ")
|
|
974
|
+
formulation["module"] = tmp_a[-1]
|
|
975
|
+
if line.startswith("dep "):
|
|
976
|
+
tmp_a = line.removeprefix("dep ").split(" ")
|
|
977
|
+
deps[tmp_a[0]] = {"version": tmp_a[1],
|
|
978
|
+
"hash": tmp_a[2] if len(tmp_a) == 3 and tmp_a[2].startswith("h1:") else None}
|
|
979
|
+
if line.startswith("build "):
|
|
980
|
+
tmp_a = line.removeprefix("build ").split("=")
|
|
981
|
+
formulation[tmp_a[0].replace("-", "")] = tmp_a[1]
|
|
982
|
+
|
|
983
|
+
return deps, formulation
|
|
984
|
+
|
|
985
|
+
|
|
930
986
|
def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
|
|
931
987
|
"""Adds PE metadata to the given metadata dictionary.
|
|
932
988
|
|
|
@@ -978,6 +1034,7 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
|
|
|
978
1034
|
if i == 14 and dd.type.value == lief.PE.DataDirectory.TYPES.CLR_RUNTIME_HEADER.value:
|
|
979
1035
|
metadata["is_dotnet"] = True
|
|
980
1036
|
metadata["dotnet_dependencies"] = parse_overlay(parsed_obj)
|
|
1037
|
+
metadata["go_dependencies"], metadata["go_formulation"] = parse_go_buildinfo(parsed_obj)
|
|
981
1038
|
tls = parsed_obj.tls
|
|
982
1039
|
if tls and tls.sizeof_zero_fill:
|
|
983
1040
|
metadata["tls_address_index"] = tls.addressof_index
|
|
@@ -1138,6 +1195,7 @@ def add_mach0_metadata(exe_file, metadata, parsed_obj):
|
|
|
1138
1195
|
metadata = add_mach0_commands(metadata, parsed_obj)
|
|
1139
1196
|
metadata = add_mach0_functions(metadata, parsed_obj)
|
|
1140
1197
|
metadata = add_mach0_signature(exe_file, metadata, parsed_obj)
|
|
1198
|
+
metadata["go_dependencies"], metadata["go_formulation"] = parse_go_buildinfo(parsed_obj)
|
|
1141
1199
|
return metadata
|
|
1142
1200
|
|
|
1143
1201
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import binascii
|
|
3
|
+
import codecs
|
|
2
4
|
import os
|
|
5
|
+
import urllib.parse
|
|
3
6
|
import uuid
|
|
4
7
|
from datetime import datetime
|
|
5
8
|
from typing import Any, Dict
|
|
@@ -317,44 +320,44 @@ def process_exe_file(
|
|
|
317
320
|
# If this is unsuccessful then store the information as a property
|
|
318
321
|
lib_components += components_from_symbols_version(symbols_version)
|
|
319
322
|
if not lib_components and symbols_version:
|
|
320
|
-
parent_component.properties
|
|
323
|
+
parent_component.properties.append(
|
|
321
324
|
Property(
|
|
322
325
|
name="internal:symbols_version",
|
|
323
326
|
value=", ".join([f["name"] for f in symbols_version]),
|
|
324
327
|
)
|
|
325
|
-
|
|
328
|
+
)
|
|
326
329
|
internal_functions = [f["name"] for f in metadata.get("functions", []) if not f["name"].startswith("__")]
|
|
327
330
|
if internal_functions:
|
|
328
|
-
parent_component.properties
|
|
331
|
+
parent_component.properties.append(
|
|
329
332
|
Property(
|
|
330
333
|
name="internal:functions",
|
|
331
334
|
value=SYMBOL_DELIMITER.join(internal_functions),
|
|
332
335
|
)
|
|
333
|
-
|
|
336
|
+
)
|
|
334
337
|
symtab_symbols = [f["name"] for f in metadata.get("symtab_symbols", [])]
|
|
335
338
|
if symtab_symbols:
|
|
336
|
-
parent_component.properties
|
|
339
|
+
parent_component.properties.append(
|
|
337
340
|
Property(
|
|
338
341
|
name="internal:symtab_symbols",
|
|
339
342
|
value=SYMBOL_DELIMITER.join(symtab_symbols),
|
|
340
343
|
)
|
|
341
|
-
|
|
344
|
+
)
|
|
342
345
|
all_imports = [f["name"] for f in metadata.get("imports", [])]
|
|
343
346
|
if all_imports:
|
|
344
|
-
parent_component.properties
|
|
347
|
+
parent_component.properties.append(
|
|
345
348
|
Property(
|
|
346
349
|
name="internal:imports",
|
|
347
350
|
value=SYMBOL_DELIMITER.join(all_imports),
|
|
348
351
|
)
|
|
349
|
-
|
|
352
|
+
)
|
|
350
353
|
dynamic_symbols = [f["name"] for f in metadata.get("dynamic_symbols", [])]
|
|
351
354
|
if dynamic_symbols:
|
|
352
|
-
parent_component.properties
|
|
355
|
+
parent_component.properties.append(
|
|
353
356
|
Property(
|
|
354
357
|
name="internal:dynamic_symbols",
|
|
355
358
|
value=SYMBOL_DELIMITER.join(dynamic_symbols),
|
|
356
359
|
)
|
|
357
|
-
|
|
360
|
+
)
|
|
358
361
|
if not sbom.metadata.component.components:
|
|
359
362
|
sbom.metadata.component.components = []
|
|
360
363
|
_add_to_parent_component(sbom.metadata.component.components, parent_component)
|
|
@@ -370,6 +373,18 @@ def process_exe_file(
|
|
|
370
373
|
if metadata.get("dotnet_dependencies"):
|
|
371
374
|
pe_components = process_dotnet_dependencies(metadata.get("dotnet_dependencies"), dependencies_dict)
|
|
372
375
|
lib_components += pe_components
|
|
376
|
+
# Convert go dependencies
|
|
377
|
+
if metadata.get("go_dependencies"):
|
|
378
|
+
go_components = process_go_dependencies(metadata.get("go_dependencies"))
|
|
379
|
+
lib_components += go_components
|
|
380
|
+
# Convert go formulation section
|
|
381
|
+
for k, v in metadata.get("go_formulation", {}).items():
|
|
382
|
+
parent_component.properties.append(
|
|
383
|
+
Property(
|
|
384
|
+
name=f"internal:{camel_to_snake(k)}",
|
|
385
|
+
value=str(v).strip(),
|
|
386
|
+
)
|
|
387
|
+
)
|
|
373
388
|
if lib_components:
|
|
374
389
|
components += lib_components
|
|
375
390
|
track_dependency(dependencies_dict, parent_component, lib_components)
|
|
@@ -485,9 +500,10 @@ def process_dotnet_dependencies(dotnet_deps: dict[str, dict], dependencies_dict:
|
|
|
485
500
|
purl = f"pkg:nuget/{tmp_a[0]}@{tmp_a[1]}"
|
|
486
501
|
hash_content = ""
|
|
487
502
|
try:
|
|
488
|
-
hash_content =
|
|
489
|
-
|
|
490
|
-
|
|
503
|
+
hash_content = codecs.encode(base64.b64decode(v.get("sha512").removeprefix("sha512-"), validate=True),
|
|
504
|
+
encoding="hex")
|
|
505
|
+
except binascii.Error:
|
|
506
|
+
hash_content = str(v.get("hash").removeprefix("sha512-"))
|
|
491
507
|
comp = Component(
|
|
492
508
|
type=Type.application if v.get("type") == "project" else Type.library,
|
|
493
509
|
name=tmp_a[0],
|
|
@@ -501,11 +517,11 @@ def process_dotnet_dependencies(dotnet_deps: dict[str, dict], dependencies_dict:
|
|
|
501
517
|
],
|
|
502
518
|
)
|
|
503
519
|
if hash_content:
|
|
504
|
-
comp.hashes =
|
|
520
|
+
comp.hashes = Hash(alg=HashAlg.SHA_512, content=hash_content),
|
|
505
521
|
comp.bom_ref = RefType(purl)
|
|
506
522
|
components.append(comp)
|
|
507
523
|
targets: dict[str, dict[str, dict]] = dotnet_deps.get("targets", {})
|
|
508
|
-
for
|
|
524
|
+
for _, tv in targets.items():
|
|
509
525
|
for k, v in tv.items():
|
|
510
526
|
tmp_a = k.split("/")
|
|
511
527
|
purl = f"pkg:nuget/{tmp_a[0]}@{tmp_a[1]}"
|
|
@@ -518,6 +534,45 @@ def process_dotnet_dependencies(dotnet_deps: dict[str, dict], dependencies_dict:
|
|
|
518
534
|
return components
|
|
519
535
|
|
|
520
536
|
|
|
537
|
+
def process_go_dependencies(go_deps: dict[str, str]) -> list[Component]:
|
|
538
|
+
"""
|
|
539
|
+
Process the go dependencies metadata extracted for binary overlays
|
|
540
|
+
|
|
541
|
+
Args:
|
|
542
|
+
go_deps (dict[str, str]): dependencies metadata
|
|
543
|
+
|
|
544
|
+
Returns:
|
|
545
|
+
list: New component list
|
|
546
|
+
"""
|
|
547
|
+
components = []
|
|
548
|
+
# Key is the name and value is the version
|
|
549
|
+
# We need to construct a purl by pretending the module name is the name with no namespace
|
|
550
|
+
# This would make this compatible with cdxgen and depscan
|
|
551
|
+
# See https://github.com/CycloneDX/cdxgen/issues/897
|
|
552
|
+
for k, v in go_deps.items():
|
|
553
|
+
purl = f"""pkg:golang/{urllib.parse.quote_plus(k)}@{v.get("version")}"""
|
|
554
|
+
comp = Component(
|
|
555
|
+
type=Type.library,
|
|
556
|
+
name=k,
|
|
557
|
+
version=v.get("version"),
|
|
558
|
+
purl=purl,
|
|
559
|
+
scope=Scope.required,
|
|
560
|
+
evidence=create_component_evidence(k, 1.0)
|
|
561
|
+
)
|
|
562
|
+
hash_content = ""
|
|
563
|
+
if v.get("hash"):
|
|
564
|
+
try:
|
|
565
|
+
hash_content = codecs.encode(base64.b64decode(v.get("hash").removeprefix("h1:"), validate=True),
|
|
566
|
+
encoding="hex")
|
|
567
|
+
except binascii.Error:
|
|
568
|
+
hash_content = str(v.get("hash").removeprefix("h1:"))
|
|
569
|
+
if hash_content:
|
|
570
|
+
comp.hashes = Hash(alg=HashAlg.SHA_256, content=hash_content)
|
|
571
|
+
comp.bom_ref = RefType(f"""pkg:golang/{k}@{v.get("version")}""")
|
|
572
|
+
components.append(comp)
|
|
573
|
+
return components
|
|
574
|
+
|
|
575
|
+
|
|
521
576
|
def track_dependency(
|
|
522
577
|
dependencies_dict: dict[str, set], parent_component: Component, app_components: list[Component]
|
|
523
578
|
) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|