Skip to content

Commit a0f993d

Browse files
committed
Fix Export VEX View
Rename VEX model Add VEX Form Fix UI bug and add the model to dataspace Add basic VEX mapping for CycloneDX Automate VEX creation Add the basic Vex Form Add the skeleton view and form for vex Add Product VEX List view and update tab_vex Add the basic for vex model Add the basic skeleton for vex export Signed-off-by: ziadhany <ziadhany2016@gmail.com>
1 parent 2d76575 commit a0f993d

21 files changed

Lines changed: 1795 additions & 1 deletion

File tree

component_catalog/forms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from product_portfolio.models import Product
5252
from product_portfolio.models import ProductComponent
5353
from product_portfolio.models import ProductPackage
54+
from product_portfolio.models import ProductPackageVEX
5455

5556

5657
class SetKeywordsChoicesFormMixin:

component_catalog/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ def get_export_spdx_url(self):
745745
def get_export_cyclonedx_url(self):
746746
return self.get_url("export_cyclonedx")
747747

748+
def get_export_vex_url(self):
749+
return self.get_url("export_vex")
750+
748751
def get_about_files(self):
749752
"""
750753
Return the list of all AboutCode files from all the Packages
@@ -1914,6 +1917,9 @@ def get_export_spdx_url(self):
19141917
def get_export_cyclonedx_url(self):
19151918
return self.get_url("export_cyclonedx")
19161919

1920+
def get_export_vex_url(self):
1921+
return self.get_url("export_vex")
1922+
19171923
@classmethod
19181924
def get_identifier_fields(cls):
19191925
"""

component_catalog/templates/component_catalog/package_details.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<a class="badge text-bg-secondary" href="{{ object.get_export_cyclonedx_url }}?spec_version=1.5">1.5</a>
4040
<a class="badge text-bg-secondary" href="{{ object.get_export_cyclonedx_url }}?spec_version=1.4">1.4</a>
4141
</div>
42+
</a>
4243
</div>
4344
</div>
4445
</div>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% extends "object_form.html" %}
2+
{% block javascripts %}
3+
{{ block.super }}
4+
{% endblock %}

component_catalog/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from dje.views import DataspacedDeleteView
3030
from dje.views import ExportCycloneDXBOMView
3131
from dje.views import ExportSPDXDocumentView
32+
from dje.views import ExportVEXView
3233
from dje.views import MultiSendAboutFilesView
3334
from dje.views import SendAboutFilesView
3435

component_catalog/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from django.views.decorators.csrf import csrf_protect
4141
from django.views.decorators.http import require_POST
4242
from django.views.generic import FormView
43+
from django.views.generic import UpdateView
4344
from django.views.generic.edit import BaseFormView
4445

4546
from crispy_forms.utils import render_crispy_form
@@ -75,6 +76,7 @@
7576
from dejacode_toolkit.scancodeio import ScanCodeIO
7677
from dejacode_toolkit.scancodeio import get_package_download_url
7778
from dejacode_toolkit.scancodeio import get_scan_results_as_file_url
79+
from dejacode_toolkit.vex import create_auto_vex
7880
from dejacode_toolkit.vulnerablecode import VulnerableCode
7981
from dje import tasks
8082
from dje.client_data import add_client_data
@@ -105,6 +107,7 @@
105107
from policy.models import UsagePolicy
106108
from product_portfolio.models import ProductComponent
107109
from product_portfolio.models import ProductPackage
110+
from product_portfolio.models import ProductPackageVEX
108111

109112
License = apps.get_model("license_library", "License")
110113

@@ -857,7 +860,6 @@ def get_vulnerabilities_tab_fields(self, vulnerabilities):
857860
vulnerability_fields = self.get_vulnerability_fields(vulnerability, dataspace)
858861
fields.extend(vulnerability_fields)
859862
vulnerabilities_count += 1
860-
861863
return fields, vulnerabilities_count
862864

863865
def get_context_data(self, **kwargs):
@@ -1452,6 +1454,8 @@ def get_vulnerabilities_tab_fields(self, vulnerabilities):
14521454
fields = []
14531455
vulnerabilities_count = 0
14541456

1457+
create_auto_vex(self.object, vulnerabilities)
1458+
14551459
for entry in vulnerabilities:
14561460
unresolved = entry.get("affected_by_vulnerabilities", [])
14571461
for vulnerability in unresolved:

dejacode_toolkit/tests/test_vex.py

Lines changed: 424 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"bomFormat": "CycloneDX",
3+
"specVersion": "1.4",
4+
"version": 1,
5+
"vulnerabilities": [
6+
{
7+
"id": "CVE-2020-25649",
8+
"source": {
9+
"name": "NVD",
10+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-25649"
11+
},
12+
"references": [
13+
{
14+
"id": "SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302",
15+
"source": {
16+
"name": "SNYK",
17+
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
18+
}
19+
}
20+
],
21+
"ratings": [
22+
{
23+
"source": {
24+
"name": "NVD",
25+
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N&version=3.1"
26+
},
27+
"score": 7.5,
28+
"severity": "high",
29+
"method": "CVSSv31",
30+
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
31+
},
32+
{
33+
"source": {
34+
"name": "SNYK",
35+
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
36+
},
37+
"score": 8.2,
38+
"severity": "high",
39+
"method": "CVSSv31",
40+
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
41+
},
42+
{
43+
"source": {
44+
"name": "Acme Inc",
45+
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:N/MI:N/MA:N&version=3.1"
46+
},
47+
"score": 0.0,
48+
"severity": "none",
49+
"method": "CVSSv31",
50+
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:N/MI:N/MA:N"
51+
}
52+
],
53+
"cwes": [
54+
611
55+
],
56+
"description": "com.fasterxml.jackson.core:jackson-databind is a library which contains the general-purpose data-binding functionality and tree-model for Jackson Data Processor.\n\nAffected versions of this package are vulnerable to XML External Entity (XXE) Injection. A flaw was found in FasterXML Jackson Databind, where it does not have entity expansion secured properly in the DOMDeserializer class. The highest threat from this vulnerability is data integrity.",
57+
"detail": "XXE Injection is a type of attack against an application that parses XML input. XML is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. By default, many XML processors allow specification of an external entity, a URI that is dereferenced and evaluated during XML processing. When an XML document is being parsed, the parser can make a request and include the content at the specified URI inside of the XML document.\n\nAttacks can include disclosing local files, which may contain sensitive data such as passwords or private user data, using file: schemes or relative paths in the system identifier.",
58+
"recommendation": "Upgrade com.fasterxml.jackson.core:jackson-databind to version 2.6.7.4, 2.9.10.7, 2.10.5.1 or higher.",
59+
"advisories": [
60+
{
61+
"title": "GitHub Commit",
62+
"url": "https://github.com/FasterXML/jackson-databind/commit/612f971b78c60202e9cd75a299050c8f2d724a59"
63+
},
64+
{
65+
"title": "GitHub Issue",
66+
"url": "https://github.com/FasterXML/jackson-databind/issues/2589"
67+
},
68+
{
69+
"title": "RedHat Bugzilla Bug",
70+
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=1887664"
71+
}
72+
],
73+
"created": "2020-12-03T00:00:00.000Z",
74+
"published": "2020-12-03T00:00:00.000Z",
75+
"updated": "2021-10-26T00:00:00.000Z",
76+
"credits": {
77+
"individuals": [
78+
{
79+
"name": "Bartosz Baranowski"
80+
}
81+
]
82+
},
83+
"analysis": {
84+
"state": "not_affected",
85+
"justification": "code_not_reachable",
86+
"response": ["will_not_fix", "update"],
87+
"detail": "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly."
88+
},
89+
"affects": [
90+
{
91+
"ref": "urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.10.0?type=jar"
92+
}
93+
]
94+
}
95+
]
96+
}

0 commit comments

Comments
 (0)