File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 583583 < summary class ="is-size-7 has-text-link " style ="cursor: pointer; ">
584584 View SSVC decision tree
585585 </ summary >
586- < pre > {{ ssvc.options|pprint }}</ pre >
586+ < pre > {{ ssvc.options_yaml }}</ pre >
587587 </ details >
588588 </ div >
589589 </ div >
Original file line number Diff line number Diff line change 2626from vulnerabilities .utils import get_purl_version_class
2727from vulnerabilities .views import PackageDetails
2828from vulnerabilities .views import PackageSearch
29+ from vulnerabilities .views import render_as_yaml
2930
3031BASE_DIR = os .path .dirname (os .path .abspath (__file__ ))
3132TEST_DIR = os .path .join (BASE_DIR , "test_data/package_sort" )
@@ -330,3 +331,19 @@ def test_aggregate_fixed_and_affected_packages(self):
330331 end_time = time .time ()
331332 assert end_time - start_time < 0.05
332333 self .assertEqual (response .status_code , 200 )
334+
335+ class TestRenderAsYaml :
336+ def test_render_as_yaml_with_ssvc_options (self ):
337+ options = [
338+ {"Exploitation" : "active" },
339+ {"Automatable" : "yes" },
340+ {"Technical Impact" : "total" },
341+ ]
342+ result = render_as_yaml (options )
343+ assert result == "- Exploitation: active\n - Automatable: yes\n - Technical Impact: total\n "
344+
345+ def test_render_as_yaml_with_none (self ):
346+ assert render_as_yaml (None ) is None
347+
348+ def test_render_as_yaml_with_empty_list (self ):
349+ assert render_as_yaml ([]) is None
Original file line number Diff line number Diff line change 77# See https://aboutcode.org for more information about nexB OSS projects.
88#
99import logging
10-
10+ import saneyaml
1111from cvss .exceptions import CVSS2MalformedError
1212from cvss .exceptions import CVSS3MalformedError
1313from cvss .exceptions import CVSS4MalformedError
4545
4646PAGE_SIZE = 20
4747
48+ def render_as_yaml (value ):
49+ if value :
50+ return saneyaml .dump (value , indent = 2 )
4851
4952class PackageSearch (ListView ):
5053 model = models .Package
@@ -522,6 +525,7 @@ def add_ssvc(ssvc):
522525 "vector" : ssvc .vector ,
523526 "decision" : ssvc .decision ,
524527 "options" : ssvc .options ,
528+ "options_yaml" : render_as_yaml (ssvc .options ),
525529 "advisory_url" : ssvc .source_advisory .url ,
526530 "advisory" : ssvc .source_advisory ,
527531 }
You can’t perform that action at this time.
0 commit comments