Skip to content

Long OSV aliases (>50 chars) break advisory import — whole advisory silently dropped #2555

Backlog

Description

@sanchit955

Problem

get_or_create_advisory_aliases (vulnerabilities/pipes/advisory.py) bulk-creates every alias with no length check, but AdvisoryAlias.alias is CharField(max_length=50). An alias over 50 chars raises django.db.utils.DataError: value too long for type character varying(50) inside insert_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: Hex, NuGet, crates.io, RubyGems, Maven, Go, Packagist, PyPI). 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, not just these 6):

  • 63 chars: SNYK-GOLANG-GITHUBCOMARGOPROJARGOEVENTSSENSORSARTIFACTS-2864522 (GO-2022-0492 / GHSA-qpgx-64h2-gc3c)
  • 61 chars: SNYK-GOLANG-GITHUBCOMTYKTECHNOLOGIESTYKIDENTITYBROKER-1089720 (GO-2022-0906 / GHSA-599h-8wpj-75xj)
  • 60 chars: SNYK-GOLANG-GITHUBCOMCONTAINERNETWORKINGCNIPKGINVOKE-1070549 (GHSA-xjqr-g762-pxwp)
  • 54 chars: SNYK-GOLANG-GITHUBCOMCONTAINRRRSHOUTRRRPKGUTIL-2849059 (GO-2022-0528 / GHSA-477v-w82m-634j)
  • 53 chars: SNYK-GOLANG-GITHUBCOMSASSOFTWAREGORPMUTILSCPIO-570427 (GO-2020-0042 / GHSA-9423-6c93-gpp8)
  • 51 chars: SNYK-GOLANG-GITHUBCOMNATSIONATSSERVERSERVER-1042967 (GO-2022-0855 / GHSA-m4jx-6526-vvhm) and SNYK-GOLANG-GITHUBCOMMHOLTARCHIVERCMDARCHIVER-50071 (GHSA-5wmg-j84w-4jj4)

Reproduced on current main: a minimal AdvisoryDataV2 carrying the real GHSA-599h-8wpj-75xj aliases passed to insert_advisory_v2 raises the DataError above.

Fix (see linked PR)

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 was considered and not taken: it 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_v3 path), 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions