Skip to content

Commit

Permalink
Improved bom-diff html report, refined version comparison, refactorin…
Browse files Browse the repository at this point in the history
…g. (#33)

* Improved bom-diff html report, refined version comparison, refactoring.

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

* Typing exceptions.

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

---------

Signed-off-by: Caroline Russell <[email protected]>
  • Loading branch information
cerrussell authored Aug 16, 2024
1 parent cfdb91b commit 86c6648
Show file tree
Hide file tree
Showing 10 changed files with 621 additions and 408 deletions.
138 changes: 133 additions & 5 deletions custom_json_diff/bom_diff_template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,17 @@
</details>
</li>
{% endif %}
{% if key not in ["source","ratings","references","affects"] %}
{% if key == "detail" %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
<li>{{ value }}</li>
</ul>
</details>
</li>
{% endif %}
{% if key not in ["source","ratings","references","affects","detail"] %}
<li>{{ key }}: {{ value }}</li>
{% endif %}
{% endif %}
Expand Down Expand Up @@ -577,7 +587,17 @@
</details>
</li>
{% endif %}
{% if key not in ["source","ratings","references","affects"] %}
{% if key == "detail" %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
<li>{{ value }}</li>
</ul>
</details>
</li>
{% endif %}
{% if key not in ["source","ratings","references","affects","detail"] %}
<li>{{ key }}: {{ value }}</li>
{% endif %}
{% endif %}
Expand Down Expand Up @@ -797,13 +817,121 @@
{% if common_vdrs %}
<tr>
<th style="width: 8%">vulnerabilities</th>
<td style="width: 41%">{% for item in common_vdrs %}
<td>{% for item in common_vdrs %}
<details>
<summary>{{ item['bom-ref'] }}</summary>
<ul>
{% for key, value in item|items %}
{% if value != "" %}
<li>{{ key }}: {{ value }}</li>
{% if value and key not in ["advisories","analysis","cwes","properties"] %}
{% if key == "source" %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
{% for skey, svalue in value|items %}
<li>{{ skey }}: {{ svalue }}</li>
{% endfor %}
</ul>
</details>
</li>
{% endif %}
{% if key == "ratings" %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
{% for rating in value %}
<li>
<details>
<summary>{{ rating["vector"] }}:</summary>
<ul>
{% for rkey, rvalue in rating|items %}
<li>{{ rkey }}: {{ rvalue }}</li>
{% endfor %}
</ul>
</details>
</li>
{% endfor %}
</ul>
</details>
</li>
{% endif %}
{% if key == "references" %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
{% for ref in value %}
<details>
<summary>{{ ref['id'] }}:</summary>
<ul>
<li>
name: {{ ref['source']['name'] }}</li>
<li>
url: {{ ref['source']['url'] }}</li>
</ul>
</details>
{% endfor %}
</ul>
</details>
</li>
{% endif %}
{% if key == "affects" %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
{% for affect in value %}
<details>
<summary>{{ affect['ref'] }}:</summary>
<ul>
{% for a in affect['versions'] %}
<li>{{ a }}</li>
{% endfor %}
</ul>
</details>
{% endfor %}
</ul>
</details>
</li>
{% endif %}
{% if key == "detail" %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
<li>{{ value }}</li>
</ul>
</details>
</li>
{% endif %}
{% if key not in ["source","ratings","references","affects","detail"] %}
<li>{{ key }}: {{ value }}</li>
{% endif %}
{% endif %}
{% if key in ["advisories","cwes","properties"] and value|length > 0 %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
{% for i in value %}
<li>{{ i }}</li>
{% endfor %}
</ul>
</details>
</li>
{% endif %}
{% if key == "analysis" and value|length > 0 %}
<li>
<details>
<summary>{{ key }}:</summary>
<ul>
{% for a,b in value|items %}
<li>{{ a }}: {{ b }}</li>
{% endfor %}
</ul>
</details>
</li>
{% endif %}
{% endfor %}
</ul>
Expand Down
8 changes: 6 additions & 2 deletions custom_json_diff/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

from importlib.metadata import version

from custom_json_diff.custom_diff import (compare_dicts, get_diff, perform_bom_diff,
report_results)
from custom_json_diff.custom_diff import (
compare_dicts,
get_diff,
perform_bom_diff,
report_results
)
from custom_json_diff.custom_diff_classes import Options


Expand Down
Loading

0 comments on commit 86c6648

Please sign in to comment.