Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CVEDB] Why does the function metric_finder returns unknown or a metrics_id #4578

Open
jloehel opened this issue Nov 18, 2024 · 0 comments
Open

Comments

@jloehel
Copy link

jloehel commented Nov 18, 2024

@Rexbeast2 I don't really get the function metric_finder? The function checks basically if the CVSS_version can be mapped to an existing metrics_id but why unknown ? The metric_finder should return a metrics_id.

if cve["CVSS_version"] == "unknown":
metric = "unknown"

It would make more sense to add a fourth entry to the table metrics called unknown with the id 0 and skip the db check.

METRICS = [
    (0, "UNKNOWN"),
	(1, "EPSS"),
	(2, "CVSS-2"),
	(3, "CVSS-3"),
]

The IDs a predefined and will not change. Something like this should be enough, right?

...
UNKNOWN_METRIC_ID = 0
SUPPORTED_METRIC_VERSIONS = [CVSS_2_METRIC_ID, CVSS_3_METRIC_ID]

def version2metrics_id(self, version):
    if version not in SUPPORTED_METRIC_VERSIONS:
        logger.warning(f"Unsupported metric version: {version}")
        return UNKNOWN_METRIC_ID
    return version
...
                cursor.execute(
                    insert_cve_metrics,
                    [
                        cve["ID"],
                        self.version2metrics_id(cve["CVSS_version"]),
                        cve["score"],
                        cve["CVSS_vector"],
                    ],
                )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant