Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion vulnerabilities/templates/advisory_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{% load static %}
{% load show_cvss %}
{% load url_filters %}
{% load utils %}

{% block title %}
VulnerableCode Advisory Details - {{ advisory.advisory_id }}
Expand Down Expand Up @@ -583,7 +584,7 @@
<summary class="is-size-7 has-text-link" style="cursor: pointer;">
View SSVC decision tree
</summary>
<pre>{{ ssvc.options|pprint }}</pre>
<pre>{{ ssvc.options|yaml_dump }}</pre>
</details>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions vulnerabilities/templatetags/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from aboutcode.pipeline import humanize_time
from django import template
import saneyaml

register = template.Library()

Expand Down Expand Up @@ -39,3 +40,14 @@ def active_item(context, url_name):
@register.filter
def get_item(dictionary, key):
return dictionary.get(key)


@register.filter
def yaml_dump(value):
"""Render structured data as YAML using saneyaml.dump."""
if value is None:
return ""
try:
return saneyaml.dump(value)
except (TypeError, ValueError):
return str(value)