Skip to content

Commit dda8039

Browse files
Merge branch 'main' into parser
2 parents 983388e + fb9cca7 commit dda8039

26 files changed

+9504
-297
lines changed

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
tool: ['isort', 'black', 'pyupgrade', 'flake8', 'bandit', 'gitlint']
15+
tool: ['isort', 'black', 'pyupgrade', 'flake8', 'bandit', 'gitlint', 'mypy']
1616
steps:
1717
- uses: actions/checkout@v3
1818
- uses: actions/setup-python@v4

.github/workflows/sbom.yml

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: SBOM generation
22

33
on:
4+
workflow_dispatch:
45
schedule:
56
# Runs at 02:00 UTC every Monday
67
- cron: '2 0 * * 1'
@@ -9,45 +10,51 @@ jobs:
910
sbom_gen:
1011
name: Generate SBOM
1112
runs-on: ubuntu-latest
12-
timeout-minutes: 10
13-
continue-on-error: true
13+
strategy:
14+
matrix:
15+
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
1416
steps:
1517
- uses: actions/checkout@v3
1618
- uses: actions/setup-python@v4
1719
with:
18-
python-version: '3.x'
20+
python-version: ${{ matrix.python }}
1921
cache: 'pip'
2022
cache-dependency-path: '**/requirements.txt'
21-
- name: Get date
22-
id: get-date
23-
run: |
24-
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
25-
- name: Get cached database
26-
uses: actions/cache@v3
27-
with:
28-
path: ~/.cache/cve-bin-tool
29-
key: ${{ runner.os }}-cve-bin-tool-${{ steps.get-date.outputs.date }}
3023
- name: Install dependencies and cve-bin-tool
3124
run: |
3225
python -m pip install --upgrade pip
3326
python -m pip install --upgrade setuptools
3427
python -m pip install --upgrade wheel
35-
python -m pip install --upgrade pytest
3628
python -m pip install --upgrade sbom4python
37-
pip install . -r doc/requirements.txt
29+
pip install . --upgrade --upgrade-strategy=eager
3830
- name: Generate SBOM for cve-bin-tool
3931
run: |
40-
sbom4python --module cve-bin-tool --output sbom/cve-bin-tool.spdx
41-
sbom4python --module cve-bin-tool --sbom cyclonedx --format json --output sbom/cve-bin-tool.json
42-
# - name: Compare SBOM for cve-bin-tool
43-
# # This would fail due to time/date of SBOM generation in SBOM header
44-
# # Therefore ignore first 10 lines of file in comparison which is SBOM header
45-
# run: |
46-
# /bin/tail -n +10 sbom/cve-bin-tool.spdx > orig
47-
# /bin/tail -n +10 cve-bin-tool.spdx > new
48-
# /bin/diff -b orig new
49-
# - name: Display generated SBOM if difference detected
50-
# if: ${{ failure() }}
51-
# run: |
52-
# /bin/cat cve-bin-tool.spdx
53-
32+
sbom4python --module cve-bin-tool --output cve-bin-tool-py${{ matrix.python }}.spdx
33+
sbom4python --module cve-bin-tool --sbom cyclonedx --format json --output cve-bin-tool-py${{ matrix.python }}.json
34+
- name: Compare SBOM for cve-bin-tool
35+
id: diff-sbom
36+
# This would fail due to time/date of SBOM generation in SBOM header
37+
# Therefore ignore first 10 lines of file in comparison which is SBOM header
38+
run: |
39+
/bin/tail -n +10 sbom/cve-bin-tool-py${{ matrix.python }}.spdx > orig
40+
/bin/tail -n +10 cve-bin-tool-py${{ matrix.python }}.spdx > new
41+
echo "changed=$(/bin/diff -q orig new)" >> $GITHUB_OUTPUT
42+
- name: Display generated SBOM if difference detected
43+
if: ${{ steps.diff-sbom.outputs.changed }}
44+
run: |
45+
/bin/cat cve-bin-tool-py${{ matrix.python }}.spdx
46+
- name: Update existing SBOM if difference detected
47+
if: ${{ steps.diff-sbom.outputs.changed }}
48+
run: |
49+
cp cve-bin-tool-py${{ matrix.python }}.spdx sbom/cve-bin-tool-py${{ matrix.python }}.spdx
50+
cp cve-bin-tool-py${{ matrix.python }}.json sbom/cve-bin-tool-py${{ matrix.python }}.json
51+
- name: Create Pull Request
52+
if: ${{ steps.diff-sbom.outputs.changed }}
53+
uses: peter-evans/create-pull-request@v4
54+
with:
55+
commit-message: "chore: update SBOM for Python ${{ matrix.python }}"
56+
title: "chore: update SBOM for Python ${{ matrix.python }}"
57+
branch: chore-sbom-py${{ matrix.python }}
58+
delete-branch: true
59+
author: GitHub <[email protected]>
60+
add-paths: sbom

.github/workflows/testing.yml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: ubuntu-latest
4848
strategy:
4949
matrix:
50-
python: ['3.7', '3.8', '3.9']
50+
python: ['3.7', '3.8', '3.9', '3.11']
5151
timeout-minutes: 20
5252
steps:
5353
- uses: actions/checkout@v3
@@ -294,31 +294,6 @@ jobs:
294294
test/test_cvedb.py
295295
- name: Run HTML tests
296296
run: pytest -v -n auto test/test_html.py
297-
- name: Cache conda
298-
uses: actions/cache@v3
299-
env:
300-
# Increase to reset cache if requirements.txt file has not changed
301-
CACHE_NUMBER: 0
302-
with:
303-
path: ~/conda_pkgs_dir
304-
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
305-
hashFiles('requirements.txt') }}
306-
- uses: conda-incubator/setup-miniconda@v2
307-
with:
308-
auto-update-conda: true
309-
activate-environment: pdftotext
310-
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
311-
- name: Install pdftotext, reportlab and cve-bin-tool
312-
run: |
313-
conda install -c conda-forge python=3.10 poppler pdftotext
314-
python -m pip install --upgrade pip
315-
python -m pip install --upgrade setuptools
316-
python -m pip install --upgrade wheel
317-
python -m pip install --upgrade reportlab
318-
python -m pip install --upgrade -r dev-requirements.txt
319-
python -m pip install --upgrade .
320-
- name: Test PDF generation on Windows
321-
run: pytest test/test_output_engine.py -k test_output_pdf
322297

323298
windows_long_tests:
324299
name: Windows long tests
@@ -401,4 +376,4 @@ jobs:
401376
files: ./coverage.xml
402377
flags: win-longtests
403378
name: codecov-umbrella
404-
fail_ci_if_error: false
379+
fail_ci_if_error: false

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ jobs:
2222
python-version: '3.x'
2323

2424
- name: Update JS dependencies
25-
run: |
26-
python .github/workflows/update_js_dependencies.py
25+
run: python .github/workflows/update_js_dependencies.py
2726

2827
- name: Get cached Python packages
2928
uses: actions/cache@v3
@@ -35,15 +34,13 @@ jobs:
3534
3635
- name: Install dependencies
3736
run: |
38-
sudo apt-get update
39-
sudo apt-get install build-essential libpoppler-cpp-dev pkg-config python3-dev
4037
python -m pip install --upgrade pip
4138
python -m pip install --upgrade setuptools wheel
42-
python -m pip install --upgrade -r requirements.txt pytest pdftotext
39+
python -m pip install --upgrade . pytest-xdist pytest-playwright
40+
python -m playwright install chromium --with-deps
4341
44-
- name: Test HTML report generation
45-
run: |
46-
pytest test/test_output_engine.py -k test_output_html
42+
- name: Run HTML tests
43+
run: python -m pytest -v -n auto test/test_html.py
4744

4845
- name: Create Pull Request
4946
uses: peter-evans/create-pull-request@v4
@@ -62,11 +59,10 @@ jobs:
6259
run: |
6360
python -c 'from test.test_output_engine import TestOutputEngine; \
6461
from cve_bin_tool.output_engine.html import output_html; \
65-
output_html(TestOutputEngine.MOCK_OUTPUT, "", "", "", 3, 3, 0, None, None, open("test.html", "w"))'
62+
output_html(TestOutputEngine.MOCK_OUTPUT, None, "", "", "", 3, 3, 0, None, None, open("test.html", "w"))'
6663
6764
- name: Upload mock report
6865
uses: actions/upload-artifact@v3
6966
with:
7067
name: HTML report
71-
path: |
72-
test.html
68+
path: test.html

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,38 @@ repos:
3131
rev: v0.17.0
3232
hooks:
3333
- id: gitlint
34+
35+
- repo: https://github.com/pre-commit/mirrors-mypy
36+
rev: v0.991
37+
hooks:
38+
- id: mypy
39+
additional_dependencies:
40+
- types-beautifulsoup4
41+
- types-jsonschema
42+
- types-PyYAML
43+
- types-requests
44+
- types-setuptools
45+
- types-toml
46+
files: |
47+
(?x)^(
48+
cve_bin_tool/parsers/.*|
49+
cve_bin_tool/__init__.py|
50+
cve_bin_tool/async_utils.py|
51+
cve_bin_tool/file.py|
52+
cve_bin_tool/linkify.py|
53+
cve_bin_tool/log.py|
54+
cve_bin_tool/strings.py|
55+
cve_bin_tool/theme.py|
56+
cve_bin_tool/util.py|
57+
cve_bin_tool/validator.py|
58+
cve_bin_tool/version.py|
59+
doc/.*|
60+
test/test_data/.*|
61+
test/__init__.py|
62+
test/test_file.py|s
63+
test/test_requirements.py|
64+
test/test_strings.py|
65+
test/test_triage.py|
66+
test/test_version.py|
67+
test/utils.py|
68+
)$

cve_bin_tool/data_sources/gad_source.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ def format_data(self, all_cve_entries):
211211
for cve_item in all_cve_entries:
212212
cve_in_identifier = None
213213

214+
if not cve_item:
215+
continue
216+
214217
for cve in cve_item.get("identifiers"):
215218
if "CVE" in cve:
216219
cve_in_identifier = cve

cve_bin_tool/output_engine/html_reports/js/bootstrap.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cve_bin_tool/output_engine/html_reports/js/plotly.js

Lines changed: 3 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pre-commit==2.20.0
44
flake8==5.0.4
55
bandit==1.7.4
66
gitlint== v0.17.0
7+
mypy==v0.991
78
py>=1.10.0
89
pytest
910
pytest-xdist

0 commit comments

Comments
 (0)