Skip to content

Emit single SEMVER range with multiple events per affected#49

Open
PushkarJ wants to merge 2 commits intokubernetes-sigs:mainfrom
PushkarJ:enhance-semver-non-overlap-pj
Open

Emit single SEMVER range with multiple events per affected#49
PushkarJ wants to merge 2 commits intokubernetes-sigs:mainfrom
PushkarJ:enhance-semver-non-overlap-pj

Conversation

@PushkarJ
Copy link
Copy Markdown
Member

@PushkarJ PushkarJ commented Feb 26, 2026

Ensure each affected entry emits one SEMVER range whose events form a non-overlapping introduced/fixed timeline.

collector/k8s.go:

Rewrite getAffectedEvents to filter versions with Introduced set, sort intervals by closing version, and build the events slice in a single pass.

Adjust overlapping intervals that start at 0 to begin at the next minor when needed so ranges do not overlap.

Add versionEnd, nextMinorStart and minorOf helpers to centralize version arithmetic and comparisons.

Return a single SEMVER range per affected entry and omit ranges when no valid intervals exist.

Fix typo in olderCve comment (collcted -> collected).

collector/k8s_test.go:

Add testdataDir helper so fixtures are found regardless of working directory.

Update Test_ParseVulneDB and Test_cveIDToModifiedMap to use testdataDir and compare unmarshalled JSON structures instead of raw strings.

Add tests for getAffectedEvents, overlapping "introduced 0" intervals, nextMinorStart, versionEnd and minorOf.

collector/testdata/expected-vulndb.json:

  • Regenerate expected OSV output for updated ranges and new CVEs.

vulns/CVE-2025-15566.json:

  • Fix second interval: introduced 0 -> 1.13.0 to avoid
    overlap with the first interval.

Follow up to #46

/sig security

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. sig/security Categorizes an issue or PR as relevant to SIG Security. labels Feb 26, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: PushkarJ

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 26, 2026
@PushkarJ PushkarJ force-pushed the enhance-semver-non-overlap-pj branch from 1c2a8ec to c01f703 Compare March 2, 2026 22:17
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 2, 2026
@PushkarJ PushkarJ force-pushed the enhance-semver-non-overlap-pj branch from c01f703 to 309965f Compare March 2, 2026 22:20
Ensure each affected entry emits one SEMVER range whose events
form a non-overlapping introduced/fixed timeline.

collector/k8s.go:
- Rewrite getAffectedEvents to filter versions with Introduced
  set, sort intervals by closing version, and build the events
  slice in a single pass.
- Adjust overlapping intervals that start at 0 to begin at the
  next minor when needed so ranges do not overlap.
- Add versionEnd, nextMinorStart and minorOf helpers to
  centralize version arithmetic and comparisons.
- Return a single SEMVER range per affected entry and omit
  ranges when no valid intervals exist.
- Fix typo in olderCve comment (collcted -> collected).

collector/k8s_test.go:
- Add testdataDir helper so fixtures are found regardless of
  working directory.
- Update Test_ParseVulneDB and Test_cveIDToModifiedMap to use
  testdataDir and compare unmarshalled JSON structures instead
  of raw strings.
- Add tests for getAffectedEvents, overlapping "introduced 0"
  intervals, nextMinorStart, versionEnd and minorOf.

collector/testdata/expected-vulndb.json:
- Regenerate expected OSV output for updated ranges and new
  CVEs.

vulns/CVE-2025-15566.json:
- Fix second interval: introduced 0 -> 1.13.0 to avoid
  overlap with the first interval.
@PushkarJ PushkarJ force-pushed the enhance-semver-non-overlap-pj branch from 309965f to 7d46d78 Compare March 3, 2026 05:01
@PushkarJ
Copy link
Copy Markdown
Member Author

PushkarJ commented Mar 3, 2026

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Mar 3, 2026
@PushkarJ PushkarJ marked this pull request as ready for review March 3, 2026 16:48
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 3, 2026
@k8s-ci-robot k8s-ci-robot requested a review from tabbysable March 3, 2026 16:48
@PushkarJ
Copy link
Copy Markdown
Member Author

/cc @mtardy

@k8s-ci-robot k8s-ci-robot requested a review from mtardy March 16, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/security Categorizes an issue or PR as relevant to SIG Security. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants