sec-report-kit 0.3.5__tar.gz → 0.4.4__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.
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/.github/workflows/pip-audit.yml +0 -2
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/.github/workflows/publish-pypi.yml +1 -6
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/.github/workflows/publish-testpypi.yml +1 -4
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/.github/workflows/trivy-fs-audit.yml +0 -2
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/.github/workflows/unit-test-coverage-gate.yml +0 -4
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/CHANGELOG.md +28 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/PKG-INFO +1 -1
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/pyproject.toml +1 -1
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/requirements.txt +7 -7
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/__init__.py +1 -1
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/cli.py +21 -0
- sec_report_kit-0.4.4/src/sec_report_kit/models.py +41 -0
- sec_report_kit-0.4.4/src/sec_report_kit/parsers/cyclonedx.py +94 -0
- sec_report_kit-0.4.4/src/sec_report_kit/report/sbom_renderer.py +209 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/tests/test_cli.py +53 -0
- sec_report_kit-0.4.4/tests/test_cyclonedx.py +155 -0
- sec_report_kit-0.3.5/src/sec_report_kit/models.py +0 -16
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/.gitattributes +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/.gitignore +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/README.md +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/bandit-gaps-vs-sast-open-source-tools.md +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/check_assets.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/download_safety_db.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/download_safety_db.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/download_safety_db.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/install_external_clis.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/install_tools.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/install_tools.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/mcp_add_workspace_filesystem.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/mcp_add_workspace_filesystem.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/mcp_add_workspace_filesystem_help.md +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_bandit_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_bandit_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_checkov_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_checkov_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_codeql_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_codeql_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_consolidated_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_consolidated_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_gitleaks_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_gitleaks_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_osv_scanner_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_osv_scanner_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_pip_audit_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_pip_audit_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_safety_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_safety_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_semgrep_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_semgrep_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_tfsec_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_tfsec_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_trivy_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_trivy_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_trufflehog_html.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/render_trufflehog_html.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_all_security_scans.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_all_security_scans.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_bandit.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_bandit.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_checkov.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_checkov.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_codeql.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_codeql.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_gitleaks.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_gitleaks.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_osv_scanner.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_osv_scanner.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_pip_audit.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_pip_audit.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_safety.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_safety.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_semgrep.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_semgrep.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_tfsec.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_tfsec.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_trivy.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_trivy.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_trufflehog.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_trufflehog.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_unit_tests_with_coverage.bat +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/scripts/run_unit_tests_with_coverage.sh +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/__main__.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/generate_consolidated_security_report.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/mcp/__init__.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/mcp/server.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/__init__.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/bandit.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/checkov.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/codeql.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/gitleaks.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/osv_scanner.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/pip_audit.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/safety.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/semgrep.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/tfsec.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/trivy.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/parsers/trufflehog.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/report/__init__.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/report/html_renderer.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/services/__init__.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/services/normalize.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/src/sec_report_kit/services/summarize.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/tests/test_html_renderer.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/tests/test_mcp_server.py +0 -0
- {sec_report_kit-0.3.5 → sec_report_kit-0.4.4}/tests/test_parsers.py +0 -0
|
@@ -14,8 +14,6 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
steps:
|
|
16
16
|
- uses: actions/checkout@v4
|
|
17
|
-
with:
|
|
18
|
-
token: ${{ secrets.REPO_ACCESS_TOKEN || github.token }}
|
|
19
17
|
|
|
20
18
|
- uses: actions/setup-python@v5
|
|
21
19
|
with:
|
|
@@ -49,8 +47,6 @@ jobs:
|
|
|
49
47
|
runs-on: ubuntu-latest
|
|
50
48
|
steps:
|
|
51
49
|
- uses: actions/checkout@v4
|
|
52
|
-
with:
|
|
53
|
-
token: ${{ secrets.REPO_ACCESS_TOKEN || github.token }}
|
|
54
50
|
|
|
55
51
|
- uses: actions/setup-python@v5
|
|
56
52
|
with:
|
|
@@ -68,12 +64,11 @@ jobs:
|
|
|
68
64
|
runs-on: ubuntu-latest
|
|
69
65
|
environment: pypi
|
|
70
66
|
permissions:
|
|
67
|
+
contents: read # required for checkout on private repos
|
|
71
68
|
id-token: write # required for OIDC trusted publishing
|
|
72
69
|
|
|
73
70
|
steps:
|
|
74
71
|
- uses: actions/checkout@v4
|
|
75
|
-
with:
|
|
76
|
-
token: ${{ secrets.REPO_ACCESS_TOKEN || github.token }}
|
|
77
72
|
|
|
78
73
|
- uses: actions/setup-python@v5
|
|
79
74
|
with:
|
|
@@ -14,8 +14,6 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
steps:
|
|
16
16
|
- uses: actions/checkout@v4
|
|
17
|
-
with:
|
|
18
|
-
token: ${{ secrets.REPO_ACCESS_TOKEN || github.token }}
|
|
19
17
|
|
|
20
18
|
- uses: actions/setup-python@v5
|
|
21
19
|
with:
|
|
@@ -33,12 +31,11 @@ jobs:
|
|
|
33
31
|
runs-on: ubuntu-latest
|
|
34
32
|
environment: testpypi
|
|
35
33
|
permissions:
|
|
34
|
+
contents: read # required for checkout on private repos
|
|
36
35
|
id-token: write # required for OIDC trusted publishing
|
|
37
36
|
|
|
38
37
|
steps:
|
|
39
38
|
- uses: actions/checkout@v4
|
|
40
|
-
with:
|
|
41
|
-
token: ${{ secrets.REPO_ACCESS_TOKEN || github.token }}
|
|
42
39
|
|
|
43
40
|
- uses: actions/setup-python@v5
|
|
44
41
|
with:
|
|
@@ -15,8 +15,6 @@ jobs:
|
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
16
|
steps:
|
|
17
17
|
- uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
token: ${{ secrets.REPO_ACCESS_TOKEN || github.token }}
|
|
20
18
|
|
|
21
19
|
- uses: actions/setup-python@v5
|
|
22
20
|
with:
|
|
@@ -36,8 +34,6 @@ jobs:
|
|
|
36
34
|
runs-on: ubuntu-latest
|
|
37
35
|
steps:
|
|
38
36
|
- uses: actions/checkout@v4
|
|
39
|
-
with:
|
|
40
|
-
token: ${{ secrets.REPO_ACCESS_TOKEN || github.token }}
|
|
41
37
|
|
|
42
38
|
- uses: actions/setup-python@v5
|
|
43
39
|
with:
|
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.4.4 - 2026-07-12
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Added `contents: read` to the PyPI/TestPyPI publish jobs. A job-level `permissions` block replaces the workflow default instead of merging, so declaring only `id-token: write` left `contents: none`, breaking checkout on the private repo. Trusted publishing (OIDC) is unaffected.
|
|
9
|
+
|
|
10
|
+
## 0.4.3 - 2026-07-12
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Removed the invalid `REPO_ACCESS_TOKEN` checkout override from all GitHub Actions workflows so they authenticate with the default `GITHUB_TOKEN`, fixing the "Repository not found" failures in the PyPI/TestPyPI publish pipelines.
|
|
14
|
+
|
|
15
|
+
## 0.4.2 - 2026-07-12
|
|
16
|
+
|
|
17
|
+
### Tests
|
|
18
|
+
- Added test coverage for the CycloneDX parser, SBOM HTML renderer, and `srk render sbom` command, restoring the enforced 100% suite coverage gate.
|
|
19
|
+
|
|
20
|
+
## 0.4.1 - 2026-07-12
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Bumped `requirements.txt` pins to clear 13 fixable CRITICAL/HIGH/MEDIUM findings from the Trivy filesystem audit: `PyJWT` 2.12.1→2.13.0, `cryptography` 47.0.0→48.0.1, `idna` 3.13→3.15, `msgpack` 1.1.2→1.2.1, `pydantic-settings` 2.14.0→2.14.2, `python-multipart` 0.0.27→0.0.30, and `starlette` 1.0.0→1.3.1.
|
|
24
|
+
|
|
25
|
+
## 0.4.0 - 2026-07-12
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- New CLI command: `srk render sbom` to render a CycloneDX SBOM JSON into an HTML component inventory report.
|
|
29
|
+
- New `Component` and `SbomDocument` models for representing SBOM component inventories.
|
|
30
|
+
- New CycloneDX parser (`parsers/cyclonedx.py`) handling `license.id`, `license.name`, and `expression` license shapes, with purl-derived ecosystem detection.
|
|
31
|
+
- New SBOM HTML renderer (`report/sbom_renderer.py`) with summary cards, component-type/ecosystem/license breakdowns, and a client-side filterable component table.
|
|
32
|
+
|
|
5
33
|
## 0.3.5 - 2026-05-21
|
|
6
34
|
|
|
7
35
|
### Added
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sec-report-kit"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.4"
|
|
8
8
|
description = "Generate HTML security reports from Trivy, pip-audit, Safety, Bandit, and Gitleaks JSON"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -12,7 +12,7 @@ charset-normalizer==3.4.7
|
|
|
12
12
|
click==8.3.3
|
|
13
13
|
colorama==0.4.6
|
|
14
14
|
coverage==7.14.0
|
|
15
|
-
cryptography==
|
|
15
|
+
cryptography==48.0.1
|
|
16
16
|
cyclonedx-python-lib==11.7.0
|
|
17
17
|
defusedxml==0.7.1
|
|
18
18
|
docutils==0.22.4
|
|
@@ -22,7 +22,7 @@ httpcore==1.0.9
|
|
|
22
22
|
httpx==0.28.1
|
|
23
23
|
httpx-sse==0.4.3
|
|
24
24
|
id==1.6.1
|
|
25
|
-
idna==3.
|
|
25
|
+
idna==3.15
|
|
26
26
|
iniconfig==2.3.0
|
|
27
27
|
jaraco.classes==3.4.0
|
|
28
28
|
jaraco.context==6.1.2
|
|
@@ -35,7 +35,7 @@ markdown-it-py==4.0.0
|
|
|
35
35
|
mcp==1.27.0
|
|
36
36
|
mdurl==0.1.2
|
|
37
37
|
more-itertools==11.0.2
|
|
38
|
-
msgpack==1.1
|
|
38
|
+
msgpack==1.2.1
|
|
39
39
|
nh3==0.3.5
|
|
40
40
|
packageurl-python==0.17.6
|
|
41
41
|
packaging==26.2
|
|
@@ -47,17 +47,17 @@ pluggy==1.6.0
|
|
|
47
47
|
py-serializable==2.1.0
|
|
48
48
|
pycparser==3.0
|
|
49
49
|
pydantic==2.13.3
|
|
50
|
-
pydantic-settings==2.14.
|
|
50
|
+
pydantic-settings==2.14.2
|
|
51
51
|
pydantic_core==2.46.3
|
|
52
52
|
pyfiglet==1.0.4
|
|
53
53
|
Pygments==2.20.0
|
|
54
|
-
PyJWT==2.
|
|
54
|
+
PyJWT==2.13.0
|
|
55
55
|
pyparsing==3.3.2
|
|
56
56
|
pyproject_hooks==1.2.0
|
|
57
57
|
pytest==9.0.3
|
|
58
58
|
pytest-cov==7.1.0
|
|
59
59
|
python-dotenv==1.2.2
|
|
60
|
-
python-multipart==0.0.
|
|
60
|
+
python-multipart==0.0.30
|
|
61
61
|
pywin32==311
|
|
62
62
|
pywin32-ctypes==0.2.3
|
|
63
63
|
PyYAML==6.0.3
|
|
@@ -72,7 +72,7 @@ rpds-py==0.30.0
|
|
|
72
72
|
shellingham==1.5.4
|
|
73
73
|
sortedcontainers==2.4.0
|
|
74
74
|
sse-starlette==3.4.1
|
|
75
|
-
starlette==1.
|
|
75
|
+
starlette==1.3.1
|
|
76
76
|
stevedore==5.7.0
|
|
77
77
|
tomli==2.4.1
|
|
78
78
|
tomli_w==1.2.0
|
|
@@ -21,7 +21,9 @@ from sec_report_kit.parsers.semgrep import parse_semgrep_json
|
|
|
21
21
|
from sec_report_kit.parsers.tfsec import parse_tfsec_json
|
|
22
22
|
from sec_report_kit.parsers.trivy import parse_trivy_json
|
|
23
23
|
from sec_report_kit.parsers.trufflehog import parse_trufflehog_json
|
|
24
|
+
from sec_report_kit.parsers.cyclonedx import parse_cyclonedx_sbom
|
|
24
25
|
from sec_report_kit.report.html_renderer import render_consolidated_dashboard_report, render_html_report
|
|
26
|
+
from sec_report_kit.report.sbom_renderer import render_sbom_report
|
|
25
27
|
from sec_report_kit.services.summarize import count_by_severity, sort_findings
|
|
26
28
|
|
|
27
29
|
app = typer.Typer(help="Security report kit CLI")
|
|
@@ -358,6 +360,25 @@ def render_trufflehog(
|
|
|
358
360
|
_write_report(source, target, input, output, parser="trufflehog")
|
|
359
361
|
|
|
360
362
|
|
|
363
|
+
@render_app.command("sbom")
|
|
364
|
+
def render_sbom(
|
|
365
|
+
input: Path = typer.Option(..., "--input", exists=True, dir_okay=False, file_okay=True, readable=True),
|
|
366
|
+
output: Path = typer.Option(..., "--output", dir_okay=False, file_okay=True),
|
|
367
|
+
source: str = typer.Option("sbom", "--source", help="Source label to display in the report header"),
|
|
368
|
+
target: str = typer.Option("software-inventory", "--target", help="SBOM subject or artifact reference"),
|
|
369
|
+
) -> None:
|
|
370
|
+
"""Render an HTML component inventory report from a CycloneDX SBOM JSON."""
|
|
371
|
+
payload = _load_json(input)
|
|
372
|
+
document = parse_cyclonedx_sbom(payload)
|
|
373
|
+
report_html = render_sbom_report(source_label=source, target_ref=target, document=document)
|
|
374
|
+
output.parent.mkdir(parents=True, exist_ok=True)
|
|
375
|
+
output.write_text(report_html, encoding="utf-8")
|
|
376
|
+
|
|
377
|
+
typer.echo(f"[OK] Report generated: {output}")
|
|
378
|
+
typer.echo(f"[INFO] SBOM format: {document.bom_format} {document.spec_version}")
|
|
379
|
+
typer.echo(f"[INFO] Total components: {len(document.components)}")
|
|
380
|
+
|
|
381
|
+
|
|
361
382
|
@render_app.command("consolidated")
|
|
362
383
|
def render_consolidated(
|
|
363
384
|
input: Path = typer.Option(
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True)
|
|
7
|
+
class Finding:
|
|
8
|
+
source_type: str
|
|
9
|
+
target: str
|
|
10
|
+
severity: str
|
|
11
|
+
vulnerability_id: str
|
|
12
|
+
package: str
|
|
13
|
+
installed_version: str
|
|
14
|
+
fixed_version: str
|
|
15
|
+
title: str
|
|
16
|
+
primary_url: str
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True)
|
|
20
|
+
class Component:
|
|
21
|
+
"""A single software component from an SBOM inventory."""
|
|
22
|
+
|
|
23
|
+
name: str
|
|
24
|
+
version: str
|
|
25
|
+
type: str
|
|
26
|
+
group: str
|
|
27
|
+
ecosystem: str
|
|
28
|
+
language: str
|
|
29
|
+
license: str
|
|
30
|
+
purl: str
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
class SbomDocument:
|
|
35
|
+
"""Parsed SBOM document: metadata plus the component inventory."""
|
|
36
|
+
|
|
37
|
+
bom_format: str
|
|
38
|
+
spec_version: str
|
|
39
|
+
subject: str
|
|
40
|
+
timestamp: str
|
|
41
|
+
components: list[Component]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from urllib.parse import unquote
|
|
4
|
+
|
|
5
|
+
from sec_report_kit.models import Component, SbomDocument
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _ecosystem_from_purl(purl: str) -> str:
|
|
9
|
+
"""Extract the package ecosystem (npm, pypi, ...) from a Package URL."""
|
|
10
|
+
if not purl.startswith("pkg:"):
|
|
11
|
+
return "-"
|
|
12
|
+
remainder = purl[len("pkg:") :]
|
|
13
|
+
eco = remainder.split("/", 1)[0].split("@", 1)[0]
|
|
14
|
+
return eco or "-"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _property_value(component: dict, name: str) -> str:
|
|
18
|
+
props = component.get("properties")
|
|
19
|
+
if not isinstance(props, list):
|
|
20
|
+
return "-"
|
|
21
|
+
for prop in props:
|
|
22
|
+
if isinstance(prop, dict) and prop.get("name") == name:
|
|
23
|
+
return str(prop.get("value") or "-")
|
|
24
|
+
return "-"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _license_text(component: dict) -> str:
|
|
28
|
+
"""Collapse CycloneDX license entries into a single display string.
|
|
29
|
+
|
|
30
|
+
Handles the three common shapes: ``{"license": {"id": ...}}``,
|
|
31
|
+
``{"license": {"name": ...}}``, and ``{"expression": ...}``.
|
|
32
|
+
"""
|
|
33
|
+
licenses = component.get("licenses")
|
|
34
|
+
if not isinstance(licenses, list):
|
|
35
|
+
return "-"
|
|
36
|
+
|
|
37
|
+
parts: list[str] = []
|
|
38
|
+
for entry in licenses:
|
|
39
|
+
if not isinstance(entry, dict):
|
|
40
|
+
continue
|
|
41
|
+
if "expression" in entry:
|
|
42
|
+
value = str(entry.get("expression") or "").strip()
|
|
43
|
+
if value:
|
|
44
|
+
parts.append(value)
|
|
45
|
+
continue
|
|
46
|
+
lic = entry.get("license")
|
|
47
|
+
if isinstance(lic, dict):
|
|
48
|
+
value = str(lic.get("id") or lic.get("name") or "").strip()
|
|
49
|
+
if value:
|
|
50
|
+
parts.append(value)
|
|
51
|
+
|
|
52
|
+
# De-duplicate while preserving order.
|
|
53
|
+
seen: set[str] = set()
|
|
54
|
+
unique = [p for p in parts if not (p in seen or seen.add(p))]
|
|
55
|
+
return ", ".join(unique) if unique else "-"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def parse_cyclonedx_sbom(data: dict) -> SbomDocument:
|
|
59
|
+
"""Parse a CycloneDX JSON SBOM into an :class:`SbomDocument`."""
|
|
60
|
+
if not isinstance(data, dict):
|
|
61
|
+
raise ValueError("CycloneDX SBOM must be a JSON object")
|
|
62
|
+
|
|
63
|
+
metadata = data.get("metadata") if isinstance(data.get("metadata"), dict) else {}
|
|
64
|
+
meta_component = (
|
|
65
|
+
metadata.get("component") if isinstance(metadata.get("component"), dict) else {}
|
|
66
|
+
)
|
|
67
|
+
subject = str(meta_component.get("name") or "sbom")
|
|
68
|
+
timestamp = str(metadata.get("timestamp") or "")
|
|
69
|
+
|
|
70
|
+
components: list[Component] = []
|
|
71
|
+
for raw in data.get("components", []) if isinstance(data.get("components"), list) else []:
|
|
72
|
+
if not isinstance(raw, dict):
|
|
73
|
+
continue
|
|
74
|
+
purl = str(raw.get("purl") or "")
|
|
75
|
+
components.append(
|
|
76
|
+
Component(
|
|
77
|
+
name=str(raw.get("name") or "-"),
|
|
78
|
+
version=str(raw.get("version") or "-"),
|
|
79
|
+
type=str(raw.get("type") or "-"),
|
|
80
|
+
group=str(raw.get("group") or "-"),
|
|
81
|
+
ecosystem=_ecosystem_from_purl(purl),
|
|
82
|
+
language=_property_value(raw, "syft:package:language"),
|
|
83
|
+
license=_license_text(raw),
|
|
84
|
+
purl=unquote(purl) if purl else "-",
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
return SbomDocument(
|
|
89
|
+
bom_format=str(data.get("bomFormat") or "CycloneDX"),
|
|
90
|
+
spec_version=str(data.get("specVersion") or "-"),
|
|
91
|
+
subject=subject,
|
|
92
|
+
timestamp=timestamp,
|
|
93
|
+
components=components,
|
|
94
|
+
)
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import html
|
|
5
|
+
from collections import Counter
|
|
6
|
+
|
|
7
|
+
from sec_report_kit.models import SbomDocument
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _esc(value: str) -> str:
|
|
11
|
+
return html.escape(value, quote=True)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def render_sbom_report(source_label: str, target_ref: str, document: SbomDocument) -> str:
|
|
15
|
+
"""Render an HTML inventory report from a parsed SBOM document."""
|
|
16
|
+
generated_at = dt.datetime.now(dt.timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
|
|
17
|
+
components = document.components
|
|
18
|
+
total = len(components)
|
|
19
|
+
|
|
20
|
+
type_counts = Counter(c.type for c in components)
|
|
21
|
+
ecosystem_counts = Counter(c.ecosystem for c in components)
|
|
22
|
+
licenses = Counter(c.license for c in components if c.license and c.license != "-")
|
|
23
|
+
no_license = sum(1 for c in components if not c.license or c.license == "-")
|
|
24
|
+
distinct_licenses = len(licenses)
|
|
25
|
+
|
|
26
|
+
rows = []
|
|
27
|
+
for item in sorted(components, key=lambda c: (c.type, c.name.lower(), c.version)):
|
|
28
|
+
rows.append(
|
|
29
|
+
"<tr>"
|
|
30
|
+
f"<td>{_esc(item.name)}</td>"
|
|
31
|
+
f"<td>{_esc(item.version)}</td>"
|
|
32
|
+
f"<td>{_esc(item.type)}</td>"
|
|
33
|
+
f"<td>{_esc(item.ecosystem)}</td>"
|
|
34
|
+
f"<td>{_esc(item.language)}</td>"
|
|
35
|
+
f"<td>{_esc(item.license)}</td>"
|
|
36
|
+
f"<td class=\"purl\">{_esc(item.purl)}</td>"
|
|
37
|
+
"</tr>"
|
|
38
|
+
)
|
|
39
|
+
rows_html = "\n".join(rows) if rows else "<tr><td colspan=\"7\">No components found.</td></tr>"
|
|
40
|
+
|
|
41
|
+
def _breakdown(counter: Counter, limit: int | None = None) -> str:
|
|
42
|
+
items = counter.most_common(limit)
|
|
43
|
+
if not items:
|
|
44
|
+
return "<span class=\"muted\">None</span>"
|
|
45
|
+
return "".join(
|
|
46
|
+
f"<span class=\"chip\">{_esc(str(label))}<strong>{count}</strong></span>"
|
|
47
|
+
for label, count in items
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
type_chips = _breakdown(type_counts)
|
|
51
|
+
ecosystem_chips = _breakdown(ecosystem_counts)
|
|
52
|
+
license_chips = _breakdown(licenses, limit=15)
|
|
53
|
+
|
|
54
|
+
return f"""<!doctype html>
|
|
55
|
+
<html lang=\"en\">
|
|
56
|
+
<head>
|
|
57
|
+
<meta charset=\"utf-8\" />
|
|
58
|
+
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />
|
|
59
|
+
<title>SBOM Component Report</title>
|
|
60
|
+
<style>
|
|
61
|
+
body {{ font-family: Segoe UI, Arial, sans-serif; margin: 24px; color: #1f2937; }}
|
|
62
|
+
h1 {{ margin: 0 0 8px 0; }}
|
|
63
|
+
h2 {{ font-size: 16px; margin: 22px 0 8px; }}
|
|
64
|
+
.meta {{ margin-bottom: 18px; color: #4b5563; }}
|
|
65
|
+
.cards {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }}
|
|
66
|
+
.card {{ border: 1px solid #d1d5db; border-radius: 8px; padding: 10px 12px; background: #f9fafb; }}
|
|
67
|
+
.label {{ font-size: 12px; color: #6b7280; text-transform: uppercase; }}
|
|
68
|
+
.value {{ font-size: 24px; font-weight: 700; margin-top: 4px; }}
|
|
69
|
+
.breakdown {{ display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }}
|
|
70
|
+
.chip {{
|
|
71
|
+
display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
|
|
72
|
+
padding: 4px 10px; border: 1px solid #d1d5db; border-radius: 999px; background: #fff;
|
|
73
|
+
}}
|
|
74
|
+
.chip strong {{ color: #1d4ed8; }}
|
|
75
|
+
.muted {{ color: #6b7280; font-size: 13px; }}
|
|
76
|
+
.filters {{ display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; align-items: flex-end; }}
|
|
77
|
+
.filters label {{ font-size: 13px; color: #374151; display: flex; flex-direction: column; gap: 3px; }}
|
|
78
|
+
.filters select, .filters input[type=text] {{
|
|
79
|
+
font-size: 13px; padding: 5px 8px; border: 1px solid #d1d5db;
|
|
80
|
+
border-radius: 6px; background: #fff; color: #1f2937; min-width: 150px;
|
|
81
|
+
}}
|
|
82
|
+
.filters button {{
|
|
83
|
+
font-size: 13px; padding: 6px 14px; border: 1px solid #d1d5db;
|
|
84
|
+
border-radius: 6px; background: #f3f4f6; cursor: pointer; color: #374151;
|
|
85
|
+
}}
|
|
86
|
+
.filters button:hover {{ background: #e5e7eb; }}
|
|
87
|
+
#result-count {{ font-size: 13px; color: #6b7280; margin-left: auto; }}
|
|
88
|
+
table {{ width: 100%; border-collapse: collapse; font-size: 13px; }}
|
|
89
|
+
thead th {{ text-align: left; border-bottom: 2px solid #d1d5db; padding: 8px; background: #f3f4f6; position: sticky; top: 0; }}
|
|
90
|
+
tbody td {{ border-bottom: 1px solid #e5e7eb; padding: 8px; vertical-align: top; }}
|
|
91
|
+
tbody tr.hidden {{ display: none; }}
|
|
92
|
+
td.purl {{ font-family: Consolas, monospace; font-size: 12px; color: #4b5563; word-break: break-all; }}
|
|
93
|
+
.report-footer {{
|
|
94
|
+
margin-top: 36px; padding-top: 14px; border-top: 1px solid #e5e7eb;
|
|
95
|
+
text-align: center; font-size: 12px; color: #6b7280;
|
|
96
|
+
}}
|
|
97
|
+
</style>
|
|
98
|
+
</head>
|
|
99
|
+
<body>
|
|
100
|
+
<h1>SBOM Component Inventory</h1>
|
|
101
|
+
<div class=\"meta\">Source: <strong>{_esc(source_label)}</strong> | Target: <strong>{_esc(target_ref)}</strong> | Format: {_esc(document.bom_format)} {_esc(document.spec_version)} | Generated: {_esc(generated_at)}</div>
|
|
102
|
+
|
|
103
|
+
<div class=\"cards\">
|
|
104
|
+
<div class=\"card\"><div class=\"label\">Components</div><div class=\"value\">{total}</div></div>
|
|
105
|
+
<div class=\"card\"><div class=\"label\">Libraries</div><div class=\"value\">{type_counts.get('library', 0)}</div></div>
|
|
106
|
+
<div class=\"card\"><div class=\"label\">Applications</div><div class=\"value\">{type_counts.get('application', 0)}</div></div>
|
|
107
|
+
<div class=\"card\"><div class=\"label\">Distinct Licenses</div><div class=\"value\">{distinct_licenses}</div></div>
|
|
108
|
+
<div class=\"card\"><div class=\"label\">No License</div><div class=\"value\">{no_license}</div></div>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<h2>Component Types</h2>
|
|
112
|
+
<div class=\"breakdown\">{type_chips}</div>
|
|
113
|
+
|
|
114
|
+
<h2>Ecosystems</h2>
|
|
115
|
+
<div class=\"breakdown\">{ecosystem_chips}</div>
|
|
116
|
+
|
|
117
|
+
<h2>Top Licenses</h2>
|
|
118
|
+
<div class=\"breakdown\">{license_chips}</div>
|
|
119
|
+
|
|
120
|
+
<h2>Components</h2>
|
|
121
|
+
<div class=\"filters\">
|
|
122
|
+
<label>Name
|
|
123
|
+
<input type=\"text\" id=\"f-name\" placeholder=\"e.g. babel\" />
|
|
124
|
+
</label>
|
|
125
|
+
<label>Type
|
|
126
|
+
<input type=\"text\" id=\"f-type\" placeholder=\"e.g. library\" />
|
|
127
|
+
</label>
|
|
128
|
+
<label>Ecosystem
|
|
129
|
+
<input type=\"text\" id=\"f-eco\" placeholder=\"e.g. npm\" />
|
|
130
|
+
</label>
|
|
131
|
+
<label>Language
|
|
132
|
+
<input type=\"text\" id=\"f-lang\" placeholder=\"e.g. python\" />
|
|
133
|
+
</label>
|
|
134
|
+
<label>License
|
|
135
|
+
<input type=\"text\" id=\"f-license\" placeholder=\"e.g. MIT\" />
|
|
136
|
+
</label>
|
|
137
|
+
<button onclick=\"clearFilters()\">Clear</button>
|
|
138
|
+
<span id=\"result-count\"></span>
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<table id=\"sbom-table\">
|
|
142
|
+
<thead>
|
|
143
|
+
<tr>
|
|
144
|
+
<th>Name</th>
|
|
145
|
+
<th>Version</th>
|
|
146
|
+
<th>Type</th>
|
|
147
|
+
<th>Ecosystem</th>
|
|
148
|
+
<th>Language</th>
|
|
149
|
+
<th>License</th>
|
|
150
|
+
<th>Package URL</th>
|
|
151
|
+
</tr>
|
|
152
|
+
</thead>
|
|
153
|
+
<tbody id=\"sbom-body\">
|
|
154
|
+
{rows_html}
|
|
155
|
+
</tbody>
|
|
156
|
+
</table>
|
|
157
|
+
|
|
158
|
+
<script>
|
|
159
|
+
const filterIds = ['f-name', 'f-type', 'f-eco', 'f-lang', 'f-license'];
|
|
160
|
+
// col indices: name=0, version=1, type=2, ecosystem=3, language=4, license=5, purl=6
|
|
161
|
+
const colMap = {{ 'f-name': 0, 'f-type': 2, 'f-eco': 3, 'f-lang': 4, 'f-license': 5 }};
|
|
162
|
+
|
|
163
|
+
function applyFilters() {{
|
|
164
|
+
const filters = {{}};
|
|
165
|
+
filterIds.forEach(id => {{
|
|
166
|
+
filters[id] = document.getElementById(id).value.trim().toLowerCase();
|
|
167
|
+
}});
|
|
168
|
+
|
|
169
|
+
const rows = document.querySelectorAll('#sbom-body tr');
|
|
170
|
+
let visible = 0;
|
|
171
|
+
rows.forEach(row => {{
|
|
172
|
+
const cells = row.querySelectorAll('td');
|
|
173
|
+
if (!cells.length) return;
|
|
174
|
+
let show = true;
|
|
175
|
+
for (const [id, col] of Object.entries(colMap)) {{
|
|
176
|
+
const val = filters[id];
|
|
177
|
+
if (!val) continue;
|
|
178
|
+
const cellText = (cells[col]?.textContent || '').trim().toLowerCase();
|
|
179
|
+
if (!cellText.includes(val)) {{ show = false; break; }}
|
|
180
|
+
}}
|
|
181
|
+
row.classList.toggle('hidden', !show);
|
|
182
|
+
if (show) visible++;
|
|
183
|
+
}});
|
|
184
|
+
|
|
185
|
+
const total = rows.length;
|
|
186
|
+
document.getElementById('result-count').textContent =
|
|
187
|
+
visible === total ? `${{total}} components` : `${{visible}} of ${{total}} components`;
|
|
188
|
+
}}
|
|
189
|
+
|
|
190
|
+
function clearFilters() {{
|
|
191
|
+
filterIds.forEach(id => {{ document.getElementById(id).value = ''; }});
|
|
192
|
+
applyFilters();
|
|
193
|
+
}}
|
|
194
|
+
|
|
195
|
+
filterIds.forEach(id => {{
|
|
196
|
+
const el = document.getElementById(id);
|
|
197
|
+
el.addEventListener('input', applyFilters);
|
|
198
|
+
el.addEventListener('change', applyFilters);
|
|
199
|
+
}});
|
|
200
|
+
|
|
201
|
+
applyFilters();
|
|
202
|
+
</script>
|
|
203
|
+
|
|
204
|
+
<footer class=\"report-footer\">
|
|
205
|
+
This report is generated by <a href=\"https://github.com/ShanKonduru/sec-report-kit\" target=\"_blank\" rel=\"noopener noreferrer\">sec-report-kit utility</a> | Connect with the developer: <a href=\"https://www.linkedin.com/in/shankonduru/\" target=\"_blank\" rel=\"noopener noreferrer\">Shan Konduru</a>
|
|
206
|
+
</footer>
|
|
207
|
+
</body>
|
|
208
|
+
</html>
|
|
209
|
+
"""
|
|
@@ -331,6 +331,17 @@ def test_main_calls_app(monkeypatch):
|
|
|
331
331
|
assert exc.value.code == 0
|
|
332
332
|
|
|
333
333
|
|
|
334
|
+
def test_main_prints_banner_for_regular_command(monkeypatch, capsys):
|
|
335
|
+
monkeypatch.setattr("sys.argv", ["srk", "render"])
|
|
336
|
+
from sec_report_kit.cli import main
|
|
337
|
+
|
|
338
|
+
with patch("sec_report_kit.cli.app") as mock_app:
|
|
339
|
+
main()
|
|
340
|
+
|
|
341
|
+
mock_app.assert_called_once()
|
|
342
|
+
assert "____ _____" in capsys.readouterr().out
|
|
343
|
+
|
|
344
|
+
|
|
334
345
|
def test_main_help_does_not_print_banner(monkeypatch, capsys):
|
|
335
346
|
import pytest
|
|
336
347
|
|
|
@@ -477,6 +488,48 @@ def test_render_osv_scanner_command(tmp_path):
|
|
|
477
488
|
assert "requests" in output_file.read_text()
|
|
478
489
|
|
|
479
490
|
|
|
491
|
+
def test_render_sbom_command(tmp_path):
|
|
492
|
+
payload = {
|
|
493
|
+
"bomFormat": "CycloneDX",
|
|
494
|
+
"specVersion": "1.6",
|
|
495
|
+
"metadata": {"component": {"type": "file", "name": "my-project"}},
|
|
496
|
+
"components": [
|
|
497
|
+
{
|
|
498
|
+
"type": "library",
|
|
499
|
+
"name": "requests",
|
|
500
|
+
"version": "2.33.1",
|
|
501
|
+
"purl": "pkg:pypi/requests@2.33.1",
|
|
502
|
+
"licenses": [{"license": {"id": "Apache-2.0"}}],
|
|
503
|
+
}
|
|
504
|
+
],
|
|
505
|
+
}
|
|
506
|
+
input_file = tmp_path / "bom.cdx.json"
|
|
507
|
+
input_file.write_text(json.dumps(payload))
|
|
508
|
+
output_file = tmp_path / "sbom.html"
|
|
509
|
+
|
|
510
|
+
result = runner.invoke(
|
|
511
|
+
app,
|
|
512
|
+
[
|
|
513
|
+
"render",
|
|
514
|
+
"sbom",
|
|
515
|
+
"--input",
|
|
516
|
+
str(input_file),
|
|
517
|
+
"--output",
|
|
518
|
+
str(output_file),
|
|
519
|
+
"--source",
|
|
520
|
+
"cyclonedx",
|
|
521
|
+
"--target",
|
|
522
|
+
"my-project",
|
|
523
|
+
],
|
|
524
|
+
)
|
|
525
|
+
assert result.exit_code == 0
|
|
526
|
+
assert output_file.exists()
|
|
527
|
+
html = output_file.read_text()
|
|
528
|
+
assert "SBOM Component Inventory" in html
|
|
529
|
+
assert "requests" in html
|
|
530
|
+
assert "Total components: 1" in result.stdout
|
|
531
|
+
|
|
532
|
+
|
|
480
533
|
def test_render_checkov_command(tmp_path):
|
|
481
534
|
input_file = tmp_path / "checkov.json"
|
|
482
535
|
input_file.write_text(json.dumps(CHECKOV_PAYLOAD))
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from sec_report_kit.models import SbomDocument
|
|
6
|
+
from sec_report_kit.parsers.cyclonedx import (
|
|
7
|
+
_ecosystem_from_purl,
|
|
8
|
+
parse_cyclonedx_sbom,
|
|
9
|
+
)
|
|
10
|
+
from sec_report_kit.report.sbom_renderer import render_sbom_report
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
SBOM_PAYLOAD = {
|
|
14
|
+
"bomFormat": "CycloneDX",
|
|
15
|
+
"specVersion": "1.6",
|
|
16
|
+
"metadata": {
|
|
17
|
+
"timestamp": "2026-07-12T10:00:00Z",
|
|
18
|
+
"component": {"type": "file", "name": "my-project"},
|
|
19
|
+
},
|
|
20
|
+
"components": [
|
|
21
|
+
{
|
|
22
|
+
"type": "library",
|
|
23
|
+
"name": "@babel/runtime",
|
|
24
|
+
"version": "7.29.7",
|
|
25
|
+
"purl": "pkg:npm/%40babel/runtime@7.29.7",
|
|
26
|
+
"licenses": [{"license": {"id": "MIT"}}],
|
|
27
|
+
"properties": [
|
|
28
|
+
{"name": "syft:package:language", "value": "javascript"},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "library",
|
|
33
|
+
"name": "requests",
|
|
34
|
+
"version": "2.33.1",
|
|
35
|
+
"purl": "pkg:pypi/requests@2.33.1",
|
|
36
|
+
"licenses": [{"license": {"name": "Apache Software License"}}],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "application",
|
|
40
|
+
"name": "my-app",
|
|
41
|
+
"version": "1.0.0",
|
|
42
|
+
"licenses": [{"expression": "Apache-2.0 OR MIT"}],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
# No license, no purl, no properties -> all fallbacks.
|
|
46
|
+
"type": "library",
|
|
47
|
+
"name": "mystery-lib",
|
|
48
|
+
"version": "0.1.0",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_parse_cyclonedx_basic_metadata_and_count():
|
|
55
|
+
doc = parse_cyclonedx_sbom(SBOM_PAYLOAD)
|
|
56
|
+
assert isinstance(doc, SbomDocument)
|
|
57
|
+
assert doc.bom_format == "CycloneDX"
|
|
58
|
+
assert doc.spec_version == "1.6"
|
|
59
|
+
assert doc.subject == "my-project"
|
|
60
|
+
assert doc.timestamp == "2026-07-12T10:00:00Z"
|
|
61
|
+
assert len(doc.components) == 4
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_parse_cyclonedx_license_shapes():
|
|
65
|
+
comps = {c.name: c for c in parse_cyclonedx_sbom(SBOM_PAYLOAD).components}
|
|
66
|
+
assert comps["@babel/runtime"].license == "MIT"
|
|
67
|
+
assert comps["requests"].license == "Apache Software License"
|
|
68
|
+
assert comps["my-app"].license == "Apache-2.0 OR MIT"
|
|
69
|
+
assert comps["mystery-lib"].license == "-"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_parse_cyclonedx_ecosystem_language_and_purl_decoding():
|
|
73
|
+
comps = {c.name: c for c in parse_cyclonedx_sbom(SBOM_PAYLOAD).components}
|
|
74
|
+
babel = comps["@babel/runtime"]
|
|
75
|
+
assert babel.ecosystem == "npm"
|
|
76
|
+
assert babel.language == "javascript"
|
|
77
|
+
# purl is percent-decoded for display.
|
|
78
|
+
assert babel.purl == "pkg:npm/@babel/runtime@7.29.7"
|
|
79
|
+
# No purl / no language properties fall back to "-".
|
|
80
|
+
assert comps["my-app"].ecosystem == "-"
|
|
81
|
+
assert comps["mystery-lib"].language == "-"
|
|
82
|
+
assert comps["mystery-lib"].purl == "-"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_parse_cyclonedx_deduplicates_and_ignores_bad_entries():
|
|
86
|
+
payload = {
|
|
87
|
+
"components": [
|
|
88
|
+
{
|
|
89
|
+
"type": "library",
|
|
90
|
+
"name": "dup-licensed",
|
|
91
|
+
"version": "1.0",
|
|
92
|
+
"licenses": [
|
|
93
|
+
{"license": {"id": "MIT"}},
|
|
94
|
+
{"license": {"name": "MIT"}},
|
|
95
|
+
"not-a-dict",
|
|
96
|
+
{"license": {}},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
"not-a-dict-component",
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
doc = parse_cyclonedx_sbom(payload)
|
|
103
|
+
assert len(doc.components) == 1
|
|
104
|
+
assert doc.components[0].license == "MIT"
|
|
105
|
+
# Missing bomFormat/specVersion/metadata fall back to defaults.
|
|
106
|
+
assert doc.bom_format == "CycloneDX"
|
|
107
|
+
assert doc.spec_version == "-"
|
|
108
|
+
assert doc.subject == "sbom"
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_parse_cyclonedx_rejects_non_dict():
|
|
112
|
+
with pytest.raises(ValueError):
|
|
113
|
+
parse_cyclonedx_sbom([1, 2, 3])
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_ecosystem_from_purl_non_purl_returns_dash():
|
|
117
|
+
assert _ecosystem_from_purl("") == "-"
|
|
118
|
+
assert _ecosystem_from_purl("not-a-purl") == "-"
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_parse_cyclonedx_properties_present_but_no_language():
|
|
122
|
+
payload = {
|
|
123
|
+
"components": [
|
|
124
|
+
{
|
|
125
|
+
"type": "library",
|
|
126
|
+
"name": "no-lang",
|
|
127
|
+
"version": "1.0",
|
|
128
|
+
"properties": [{"name": "syft:package:type", "value": "npm"}],
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
comp = parse_cyclonedx_sbom(payload).components[0]
|
|
133
|
+
assert comp.language == "-"
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_render_sbom_report_contents():
|
|
137
|
+
doc = parse_cyclonedx_sbom(SBOM_PAYLOAD)
|
|
138
|
+
html = render_sbom_report(source_label="cyclonedx", target_ref="my-project", document=doc)
|
|
139
|
+
assert "SBOM Component Inventory" in html
|
|
140
|
+
assert "Source: <strong>cyclonedx</strong>" in html
|
|
141
|
+
assert "Target: <strong>my-project</strong>" in html
|
|
142
|
+
assert "CycloneDX 1.6" in html
|
|
143
|
+
# Component appears in the table.
|
|
144
|
+
assert "requests" in html
|
|
145
|
+
assert "pkg:npm/@babel/runtime@7.29.7" in html
|
|
146
|
+
# Summary cards reflect 4 components (3 libraries, 1 application).
|
|
147
|
+
assert ">4</div>" in html
|
|
148
|
+
assert "This report is generated by" in html
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def test_render_sbom_report_empty_components():
|
|
152
|
+
doc = parse_cyclonedx_sbom({"components": []})
|
|
153
|
+
html = render_sbom_report(source_label="sbom", target_ref="empty", document=doc)
|
|
154
|
+
assert "No components found." in html
|
|
155
|
+
assert "None" in html # empty breakdown fallback
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@dataclass(frozen=True)
|
|
7
|
-
class Finding:
|
|
8
|
-
source_type: str
|
|
9
|
-
target: str
|
|
10
|
-
severity: str
|
|
11
|
-
vulnerability_id: str
|
|
12
|
-
package: str
|
|
13
|
-
installed_version: str
|
|
14
|
-
fixed_version: str
|
|
15
|
-
title: str
|
|
16
|
-
primary_url: str
|
|
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
|
|
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
|
|
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
|