MCPcopy Index your code
hub / github.com/aboutcode-org/vulnerablecode / get_fixed_package_details

Function get_fixed_package_details

vulnerabilities/views.py:438–476  ·  view source on GitHub ↗
(package)

Source from the content-addressed store, hash-verified

436
437
438def get_fixed_package_details(package):
439 rows = package.affected_in_impacts.values_list(
440 "advisory__avid",
441 "fixed_by_packages",
442 )
443
444 pkg_ids = {pkg_id for _, pkg_id in rows if pkg_id}
445
446 pkg_map = {
447 p.id: p
448 for p in models.PackageV2.objects.filter(id__in=pkg_ids, is_ghost=False).annotate(
449 is_vulnerable=Exists(
450 models.ImpactedPackage.objects.filter(
451 affecting_packages=OuterRef("pk"),
452 advisory__is_latest=True,
453 advisory___all_impacts_unfurled_at__isnull=False,
454 )
455 )
456 )
457 }
458
459 fixed_pkg_details = defaultdict(list)
460
461 for avid, pkg_id in rows:
462 if not pkg_id:
463 continue
464
465 pkg = pkg_map.get(pkg_id)
466 if not pkg:
467 continue
468
469 fixed_pkg_details[avid].append(
470 {
471 "pkg": pkg,
472 "is_vulnerable": pkg.is_vulnerable,
473 }
474 )
475
476 return fixed_pkg_details
477
478
479class VulnerabilityDetails(VulnerableCodeDetailView):

Callers 2

get_context_dataMethod · 0.85
get_context_dataMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected