Skip to content

Commit 5eef312

Browse files
committed
fix: merge related fixes
1 parent 3c29436 commit 5eef312

7 files changed

Lines changed: 167 additions & 349 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 5.1.5 on 2025-03-28 10:43
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('commons', '0013_merge_20241028_1602'),
10+
('commons', '0015_settings_exploit_information_max_age_years_and_more'),
11+
]
12+
13+
operations = [
14+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 5.1.5 on 2025-03-28 10:43
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('core', '0061_observation_cve_found_in_and_more'),
10+
('core', '0069_merge_20250120_2305'),
11+
]
12+
13+
operations = [
14+
]

backend/application/import_observations/parsers/cyclone_dx/dependencies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from collections import defaultdict
2+
import logging
23

3-
from application.import_observations.parsers.cyclone_dx.types import Component
4+
from application.import_observations.parsers.cyclone_dx.parser import Component
45

56
logger = logging.getLogger("secobserve.import_observations.cyclone_dx.dependencies")
67

backend/application/import_observations/parsers/cyclone_dx/parser.py

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def check_format(self, data: Any) -> bool:
6464
return True
6565
return False
6666

67-
def get_observations(self, data: dict) -> list[Observation]:
67+
def get_observations(self, data: dict, product: Product, branch: Optional[Branch]) -> list[Observation]:
6868
self.metadata = self._get_metadata(data)
6969
sbom_data = None
7070

@@ -236,48 +236,6 @@ def _create_observations( # pylint: disable=too-many-locals
236236
if not sbom_data:
237237
sbom_data = data
238238

239-
dependencies = sbom_data.get("dependencies", [])
240-
241-
reverse_dep_map = defaultdict(list)
242-
for entry in dependencies:
243-
for dep in entry.get("dependsOn", []):
244-
reverse_dep_map[dep].append(
245-
entry["ref"]
246-
) # Add a relation from the dependency it's "parent"
247-
248-
relevant_components = set()
249-
for vulnerability in data.get("vulnerabilities", []):
250-
for affected in vulnerability.get("affects", []):
251-
ref = affected.get("ref")
252-
if ref:
253-
component = self.components.get(ref)
254-
if component:
255-
relevant_components.add(component.bom_ref)
256-
257-
dependency_paths: dict[str, list[str]] = defaultdict(list)
258-
259-
# Get all paths from the root components in the dependency tree to the relevant components
260-
for relevant_component in relevant_components:
261-
stack: list[tuple[str, Optional[str]]] = [(relevant_component, None)]
262-
visited = set()
263-
if relevant_component not in dependency_paths:
264-
dependency_paths[relevant_component] = []
265-
while stack:
266-
current, previous = stack.pop()
267-
if not current:
268-
continue
269-
270-
if previous:
271-
path = f"{self._translate_component(current)} --> {self._translate_component(previous)}"
272-
if path not in dependency_paths[relevant_component]:
273-
dependency_paths[relevant_component].append(path)
274-
if current in visited:
275-
continue
276-
visited.add(current)
277-
if current in reverse_dep_map:
278-
for parent in reverse_dep_map[current]:
279-
stack.append((parent, current))
280-
281239
for vulnerability in data.get("vulnerabilities", []):
282240
vulnerability_id = vulnerability.get("id")
283241
cvss3_score, cvss3_vector = self._get_cvss(vulnerability, 3)
@@ -309,7 +267,7 @@ def _create_observations( # pylint: disable=too-many-locals
309267
# dependency_paths,
310268
# self.dependencies
311269
# )
312-
self._get_component_dependencies(
270+
observation_component_dependencies = self._get_component_dependencies(
313271
component.bom_ref, self.components, self.dependencies
314272
)
315273
component_dependencies_cache[component.bom_ref] = observation_component_dependencies

backend/application/vex/services/csaf_generator_component.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def _create_component(component_name_version: str, purl: Optional[str], cpe: Opt
9595
product_identification_helper = None
9696
if purl: # or cpe:
9797
purl = purl if purl else None
98+
# Temporary disabled, because Rust crate for CSAF export does not support CPE
9899
# cpe = cpe if cpe else None
99100
product_identification_helper = CSAFProductIdentificationHelper(purl=purl, cpe=cpe)
100101

0 commit comments

Comments
 (0)