Skip to content

computeAffectedVersions narrows coarse window after SortEvents lexicographic fallback #5824

Description

@SashaMIT

Summary

In go/internal/database/datastore/affected_versions.go, computeAffectedVersions calls osvutil.SortEvents and discards the error:

_ = osvutil.SortEvents(eHelper, events)

When any event version fails Parse/Compare, SortEvents re-sorts lexicographically (documented as arbitrary/stable) and returns that error to signal the order is not semantic. The caller still derives coarse_min / coarse_max from positional assumptions that only hold under a semantic sort (first introduced, last event).

Those coarse bounds become hard Datastore inequality filters in buildVersionMatcher, so a row excluded by a wrongly-narrowed window is never returned to the semantic matcher.

Worked example (Packagist)

Events: introduced 1.0, fixed 9.0, introduced 20.0, fixed 30.0, introduced 1.0#bad (Packagist rejects #).

Lexicographic fallback order ends with fixed 9.0, so today's code emits coarse_max = coarse(9.0). Version 25.0 is semantically in-range (20.030.0) but fails the coarse_max >= coarse(25.0) pre-filter.

Expected

On SortEvents error, leave coarse_min/coarse_max at the unbounded defaults (00:000… / 99:999…), matching the Python _get_coarse_min_max ValueError path that resets to MIN/MAX.

Note

This is a correctness / false-negative matching bug in the Go datastore index path (live importer/worker), not a security advisory request. Happy to send a small patch + unit test once this is assigned per CONTRIBUTING.

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