Skip to content

Commit ca91566

Browse files
Merge branch 'main' into improve-test-nvd-api
2 parents 449f24c + cc4c13c commit ca91566

21 files changed

+565
-706
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@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
54+
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
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@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
79+
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- name: 'Checkout Repository'
2525
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2626
- name: 'Dependency Review'
27-
uses: actions/dependency-review-action@38ecb5b593bf0eb19e335c03f97670f792489a8b # v4.7.0
27+
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1

.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@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
30+
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
3131
with:
3232
results_file: results.sarif
3333
results_format: sarif

.github/workflows/spelling.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
egress-policy: audit
2121

2222
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
23-
- uses: check-spelling/[email protected].24
23+
- uses: check-spelling/[email protected].25
2424
with:
2525
extra_dictionaries:
2626
cspell:python/src/python/python.txt

.github/workflows/testing.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ jobs:
285285
--ignore=test/test_language_parser.py
286286
- name: Upload code coverage to codecov
287287
if: env.sbom != 'true'
288-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
288+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
289289
with:
290290
token: ${{ secrets.CODECOV_TOKEN }}
291291
files: coverage.xml
@@ -388,7 +388,7 @@ jobs:
388388
test/test_language_scanner.py
389389
- name: Upload code coverage to codecov
390390
if: env.sbom != 'true'
391-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
391+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
392392
with:
393393
token: ${{ secrets.CODECOV_TOKEN }}
394394
files: coverage.xml
@@ -491,7 +491,7 @@ jobs:
491491
test/test_scanner.py
492492
- name: Upload code coverage to codecov
493493
if: env.sbom != 'true'
494-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
494+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
495495
with:
496496
token: ${{ secrets.CODECOV_TOKEN }}
497497
files: coverage.xml
@@ -595,7 +595,7 @@ jobs:
595595
test/test_cvedb.py
596596
- name: Upload code coverage to codecov
597597
if: env.sbom != 'true'
598-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
598+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
599599
with:
600600
token: ${{ secrets.CODECOV_TOKEN }}
601601
files: coverage.xml
@@ -873,7 +873,7 @@ jobs:
873873
-o junit_family=legacy
874874
--durations=50
875875
- name: Upload code coverage to codecov
876-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
876+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
877877
with:
878878
files: coverage.xml
879879
flags: windows_long_tests

cve_bin_tool/checkers/ffmpeg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FfmpegChecker(Checker):
2828
r"ffmpeg",
2929
]
3030
VERSION_PATTERNS = [
31-
r"%s version ([0-9]+\.[0-9]+\.[0-9]+)[a-zA-Z0-9 \(\)%~\-\r\n]*(?:avutil|FFmpeg)",
32-
r"FFmpeg version n?([0-9]+\.[0-9]+\.[0-9]+)",
31+
r"%s version ([0-9]+\.[0-9]+(\.[0-9]+)?)[a-zA-Z0-9 \(\)%~\-\r\n]*(?:avutil|FFmpeg)",
32+
r"FFmpeg version n?([0-9]+\.[0-9]+(\.[0-9]+)?)",
3333
]
3434
VENDOR_PRODUCT = [("ffmpeg", "ffmpeg")]

cve_bin_tool/checkers/linuxptp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class LinuxptpChecker(Checker):
1717
CONTAINS_PATTERNS: list[str] = []
1818
FILENAME_PATTERNS: list[str] = []
1919
VERSION_PATTERNS = [
20-
r"(?:ptp|PTP_)[A-Za-z0-9_:% \[\]\-\.\r\n]*\r?\n([0-9]\.[0-9])\r?\n"
20+
r"[ \n]+(?:ptp|PTP_)[A-Za-z0-9_:% \[\]\-\.\r\n]*\r?\n([0-9]\.[0-9])\r?\n"
2121
]
2222
VENDOR_PRODUCT = [("linuxptp_project", "linuxptp")]

cve_bin_tool/data_sources/nvd_source.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ async def fetch_cves(self):
420420
tasks = [
421421
self.cache_update(self.session, url, meta["sha256"])
422422
for url, meta in nvd_metadata.items()
423-
if meta is not None
423+
if meta is not None and meta.get("sha256") is not None
424424
]
425425

426426
total_tasks = len(tasks)
@@ -579,6 +579,9 @@ async def cache_update(
579579
# Raise for all other 4xx errors
580580
response.raise_for_status()
581581
gzip_data = await response.read()
582+
if len(gzip_data) == 0:
583+
self.LOGGER.debug(f"Missing data for {filename}")
584+
return
582585
json_data = gzip.decompress(gzip_data)
583586
gotsha = hashlib.sha256(json_data).hexdigest().upper()
584587
async with FileIO(filepath, "wb") as filepath_handle:

cve_bin_tool/parsers/opkg.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ def run_checker(self, filename):
3939
if cpe_id is None:
4040
self.logger.debug(f"{filename} doesn't contain any CPE-ID")
4141
return
42-
# version is always suffixed by a digit (e.g. 2.90-1 instead of 2.90)
42+
# version is always suffixed (e.g. 2.90-r1 instead of 2.90)
43+
# it can sometimes be prefixed (e.g. gen_2.90_v0.2.3-r1)
4344
version = search(
44-
compile(r"^Version: (.+)-([0-9\.]+)$", MULTILINE), lines
45+
compile(r"^Version: [a-z_]*([0-9_\-\.]+)[-_]+", MULTILINE), lines
4546
).group(1)
4647
vendor, product, _ = decode_cpe22(f"{cpe_id.group(1)}:{version}")
4748
vendorlist: list[ScanInfo] = [

doc/MANUAL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ To disable multiple data sources, the data sources should be specified as a comm
870870

871871
### -s SKIPS, --skips SKIPS
872872

873-
This option allows one to skip (disable) a comma-separated list of checkers. This can be useful for improving the performance of the tool when you have some prior knowledge about what checkers may apply to the binary you are scanning.
873+
This option allows one to skip (disable) a comma-separated list of checkers and language parsers. This can be useful for improving the performance of the tool when you have some prior knowledge about what checkers may apply to the binary you are scanning or what language parsers are needed. The `--skips` flag works for both binary checkers and language parsers.
874874

875875
### -r CHECKERS, --runs CHECKERS
876876

0 commit comments

Comments
 (0)