-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore access to exclude to bom-diff, options bugfix. (#16)
Signed-off-by: Caroline Russell <[email protected]>
- Loading branch information
1 parent
3f21e02
commit 64f1386
Showing
6 changed files
with
3,752 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[project] | ||
name = "custom-json-diff" | ||
version = "1.0.0" | ||
version = "1.1.0" | ||
description = "Custom JSON and CycloneDx BOM diffing and comparison tool." | ||
authors = [ | ||
{ name = "Caroline Russell", email = "[email protected]" }, | ||
|
This file contains 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 |
---|---|---|
|
@@ -6,30 +6,6 @@ | |
from custom_json_diff.custom_diff_classes import BomComponent, BomDicts, Options | ||
|
||
|
||
@pytest.fixture | ||
def java_1_bom(): | ||
options = Options(file_1="test/sbom-java.json", file_2="test/sbom-java2.json", bom_diff=True, include=["hashes", "evidence", "licenses", "properties"]) | ||
return load_json("test/sbom-java.json", options) | ||
|
||
|
||
@pytest.fixture | ||
def java_2_bom(): | ||
options = Options(file_1="test/sbom-java.json", file_2="test/sbom-java2.json", bom_diff=True, include=["hashes", "evidence", "licenses", "properties"]) | ||
return load_json("test/sbom-java2.json", options) | ||
|
||
|
||
@pytest.fixture | ||
def python_1_bom(): | ||
options = Options(file_1="test/sbom-python.json", file_2="test/sbom-python2.json", bom_diff=True, include=["licenses", "hashes", "evidence", "properties"]) | ||
return load_json("test/sbom-python.json", options) | ||
|
||
|
||
@pytest.fixture | ||
def python_2_bom(): | ||
options = Options(file_1="test/sbom-python.json", file_2="test/sbom-python2.json", bom_diff=True, include=["licenses", "hashes", "evidence", "properties"]) | ||
return load_json("test/sbom-python2.json", options) | ||
|
||
|
||
@pytest.fixture | ||
def options_1(): | ||
return Options(file_1="test/sbom-java.json", file_2="test/sbom-java2.json", bom_diff=True, include=["hashes", "evidence", "licenses"]) | ||
|
@@ -44,6 +20,7 @@ def options_2(): | |
def options_3(): | ||
return Options(file_1="bom_1.json", file_2="bom_2.json", bom_diff=True, allow_new_data=True) | ||
|
||
|
||
@pytest.fixture | ||
def bom_dicts_1(): | ||
options = Options(file_1="bom_1.json", file_2="bom_2.json", | ||
|
@@ -185,22 +162,93 @@ def bom_dicts_6(): | |
return bom_dicts | ||
|
||
|
||
@pytest.fixture | ||
def bom_dicts_7(): | ||
options = Options(file_1="bom_1.json", file_2="bom_2.json", | ||
bom_diff=True, allow_new_data=True, allow_new_versions=True) | ||
bom_dicts = BomDicts(options, "bom_1.json", {}, {}) | ||
bom_dicts.components = [ | ||
BomComponent({ | ||
"bom-ref": "pkg:pypi/[email protected]", | ||
"evidence": { | ||
"identity": { | ||
"confidence": 0.8, | ||
"field": "purl", | ||
"methods": [ | ||
{ | ||
"confidence": 0.8, | ||
"technique": "manifest-analysis", | ||
"value": "/home/runner/work/src_repos/python/django-goat/requirements_tests.txt" | ||
} | ||
] | ||
} | ||
}, | ||
"group": "", | ||
"name": "requests", | ||
"properties": [ | ||
{ | ||
"name": "SrcFile", | ||
"value": "/home/runner/work/src_repos/python/django-goat/requirements_tests.txt" | ||
} | ||
], | ||
"purl": "pkg:pypi/[email protected]", | ||
"type": "library", | ||
"version": "2.31.0" | ||
}, options), | ||
] | ||
return bom_dicts | ||
|
||
|
||
@pytest.fixture | ||
def bom_dicts_8(): | ||
options = Options(file_1="bom_1.json", file_2="bom_2.json", | ||
bom_diff=True, allow_new_data=True, allow_new_versions=True) | ||
bom_dicts = BomDicts(options, "bom_2.json", {}, {}) | ||
bom_dicts.components = [ | ||
BomComponent({ | ||
"bom-ref": "pkg:pypi/[email protected]", | ||
"evidence": { | ||
"identity": { | ||
"confidence": 0.8, | ||
"field": "purl", | ||
"methods": [ | ||
{ | ||
"confidence": 0.8, | ||
"technique": "manifest-analysis", | ||
"value": "/home/runner/work/src_repos/python/django-goat/requirements_tests.txt" | ||
} | ||
] | ||
} | ||
}, | ||
"group": "", | ||
"name": "requests", | ||
"properties": [ | ||
{ | ||
"name": "SrcFile", | ||
"value": "/home/runner/work/src_repos/python/django-goat/requirements_tests.txt" | ||
} | ||
], | ||
"purl": "pkg:pypi/[email protected]", | ||
"type": "library", | ||
"version": "2.32.3" | ||
}, options), | ||
] | ||
return bom_dicts | ||
|
||
|
||
@pytest.fixture | ||
def results(): | ||
with open("test/test_data.json", "r", encoding="utf-8") as f: | ||
return json.load(f) | ||
|
||
|
||
def test_bom_diff(java_1_bom, java_2_bom, python_1_bom, python_2_bom, results, options_1, options_2): | ||
def test_bom_diff(results, options_1): | ||
result, j1, j2 = compare_dicts(options_1) | ||
result_summary = perform_bom_diff(j1, j2) | ||
assert result_summary == results["result_4"] | ||
result, p1, p2 = compare_dicts(options_2) | ||
result_summary2 = perform_bom_diff(p1, p2) | ||
assert result_summary2 == results["result_5"] | ||
|
||
|
||
def test_bom_diff_options(results, bom_dicts_1, bom_dicts_2, bom_dicts_3, bom_dicts_4, bom_dicts_5, bom_dicts_6): | ||
def test_bom_diff_options(results, bom_dicts_1, bom_dicts_2, bom_dicts_3, bom_dicts_4, bom_dicts_5, bom_dicts_6, bom_dicts_7, bom_dicts_8): | ||
# test --allow-new-data | ||
result_summary = perform_bom_diff(bom_dicts_1, bom_dicts_2) | ||
assert result_summary == results["result_1"] | ||
|
@@ -210,5 +258,9 @@ def test_bom_diff_options(results, bom_dicts_1, bom_dicts_2, bom_dicts_3, bom_di | |
assert result_summary == results["result_2"] | ||
|
||
# test --allow-new-data and --allow-new-versions | ||
result_summary = perform_bom_diff(bom_dicts_7, bom_dicts_8) | ||
assert result_summary == results["result_5"] | ||
|
||
result_summary = perform_bom_diff(bom_dicts_5, bom_dicts_6) | ||
assert result_summary == results["result_3"] | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.