diff --git a/component_catalog/templates/component_catalog/includes/vulnerability_icon_link.html b/component_catalog/templates/component_catalog/includes/vulnerability_icon_link.html index 9ba7d739..bf556e1e 100644 --- a/component_catalog/templates/component_catalog/includes/vulnerability_icon_link.html +++ b/component_catalog/templates/component_catalog/includes/vulnerability_icon_link.html @@ -1,3 +1,3 @@ - + {% if count %}{{ count }}{% endif %} \ No newline at end of file diff --git a/component_catalog/templates/component_catalog/tabs/tab_vulnerabilities.html b/component_catalog/templates/component_catalog/tabs/tab_vulnerabilities.html new file mode 100644 index 00000000..9f29dea3 --- /dev/null +++ b/component_catalog/templates/component_catalog/tabs/tab_vulnerabilities.html @@ -0,0 +1,67 @@ +{% load i18n %} +
+ + {% trans 'Affected by' %} + + | ++ + {% trans 'Summary' %} + + | ++ + {% trans 'Aliases' %} + + | ++ + {% trans 'Fixed packages' %} + + | +
---|---|---|---|
+ + {{ vulnerability.vulnerability_id }} + + + | ++ {{ vulnerability.summary }} + | +
+ {% for alias in vulnerability.aliases %}
+ {% if alias|slice:":3" == "CVE" %}
+ {{ alias }}
+
+
+ {% elif alias|slice:":4" == "GHSA" %}
+ {{ alias }}
+
+
+ {% elif alias|slice:":3" == "NPM" %}
+ {{ alias }}
+
+
+ {% else %}
+ {{ alias }}
+ {% endif %}
+ + {% endfor %} + |
+ + {% if vulnerability.fixed_packages_html %} + {{ vulnerability.fixed_packages_html }} + {% endif %} + | +
- display_value += (
- f''
- f''
- f''
- f""
- f""
+ fixed_packages_values = []
+ for fixed_package in fixed_packages_sorted:
+ purl = fixed_package.get("purl")
+ is_vulnerable = fixed_package.get("is_vulnerable")
+ package_instances = Package.objects.scope(dataspace).for_package_url(purl)
+
+ for package in package_instances:
+ absolute_url = package.get_absolute_url()
+ display_value = package.get_html_link(href=absolute_url)
+ if is_vulnerable:
+ display_value += package.get_html_link(
+ href=f"{absolute_url}#vulnerabilities",
+ value=format_html(vulnerability_icon),
)
- fixed_packages_values.append(display_value)
-
- tab_fields.append(
- (
- _("Fixed packages"),
- format_html("\n".join(fixed_packages_values)),
- "The identifiers of Package Versions that have been reported to fix a "
- "specific vulnerability and collected in VulnerableCodeDB.",
- ),
- )
+ else:
+ display_value += no_vulnerabilities_icon
+ fixed_packages_values.append(display_value)
- tab_fields.extend(
- [
- (
- _("Reference IDs"),
- format_html(reference_ids_joined),
- "Reference IDs to the reported vulnerability, such as a DSA "
- "(Debian Security Advisory) ID or a CVE (Common Vulnerabilities "
- "and Exposures) ID, when available.",
- ),
- (
- _("Reference URLs"),
- urlize_target_blank(reference_urls_joined),
- "The URLs collected in VulnerableCodeDB that give you quick "
- "access to public websites that provide details about a "
- "vulnerability.",
- ),
- FieldLastLoop,
- ]
- )
+ if not package_instances:
+ display_value = purl.replace("pkg:", "")
+ if is_vulnerable:
+ display_value += vulnerability_icon
+ else:
+ display_value += no_vulnerabilities_icon
+ # Warning: do not add spaces between HTML elements as this content
+ # is displayed in a
+ display_value += (
+ f''
+ f''
+ f''
+ f""
+ f""
+ )
+ fixed_packages_values.append(display_value)
- return tab_fields
+ return format_html("\n".join(fixed_packages_values))
class ComponentListView(
diff --git a/dejacode/static/css/dejacode_bootstrap.css b/dejacode/static/css/dejacode_bootstrap.css
index 07d374cc..1a36881e 100644
--- a/dejacode/static/css/dejacode_bootstrap.css
+++ b/dejacode/static/css/dejacode_bootstrap.css
@@ -64,6 +64,9 @@ a.dropdown-item:hover {
.smaller {
font-size: 90%;
}
+.mini {
+ font-size: .675em;
+}
code {
color: #ac1459;
}