Repository navigation
fix(pipes): skip OSV aliases longer than the alias column - #2556
Open
sanchit955 wants to merge 1 commit into
Open
sanchit955 wants to merge 1 commit into
sanchit955 wants to merge 1 commit into
Conversation
Over-long aliases (e.g. SNYK ids that embed the full package path) raise DataError on insert and drop the whole advisory. GHSA-599h-8wpj-75xj carries a 61-char SNYK alias; skip such aliases with a log instead so the advisory still imports with its other aliases. Signed-off-by: Sanchit <dev.sanchit955@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2555
Problem
get_or_create_advisory_aliasesbulk-creates every alias with no length check, butAdvisoryAlias.aliasisCharField(max_length=50). An alias over 50 chars raisesdjango.db.utils.DataError: value too long for type character varying(50)insideinsert_advisory_v2, which has no try/except around the alias step — the base pipeline catches it per-advisory and logs "Failed to import advisory", so the whole advisory is silently dropped from the import.Evidence
Scanned the OSV bulk exports for 8 ecosystems (62,291 advisories). 12 records carry an alias over 50 chars — 6 distinct SNYK-Golang ids (SNYK ids embed the full uppercase module path, so the class is open-ended):
SNYK-GOLANG-GITHUBCOMARGOPROJARGOEVENTSSENSORSARTIFACTS-2864522(GO-2022-0492 / GHSA-qpgx-64h2-gc3c)SNYK-GOLANG-GITHUBCOMTYKTECHNOLOGIESTYKIDENTITYBROKER-1089720(GO-2022-0906 / GHSA-599h-8wpj-75xj)Reproduced on current main: a minimal
AdvisoryDataV2with the real GHSA-599h-8wpj-75xj aliases raises the DataError frominsert_advisory_v2.Fix
Skip over-long aliases with an error log in
get_or_create_advisory_aliases. A truncated alias would be a false identifier, so skipping keeps stored data truthful and lets the advisory import with its other aliases. Widening the column would fix the 6 known ids but a longer SNYK id re-breaks it; the skip closes the class at any length.The same advisory also flows through the github_osv importer (same
parse_advisory_data_v3path), so one fix covers both.Caveat: the skipped SNYK alias is genuinely lost from the record (the advisory keeps its CVE + GO aliases). If maintainers prefer a migration widening the column instead, happy to rework.
Tests
vulnerabilities/tests/pipes/test_advisory.py:test_get_or_create_advisory_aliases_skips_overlong_aliasandtest_insert_advisory_v2_with_overlong_alias(real GHSA-599h aliases; asserts the advisory imports and only CVE-2021-23365 + GO-2022-0906 are stored). Both fail pre-fix with DataError and pass post-fix (verified by reverting the source change only).test_advisory.py: 14 passed (PostgreSQL 16).black --checkclean on both changed files.Signed-off-by: Sanchit dev.sanchit955@gmail.com