-
Notifications
You must be signed in to change notification settings - Fork 32
Ingest CVSS 4.0 metrics #857
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
Draft
DarshanCode2005
wants to merge
9
commits into
NixOS:main
Choose a base branch
from
DarshanCode2005:cvss-4-metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a9f9d41
feat(shared): add CVSS version fallback in metric ingestion
DarshanCode2005 75796c9
fix(webview): handle non-CVSS3 vectors in severity badge
DarshanCode2005 7ec51b0
test(cvss): cover fallback ingestion and severity badge parsing
DarshanCode2005 33e592c
feat(viewutils): simplify the parser format extraction and check
DarshanCode2005 1137d16
refactor(fetchers): simpliffy make_metric()
DarshanCode2005 47bb940
feat(viewutils): support CVSS v4 vectors in severity_badge
DarshanCode2005 b1b89a8
refactor(tests): unify CVSS vector tests and add fixtures
DarshanCode2005 4775010
fix: remove float baseScore, present in Schema
DarshanCode2005 f360489
refactor(viewutils): implement dictionary based lookup
DarshanCode2005 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| from shared.fetchers import make_metric | ||
|
|
||
|
|
||
| def test_make_metric_uses_cvss_v4_0_when_v3_1_is_missing(db: None) -> None: | ||
| metric = make_metric( | ||
| { | ||
| "cvssV4_0": { | ||
| "version": "4.0", | ||
| "vectorString": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N", | ||
| "baseScore": 9.3, | ||
| "baseSeverity": "CRITICAL", | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| assert metric.format == "cvssV4_0" | ||
| assert metric.raw_cvss_json["version"] == "4.0" | ||
| assert metric.vector_string == "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N" | ||
| assert metric.base_score == 9.3 | ||
| assert metric.base_severity == "CRITICAL" | ||
|
|
||
|
|
||
| def test_make_metric_uses_cvss_v3_0_when_v3_1_is_missing(db: None) -> None: | ||
| metric = make_metric( | ||
| { | ||
| "cvssV3_0": { | ||
| "version": "3.0", | ||
| "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", | ||
| "baseScore": "9.8", | ||
| "baseSeverity": "CRITICAL", | ||
| "attackVector": "NETWORK", | ||
| "attackComplexity": "LOW", | ||
| "privilegesRequired": "NONE", | ||
| "userInteraction": "NONE", | ||
| "scope": "UNCHANGED", | ||
| "confidentialityImpact": "HIGH", | ||
| "integrityImpact": "HIGH", | ||
| "availabilityImpact": "HIGH", | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| assert metric.format == "cvssV3_0" | ||
| assert metric.base_score == 9.8 | ||
| assert metric.base_severity == "CRITICAL" | ||
| assert metric.attack_vector == "NETWORK" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from webview.templatetags.viewutils import severity_badge | ||
|
|
||
|
|
||
| import pytest | ||
| from webview.templatetags.viewutils import severity_badge | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "metric_input, expected_version, expected_score", | ||
| [ | ||
| ("cvss_v3_metric", "3.1", 9.8), | ||
| ("cvss_v4_metric", "4.0", 9.3), | ||
| ], | ||
| ) | ||
| def test_severity_badge_handles_cvss_versions( | ||
| request, metric_input, expected_version, expected_score | ||
| ): | ||
| metric = severity_badge([request.getfixturevalue(metric_input)]) | ||
|
|
||
| assert metric["version"] == expected_version | ||
| assert metric["baseScore"] == expected_score | ||
| assert metric["baseSeverity"] == "CRITICAL" | ||
| assert metric["vectorString"].startswith("CVSS:") | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.