-
Notifications
You must be signed in to change notification settings - Fork 621
feat: use default product/vendor/version for vex triage files #5649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||||||||||||||||||||||||||
| CVE-bin-tool CLI tests | ||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||
| import importlib | ||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||||||||
|
|
@@ -109,6 +110,40 @@ def test_usage(self): | |||||||||||||||||||||||||||||
| main(["cve-bin-tool"]) | ||||||||||||||||||||||||||||||
| assert e.value.args[0] == ERROR_CODES[InsufficientArgs] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def test_vex_output_without_product_vendor_release(self, caplog, tmp_path): | ||||||||||||||||||||||||||||||
| """Test that VEX generation works without --product, --vendor, --release. | ||||||||||||||||||||||||||||||
| Defaults (product='unknown', vendor='unknown', release='0.0') should be used | ||||||||||||||||||||||||||||||
| and a warning should be logged instead of erroring out.""" | ||||||||||||||||||||||||||||||
| vex_out = str(tmp_path / "default_product.vex.json") | ||||||||||||||||||||||||||||||
| CSV_PATH = str(Path(__file__).parent.resolve() / "csv" / "test_triage.csv") | ||||||||||||||||||||||||||||||
| with caplog.at_level(logging.WARNING): | ||||||||||||||||||||||||||||||
| result = main( | ||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||
| "cve-bin-tool", | ||||||||||||||||||||||||||||||
| "--offline", | ||||||||||||||||||||||||||||||
| "--input-file", | ||||||||||||||||||||||||||||||
| CSV_PATH, | ||||||||||||||||||||||||||||||
| "--vex-type", | ||||||||||||||||||||||||||||||
| "cyclonedx", | ||||||||||||||||||||||||||||||
| "--vex-output", | ||||||||||||||||||||||||||||||
| vex_out, | ||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| # Should not fail with InsufficientArgs — defaults must be used | ||||||||||||||||||||||||||||||
| assert result != ERROR_CODES[InsufficientArgs] | ||||||||||||||||||||||||||||||
| # A warning should be logged about using defaults | ||||||||||||||||||||||||||||||
| assert any( | ||||||||||||||||||||||||||||||
| "Using defaults" in record.message for record in caplog.records | ||||||||||||||||||||||||||||||
| ), "Expected warning about default product/vendor/release not found in logs" | ||||||||||||||||||||||||||||||
| # The VEX file should have been created with default values | ||||||||||||||||||||||||||||||
| if Path(vex_out).exists(): | ||||||||||||||||||||||||||||||
| with open(vex_out) as f: | ||||||||||||||||||||||||||||||
| vex_data = json.load(f) | ||||||||||||||||||||||||||||||
| component = vex_data.get("metadata", {}).get("component", {}) | ||||||||||||||||||||||||||||||
| assert component.get("name") == "unknown" | ||||||||||||||||||||||||||||||
| assert component.get("version") == "0.0" | ||||||||||||||||||||||||||||||
| assert component.get("supplier", {}).get("name") == "unknown" | ||||||||||||||||||||||||||||||
|
Comment on lines
+139
to
+145
|
||||||||||||||||||||||||||||||
| if Path(vex_out).exists(): | |
| with open(vex_out) as f: | |
| vex_data = json.load(f) | |
| component = vex_data.get("metadata", {}).get("component", {}) | |
| assert component.get("name") == "unknown" | |
| assert component.get("version") == "0.0" | |
| assert component.get("supplier", {}).get("name") == "unknown" | |
| assert Path(vex_out).exists(), "Expected VEX output file to be created" | |
| with open(vex_out) as f: | |
| vex_data = json.load(f) | |
| component = vex_data.get("metadata", {}).get("component", {}) | |
| assert component.get("name") == "unknown" | |
| assert component.get("version") == "0.0" | |
| assert component.get("supplier", {}).get("name") == "unknown" |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -123,6 +123,28 @@ def test_output_cyclonedx(self): | |||||||||
|
|
||||||||||
| Path("generated_cyclonedx_vex.json").unlink() | ||||||||||
|
|
||||||||||
| def test_output_cyclonedx_default_product_info(self): | ||||||||||
| """Test VEX output generation uses default product/vendor/release when not specified""" | ||||||||||
|
Comment on lines
+126
to
+127
|
||||||||||
| def test_output_cyclonedx_default_product_info(self): | |
| """Test VEX output generation uses default product/vendor/release when not specified""" | |
| def test_output_cyclonedx_with_provided_product_info(self): | |
| """Test VEX output generation uses the provided product/vendor/release values""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning text is misleading: this branch runs when any of --product/--release/--vendor is missing, but the message says none were provided. Consider rewording to indicate which fields are missing (or say "Missing --product/--release/--vendor; using defaults...") to avoid confusing users who supplied one or two of the flags.