Skip to content

Commit 4389a69

Browse files
Merge branch 'main' into improved-sbom-filename-extension-handling
2 parents e84e40f + 13004de commit 4389a69

22 files changed

+173
-74
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
# Initializes the CodeQL tools for scanning.
5353
- name: Initialize CodeQL
54-
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
54+
uses: github/codeql-action/init@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
5555
with:
5656
languages: ${{ matrix.language }}
5757
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -76,4 +76,4 @@ jobs:
7676
# make release
7777

7878
- name: Perform CodeQL Analysis
79-
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
79+
uses: github/codeql-action/analyze@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11

.github/workflows/formatting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: |
3737
python cve_bin_tool/format_checkers.py
3838
- name: Create Pull Request
39-
uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # v7.0.7
39+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
4040
with:
4141
commit-message: "chore: update checkers table"
4242
title: "chore: update checkers table"

.github/workflows/sbom.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
cp cve-bin-tool-py${{ matrix.python }}.json sbom/cve-bin-tool-py${{ matrix.python }}.json
6363
- name: Create Pull Request
6464
if: ${{ steps.diff-sbom.outputs.changed }}
65-
uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # v7.0.7
65+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
6666
with:
6767
commit-message: "chore: update SBOM for Python ${{ matrix.python }}"
6868
title: "chore: update SBOM for Python ${{ matrix.python }}"

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
persist-credentials: false
2828

2929
- name: "Run analysis"
30-
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
30+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
3131
with:
3232
results_file: results.sarif
3333
results_format: sarif

.github/workflows/update-js-dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: python -m pytest -v -n auto test/test_html.py
5555

5656
- name: Create Pull Request
57-
uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # v7.0.7
57+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
5858
with:
5959
commit-message: "chore: update js dependencies"
6060
title: "chore: update js dependencies"

.github/workflows/update-pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
python .github/workflows/update-dev-requirements.py
4949
5050
- name: Create Pull Request
51-
uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # v7.0.7
51+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
5252
with:
5353
commit-message: "chore: update pre-commit config"
5454
title: "chore: update pre-commit config"

.github/workflows/update-spdx-header.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
sed -i "s/[0-9]\{4\}/$(date +%Y)/" spdx_header.txt
3434
3535
- name: Create Pull Request
36-
uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # v7.0.7
36+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
3737
with:
3838
commit-message: 'chore: update spdx header'
3939
title: 'chore: update spdx header'

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ If you want to try the latest code from
7575

7676
Pip will install the python requirements for you, but for some types of extraction we use system libraries. If you have difficulties extracting files, you may want to look at our [additional Requirements lists for Linux and Windows](#additional-requirements).
7777

78-
On first usage (and by default, once per day) The tool will download vulnerability data from [a set of known vulnerability data sources](https://github.com/intel/cve-bin-tool/blob/main/doc/MANUAL.md#data-sources). Due to reliability issues with NVD, as of release 3.3 we will be using our own NVD mirror at [https://cveb.in/](https://cveb.in/) by default rather than contacting NVD directly. If you wish to get data directly from the NVD servers you must [provide your own NVD_API_KEY](https://github.com/intel/cve-bin-tool/blob/main/doc/MANUAL.md#--nvd-api-key-nvd_api_key) to use their API.
78+
On first usage (and by default, once per day), the tool will download vulnerability data from [a set of known vulnerability data sources](https://github.com/intel/cve-bin-tool/blob/main/doc/MANUAL.md#data-sources). Due to reliability issues with NVD, as of release 3.3, we will be using our own NVD mirror at [https://cveb.in/](https://cveb.in/) by default rather than contacting NVD directly. If you wish to get data directly from the NVD servers, you must [provide your own NVD_API_KEY](https://github.com/intel/cve-bin-tool/blob/main/doc/MANUAL.md#--nvd-api-key-nvd_api_key) to use their API.
7979

8080
If you are using a release prior to 3.3 that does not use our mirror, please use an NVD_API_KEY as described above.
8181

@@ -123,7 +123,7 @@ The [SBOM generation how-to guide](https://github.com/intel/cve-bin-tool/blob/ma
123123

124124
### Generating a VEX
125125

126-
As well as scanning VEX, CVE Binary Tool can be used to generate an VEX from a scan as follows:
126+
As well as scanning VEX, CVE Binary Tool can be used to generate a VEX from a scan as follows:
127127

128128
```bash
129129
cve-bin-tool --vex-type <vex_type> --vex-output <vex_filename> <other scan options as required>
@@ -137,7 +137,7 @@ The [VEX generation how-to guide](https://github.com/intel/cve-bin-tool/blob/mai
137137
### Triaging vulnerabilities
138138

139139
The `--vex-file` option can be used to add extra triage data like remarks, comments etc. while scanning a directory so that output will reflect this triage data and you can save time of re-triaging (Usage: `cve-bin-tool --vex-file test.json /path/to/scan`).
140-
The supported format is the [CycloneDX](https://cyclonedx.org/capabilities/vex/),[CSAF](https://oasis-open.github.io/csaf-documentation/) and [OpenVEX](https://edu.chainguard.dev/open-source/sbom/what-is-openvex/) VEX format which can be generated using the `--vex-output` option.
140+
The supported formats are the [CycloneDX](https://cyclonedx.org/capabilities/vex/), [CSAF](https://oasis-open.github.io/csaf-documentation/) and [OpenVEX](https://edu.chainguard.dev/open-source/sbom/what-is-openvex/) VEX formats which can be generated using the `--vex-output` option.
141141

142142
Typical usage:
143143

@@ -385,7 +385,7 @@ The tool does not guarantee that any vulnerabilities reported are actually prese
385385

386386
Users can add triage information to reports to mark issues as false positives, indicate that the risk has been mitigated by configuration/usage changes, and so on.
387387

388-
Triage details can be re-used on other projects so, for example, triage on a Linux base image could be applied to multiple containers using that image.
388+
Triage details can be reused on other projects so, for example, triage on a Linux base image could be applied to multiple containers using that image.
389389

390390
For more information and usage of triage information with the tool kindly have a look [here](https://cve-bin-tool.readthedocs.io/en/latest/triaging_process.html).
391391

@@ -508,6 +508,7 @@ Output:
508508
specify type of software bill of materials (sbom) to generate (default: spdx)
509509
<a href="https://github.com/intel/cve-bin-tool/blob/main/doc/MANUAL.md#--sbom-format">--sbom-format {tag,json,yaml}</a>
510510
specify format of software bill of materials (sbom) to generate (default: tag)
511+
--strip-scan-dir strip scan directory from sbom evidence location paths and CVE paths (useful with a firmware dump)
511512

512513
Vex Output:
513514
Arguments related to Vex output document.

cve_bin_tool/checkers/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ from cve_bin_tool.checkers import Checker
3535
class CurlChecker(Checker):
3636
```
3737

38-
Every checker may contain following 5 class attributes specific to product(ex: curl)
38+
Every checker may contain following 5 class attributes specific to product (ex: curl)
3939
you are making checker for:
4040

4141
1. CONTAINS_PATTERNS - list of commonly found strings in the binary of the product
@@ -45,7 +45,7 @@ you are making checker for:
4545
NVD.
4646
5. IGNORE_PATTERNS (optional) - list of patterns that could cause false positives (e.g. error messages that mention specific product/versions)
4747

48-
`CONTAINS_PATTERN`, `FILENAME_PATTERNS` and `VERSION_PATTERNS` supports regex to cover
48+
`CONTAINS_PATTERN`, `FILENAME_PATTERNS`, `VERSION_PATTERNS` and `IGNORE_PATTERNS` supports regex to cover
4949
wide range of use cases.
5050

5151
Once the checker is added, its name should also be added to `__init__.py` (so

cve_bin_tool/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ def main(argv=None):
348348
help="specify format of software bill of materials (sbom) to generate (default: tag)",
349349
)
350350
output_group.add_argument(
351-
"--sbom-strip-root",
351+
"--strip-scan-dir",
352352
action="store_true",
353-
help="strip SBOM root from evidence location paths (useful when building SBOM from firmware dump)",
353+
help="strip scan directory from sbom evidence location paths and CVE paths (useful with a firmware dump)",
354354
default=False,
355355
)
356356
vex_output_group = parser.add_argument_group(
@@ -1250,7 +1250,7 @@ def main(argv=None):
12501250
sbom_type=args["sbom_type"],
12511251
sbom_format=args["sbom_format"],
12521252
sbom_root=sbom_root,
1253-
sbom_strip_root=args["sbom_strip_root"],
1253+
strip_scan_dir=args["strip_scan_dir"],
12541254
offline=args["offline"],
12551255
)
12561256

cve_bin_tool/output_engine/__init__.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
intermediate_output,
3333
)
3434
from cve_bin_tool.sbom_manager.generate import SBOMGenerate
35+
from cve_bin_tool.util import strip_path
3536
from cve_bin_tool.version import VERSION
3637
from cve_bin_tool.vex_manager.generate import VEXGenerate
3738

@@ -44,6 +45,7 @@ def save_intermediate(
4445
products_with_cve: int,
4546
products_without_cve: int,
4647
total_files: int,
48+
strip_scan_dir: bool = False,
4749
):
4850
"""Save the intermediate report"""
4951

@@ -54,6 +56,7 @@ def save_intermediate(
5456
products_with_cve,
5557
products_without_cve,
5658
total_files,
59+
strip_scan_dir,
5760
)
5861
with open(filename, "w") as f:
5962
json.dump(inter_output, f, indent=" ")
@@ -62,14 +65,18 @@ def save_intermediate(
6265
def output_csv(
6366
all_cve_data: dict[ProductInfo, CVEData],
6467
all_cve_version_info: dict[str, VersionInfo] | None,
68+
scanned_dir: str,
6569
outfile,
6670
detailed: bool = False,
6771
affected_versions: int = 0,
6872
metrics: bool = False,
73+
strip_scan_dir: bool = False,
6974
):
7075
"""Output a CSV of CVEs"""
7176
formatted_output = format_output(
7277
all_cve_data,
78+
scanned_dir,
79+
strip_scan_dir,
7380
all_cve_version_info,
7481
detailed,
7582
affected_versions,
@@ -123,11 +130,13 @@ def output_pdf(
123130
is_report,
124131
products_with_cve,
125132
all_cve_version_info,
133+
scanned_dir: str,
126134
outfile,
127135
merge_report,
128136
affected_versions: int = 0,
129137
exploits: bool = False,
130138
metrics: bool = False,
139+
strip_scan_dir: bool = False,
131140
all_product_data=None,
132141
):
133142
"""Output a PDF of CVEs"""
@@ -321,7 +330,15 @@ def output_pdf(
321330
"comments": cve.comments,
322331
}
323332
)
324-
path_elements = ", ".join(cve_data["paths"])
333+
if strip_scan_dir:
334+
path_elements = ", ".join(
335+
[
336+
strip_path(path, scanned_dir)
337+
for path in cve_data["paths"]
338+
]
339+
)
340+
else:
341+
path_elements = ", ".join(cve_data["paths"])
325342
for path_element in path_elements.split(","):
326343
path_entry = {
327344
"vendor": product_info.vendor,
@@ -589,11 +606,13 @@ def output_pdf(
589606
is_report,
590607
products_with_cve,
591608
all_cve_version_info,
609+
scanned_dir: str,
592610
outfile,
593611
merge_report,
594612
affected_versions: int = 0,
595613
exploits: bool = False,
596614
all_product_data=None,
615+
strip_scan_dir: bool = False,
597616
):
598617
"""Output a PDF of CVEs
599618
Required module: Reportlab not found"""
@@ -629,6 +648,7 @@ class OutputEngine:
629648
sbom_type (str)
630649
sbom_format (str)
631650
sbom_root (str)
651+
strip_scan_dir (bool)
632652
offline (bool)
633653
634654
Methods:
@@ -667,7 +687,7 @@ def __init__(
667687
sbom_type: str = "spdx",
668688
sbom_format: str = "tag",
669689
sbom_root: str = "CVE_SBOM",
670-
sbom_strip_root: bool = False,
690+
strip_scan_dir: bool = False,
671691
vex_filename: str = "",
672692
vex_type: str = "",
673693
vex_product_info: dict[str, str] = {},
@@ -699,7 +719,7 @@ def __init__(
699719
self.sbom_type = sbom_type
700720
self.sbom_format = sbom_format
701721
self.sbom_root = sbom_root
702-
self.sbom_strip_root = sbom_strip_root
722+
self.strip_scan_dir = strip_scan_dir
703723
self.offline = offline
704724
self.organized_arguements = organized_arguements
705725
self.sbom_packages = {}
@@ -716,43 +736,51 @@ def output_cves(self, outfile, output_type="console"):
716736
output_json(
717737
self.all_cve_data,
718738
self.all_cve_version_info,
739+
self.scanned_dir,
719740
outfile,
720741
self.detailed,
721742
self.affected_versions,
722743
self.metrics,
744+
self.strip_scan_dir,
723745
)
724746
elif output_type == "json2":
725747
output_json2(
726748
self.all_cve_data,
727749
self.all_cve_version_info,
750+
self.scanned_dir,
728751
self.time_of_last_update,
729752
outfile,
730753
self.affected_versions,
731754
self.organized_arguements,
732755
self.detailed,
733756
self.exploits,
734757
self.metrics,
758+
self.strip_scan_dir,
735759
)
736760
elif output_type == "csv":
737761
output_csv(
738762
self.all_cve_data,
739763
self.all_cve_version_info,
764+
self.scanned_dir,
740765
outfile,
741766
self.detailed,
742767
self.affected_versions,
743768
self.metrics,
769+
self.strip_scan_dir,
744770
)
745771
elif output_type == "pdf":
746772
output_pdf(
747773
self.all_cve_data,
748774
self.is_report,
749775
self.products_with_cve,
750776
self.all_cve_version_info,
777+
self.scanned_dir,
751778
outfile,
752779
self.merge_report,
753780
self.affected_versions,
754781
self.exploits,
755782
self.metrics,
783+
self.strip_scan_dir,
756784
)
757785
elif output_type == "html":
758786
output_html(
@@ -768,15 +796,18 @@ def output_cves(self, outfile, output_type="console"):
768796
self.logger,
769797
outfile,
770798
self.affected_versions,
799+
self.strip_scan_dir,
771800
)
772801
else: # console, or anything else that is unrecognised
773802
output_console(
774803
self.all_cve_data,
775804
self.all_cve_version_info,
805+
self.scanned_dir,
776806
self.time_of_last_update,
777807
self.affected_versions,
778808
self.exploits,
779809
self.metrics,
810+
self.strip_scan_dir,
780811
self.all_product_data,
781812
self.offline,
782813
None,
@@ -789,6 +820,7 @@ def output_cves(self, outfile, output_type="console"):
789820
self.append,
790821
self.tag,
791822
self.scanned_dir,
823+
self.strip_scan_dir,
792824
self.products_with_cve,
793825
self.products_without_cve,
794826
self.total_files,
@@ -819,7 +851,7 @@ def output_cves(self, outfile, output_type="console"):
819851
self.sbom_type,
820852
self.sbom_format,
821853
self.sbom_root,
822-
self.sbom_strip_root,
854+
self.strip_scan_dir,
823855
self.logger,
824856
)
825857
sbomgen.generate_sbom()

cve_bin_tool/output_engine/console.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ..input_engine import Remarks
1919
from ..linkify import linkify_cve
2020
from ..theme import cve_theme
21-
from ..util import ProductInfo, VersionInfo
21+
from ..util import ProductInfo, VersionInfo, strip_path
2222
from ..version import VERSION
2323
from .util import (
2424
format_path,
@@ -47,10 +47,12 @@ def output_console(*args: Any):
4747
def _output_console_nowrap(
4848
all_cve_data: dict[ProductInfo, CVEData],
4949
all_cve_version_info: dict[str, VersionInfo],
50+
scanned_dir: str,
5051
time_of_last_update: datetime,
5152
affected_versions: int,
5253
exploits: bool = False,
5354
metrics: bool = False,
55+
strip_scan_dir: bool = False,
5456
all_product_data=None,
5557
offline: bool = False,
5658
width: int = None,
@@ -286,13 +288,17 @@ def validate_cell_length(cell_name, cell_type):
286288
color = "green"
287289
for cve_data in cve_by_paths[remarks]:
288290
path_root = format_path(cve_data["paths"])
291+
if strip_scan_dir:
292+
path_root_0 = strip_path(path_root[0], scanned_dir)
293+
else:
294+
path_root_0 = path_root[0]
289295
cells = [
290296
Text.styled(validate_cell_length(cve_data["vendor"], "Vendor "), color),
291297
Text.styled(
292298
validate_cell_length(cve_data["product"], "Product "), color
293299
),
294300
Text.styled(cve_data["version"], color),
295-
Text.styled(validate_cell_length(path_root[0], "Root "), color),
301+
Text.styled(validate_cell_length(path_root_0, "Root "), color),
296302
Text.styled(validate_cell_length(path_root[1], "Path "), color),
297303
]
298304
table.add_row(*cells)

0 commit comments

Comments
 (0)