From 4b87aa06310e5ea3b994e667d83b2c0b26f1dd5c Mon Sep 17 00:00:00 2001 From: Sampurna Pyne Date: Sat, 25 Jul 2026 00:27:01 +0530 Subject: [PATCH 01/16] Setup Insights App Signed-off-by: Sampurna Pyne --- insights/__init__.py | 8 ++++++++ insights/apps.py | 14 ++++++++++++++ vulnerabilities/templates/navbar.html | 3 +++ vulnerablecode/settings.py | 1 + vulnerablecode/urls.py | 1 + 5 files changed, 27 insertions(+) create mode 100644 insights/__init__.py create mode 100644 insights/apps.py diff --git a/insights/__init__.py b/insights/__init__.py new file mode 100644 index 000000000..20854f2ad --- /dev/null +++ b/insights/__init__.py @@ -0,0 +1,8 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# VulnerableCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/aboutcode-org/vulnerablecode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# diff --git a/insights/apps.py b/insights/apps.py new file mode 100644 index 000000000..7200f28cd --- /dev/null +++ b/insights/apps.py @@ -0,0 +1,14 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# VulnerableCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/aboutcode-org/vulnerablecode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +from django.apps import AppConfig + + +class InsightsConfig(AppConfig): + name = "insights" diff --git a/vulnerabilities/templates/navbar.html b/vulnerabilities/templates/navbar.html index 530c2521e..6e9979019 100644 --- a/vulnerabilities/templates/navbar.html +++ b/vulnerabilities/templates/navbar.html @@ -26,6 +26,9 @@ From b6448af0873ee56992bd5c7abf7773436ca06049 Mon Sep 17 00:00:00 2001 From: Sampurna Pyne Date: Wed, 19 Aug 2026 00:29:21 +0530 Subject: [PATCH 12/16] Remove formatter function for importer_name Signed-off-by: Sampurna Pyne --- insights/charts/__init__.py | 9 +++++++++ insights/charts/importer_panel.py | 7 +++---- insights/models.py | 1 - insights/utils.py | 11 ----------- vulnerabilities/improvers/__init__.py | 4 ++-- vulnerabilities/templates/navbar.html | 4 ++-- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/insights/charts/__init__.py b/insights/charts/__init__.py index a1f26ad73..b05ed6997 100644 --- a/insights/charts/__init__.py +++ b/insights/charts/__init__.py @@ -1,3 +1,12 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# VulnerableCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/aboutcode-org/vulnerablecode for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + from functools import partial from insights.models import ChartDefinition diff --git a/insights/charts/importer_panel.py b/insights/charts/importer_panel.py index 84c948963..2a774fd0d 100644 --- a/insights/charts/importer_panel.py +++ b/insights/charts/importer_panel.py @@ -15,7 +15,6 @@ from django.db.models import Q from insights.models import ImporterInsight -from insights.utils import format_importer_name from vulnerabilities.models import AdvisoryExploit from vulnerabilities.models import AdvisoryV2 @@ -128,7 +127,7 @@ def _get_snapshot_data(snapshot: Any, build_columns_fn) -> Dict[str, Any]: # Individual data for each importer for importer_insight in all_importers: - formatted_name = format_importer_name(importer_insight.importer) + formatted_name = importer_insight.importer data[formatted_name] = build_columns_fn([importer_insight]) return data @@ -144,7 +143,7 @@ def build_importer_package_columns(importers) -> Dict[str, Any]: advisories_without_ghost_packages = [] for importer_insight in importers: - importer_names.append(format_importer_name(importer_insight.importer)) + importer_names.append(importer_insight.importer) total_advisories.append(importer_insight.total_advisories) advisories_with_packages.append(importer_insight.advisories_with_packages) advisories_without_packages.append( @@ -183,7 +182,7 @@ def build_importer_exploit_columns(importers) -> Dict[str, Any]: advisories_with_exploitdb = [] for importer_insight in importers: - importer_names.append(format_importer_name(importer_insight.importer)) + importer_names.append(importer_insight.importer) total_advisories.append(importer_insight.total_advisories) advisories_with_kev.append(importer_insight.advisories_with_kev) advisories_with_metasploit.append(importer_insight.advisories_with_metasploit) diff --git a/insights/models.py b/insights/models.py index ed01830ce..edc21ba0b 100644 --- a/insights/models.py +++ b/insights/models.py @@ -97,7 +97,6 @@ class Meta: @dataclass(frozen=True) class ChartDefinition: - id: str title: str panel: str diff --git a/insights/utils.py b/insights/utils.py index e4d0e6471..08544b434 100644 --- a/insights/utils.py +++ b/insights/utils.py @@ -17,14 +17,3 @@ def get_cwe_label(cwe_id: str) -> str: return f"CWE-{num} · {name}" if name else f"CWE-{num}" except KeyError: return f"CWE-{num}" - - -def format_importer_name(name: str) -> str: - """ - Format importer internal names into human-readable labels. - e.g., 'pysec_importer_v2' -> 'Pysec Importer' - """ - parts = name.rsplit("_v", 1) - if len(parts) == 2 and parts[1].isdigit(): - name = parts[0] - return name.replace("_", " ") diff --git a/vulnerabilities/improvers/__init__.py b/vulnerabilities/improvers/__init__.py index aeaa57654..e5ad20058 100644 --- a/vulnerabilities/improvers/__init__.py +++ b/vulnerabilities/improvers/__init__.py @@ -7,7 +7,7 @@ # See https://aboutcode.org for more information about nexB OSS projects. # -from insights.insights_snapshot_pipeline import InsightsSnapshotPipeline +from insights import insights_snapshot_pipeline from vulnerabilities.pipelines.v2_improvers import archive_urls from vulnerabilities.pipelines.v2_improvers import collect_ssvc_trees from vulnerabilities.pipelines.v2_improvers import compute_advisory_todo as compute_advisory_todo_v2 @@ -44,6 +44,6 @@ enhance_with_github_poc.GithubPocsImproverPipeline, mark_unfurl_version_range.MarkUnfurlVersionRangePipeline, group_advisories_for_packages_v2.GroupAdvisoriesForPackages, - InsightsSnapshotPipeline, + insights_snapshot_pipeline.InsightsSnapshotPipeline, ] ) diff --git a/vulnerabilities/templates/navbar.html b/vulnerabilities/templates/navbar.html index b50cc3fb2..6e9979019 100644 --- a/vulnerabilities/templates/navbar.html +++ b/vulnerabilities/templates/navbar.html @@ -1,7 +1,7 @@ {% load utils %} - +{% endif %}