Skip to content

Commit

Permalink
Fix: BomVdr fields and logic (#29)
Browse files Browse the repository at this point in the history
* linting

Signed-off-by: Caroline Russell <[email protected]>

* Fix: Missing VDR fields, improve tests.

Signed-off-by: Caroline Russell <[email protected]>

---------

Signed-off-by: Caroline Russell <[email protected]>
  • Loading branch information
cerrussell authored Jul 29, 2024
1 parent bf18895 commit ee6d26d
Show file tree
Hide file tree
Showing 5 changed files with 466 additions and 206 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ dependencies
vulnerabilities
- advisories
- affects
- analysis
- bom-ref
- cwes
- description
- detail
- id
- properties
- published
- ratings
- recommendation
- references
- source
- updated
Expand Down
9 changes: 4 additions & 5 deletions custom_json_diff/custom_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Dict, List, Set, Tuple

from jinja2 import Environment
from json_flatten import flatten, unflatten # type: ignore
from json_flatten import flatten # type: ignore

from custom_json_diff.custom_diff_classes import BomDicts, FlatDicts, Options

Expand Down Expand Up @@ -40,8 +40,7 @@ def compare_dicts(options: Options) -> Tuple[int, FlatDicts | BomDicts, FlatDict
json_2_data = load_json(options.file_2, options2)
if json_1_data == json_2_data:
return 0, json_1_data, json_2_data
else:
return 1, json_1_data, json_2_data
return 1, json_1_data, json_2_data


def export_html_report(outfile: str, diffs: Dict, j1: BomDicts, j2: BomDicts, options: Options) -> None:
Expand Down Expand Up @@ -180,7 +179,7 @@ def report_results(status: int, diffs: Dict, options: Options, j1: BomDicts | No
if not options.output:
logger.warning("No output file specified. No reports generated.")
return
elif options.bom_diff:
if options.bom_diff:
report_file = options.output.replace(".json", "") + ".html"
export_html_report(report_file, diffs, j1, j2, options) # type: ignore

Expand Down Expand Up @@ -210,7 +209,7 @@ def sort_list(lst: List, sort_keys: List[str]) -> List:


def summarize_diffs(result: Dict, diff_counts: Dict, bom_counts: Dict, common_counts: Dict) -> Dict:
for key, value in diff_counts.items():
for key in diff_counts.keys():
if bom_counts[key] != 0:
found = bom_counts[key] - common_counts.get(key, 0)
if result.get(key):
Expand Down
Loading

0 comments on commit ee6d26d

Please sign in to comment.