Skip to content

Commit

Permalink
Fix Export VEX View
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ziadhany committed Apr 27, 2024
1 parent 2d76575 commit a0f993d
Show file tree
Hide file tree
Showing 21 changed files with 1,795 additions and 1 deletion.
1 change: 1 addition & 0 deletions component_catalog/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from product_portfolio.models import Product
from product_portfolio.models import ProductComponent
from product_portfolio.models import ProductPackage
from product_portfolio.models import ProductPackageVEX


class SetKeywordsChoicesFormMixin:
Expand Down
6 changes: 6 additions & 0 deletions component_catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ def get_export_spdx_url(self):
def get_export_cyclonedx_url(self):
return self.get_url("export_cyclonedx")

def get_export_vex_url(self):
return self.get_url("export_vex")

def get_about_files(self):
"""
Return the list of all AboutCode files from all the Packages
Expand Down Expand Up @@ -1914,6 +1917,9 @@ def get_export_spdx_url(self):
def get_export_cyclonedx_url(self):
return self.get_url("export_cyclonedx")

def get_export_vex_url(self):
return self.get_url("export_vex")

@classmethod
def get_identifier_fields(cls):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<a class="badge text-bg-secondary" href="{{ object.get_export_cyclonedx_url }}?spec_version=1.5">1.5</a>
<a class="badge text-bg-secondary" href="{{ object.get_export_cyclonedx_url }}?spec_version=1.4">1.4</a>
</div>
</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends "object_form.html" %}
{% block javascripts %}
{{ block.super }}
{% endblock %}
1 change: 1 addition & 0 deletions component_catalog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from dje.views import DataspacedDeleteView
from dje.views import ExportCycloneDXBOMView
from dje.views import ExportSPDXDocumentView
from dje.views import ExportVEXView
from dje.views import MultiSendAboutFilesView
from dje.views import SendAboutFilesView

Expand Down
6 changes: 5 additions & 1 deletion component_catalog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from django.views.decorators.csrf import csrf_protect
from django.views.decorators.http import require_POST
from django.views.generic import FormView
from django.views.generic import UpdateView
from django.views.generic.edit import BaseFormView

from crispy_forms.utils import render_crispy_form
Expand Down Expand Up @@ -75,6 +76,7 @@
from dejacode_toolkit.scancodeio import ScanCodeIO
from dejacode_toolkit.scancodeio import get_package_download_url
from dejacode_toolkit.scancodeio import get_scan_results_as_file_url
from dejacode_toolkit.vex import create_auto_vex
from dejacode_toolkit.vulnerablecode import VulnerableCode
from dje import tasks
from dje.client_data import add_client_data
Expand Down Expand Up @@ -105,6 +107,7 @@
from policy.models import UsagePolicy
from product_portfolio.models import ProductComponent
from product_portfolio.models import ProductPackage
from product_portfolio.models import ProductPackageVEX

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

Expand Down Expand Up @@ -857,7 +860,6 @@ def get_vulnerabilities_tab_fields(self, vulnerabilities):
vulnerability_fields = self.get_vulnerability_fields(vulnerability, dataspace)
fields.extend(vulnerability_fields)
vulnerabilities_count += 1

return fields, vulnerabilities_count

def get_context_data(self, **kwargs):
Expand Down Expand Up @@ -1452,6 +1454,8 @@ def get_vulnerabilities_tab_fields(self, vulnerabilities):
fields = []
vulnerabilities_count = 0

create_auto_vex(self.object, vulnerabilities)

for entry in vulnerabilities:
unresolved = entry.get("affected_by_vulnerabilities", [])
for vulnerability in unresolved:
Expand Down
424 changes: 424 additions & 0 deletions dejacode_toolkit/tests/test_vex.py

Large diffs are not rendered by default.

96 changes: 96 additions & 0 deletions dejacode_toolkit/tests/testfiles/vex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"version": 1,
"vulnerabilities": [
{
"id": "CVE-2020-25649",
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-25649"
},
"references": [
{
"id": "SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302",
"source": {
"name": "SNYK",
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
}
}
],
"ratings": [
{
"source": {
"name": "NVD",
"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"
},
"score": 7.5,
"severity": "high",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
},
{
"source": {
"name": "SNYK",
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
},
"score": 8.2,
"severity": "high",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
},
{
"source": {
"name": "Acme Inc",
"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"
},
"score": 0.0,
"severity": "none",
"method": "CVSSv31",
"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"
}
],
"cwes": [
611
],
"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.",
"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.",
"recommendation": "Upgrade com.fasterxml.jackson.core:jackson-databind to version 2.6.7.4, 2.9.10.7, 2.10.5.1 or higher.",
"advisories": [
{
"title": "GitHub Commit",
"url": "https://github.com/FasterXML/jackson-databind/commit/612f971b78c60202e9cd75a299050c8f2d724a59"
},
{
"title": "GitHub Issue",
"url": "https://github.com/FasterXML/jackson-databind/issues/2589"
},
{
"title": "RedHat Bugzilla Bug",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=1887664"
}
],
"created": "2020-12-03T00:00:00.000Z",
"published": "2020-12-03T00:00:00.000Z",
"updated": "2021-10-26T00:00:00.000Z",
"credits": {
"individuals": [
{
"name": "Bartosz Baranowski"
}
]
},
"analysis": {
"state": "not_affected",
"justification": "code_not_reachable",
"response": ["will_not_fix", "update"],
"detail": "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly."
},
"affects": [
{
"ref": "urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#pkg:maven/com.fasterxml.jackson.core/jackson-databind@2.10.0?type=jar"
}
]
}
]
}
Loading

0 comments on commit a0f993d

Please sign in to comment.