Skip to content

Add PURL validation support (Issue #17)#20

Open
jgamblin wants to merge 1 commit into
mprpic:mainfrom
jgamblin:issue/17-purl-validation
Open

Add PURL validation support (Issue #17)#20
jgamblin wants to merge 1 commit into
mprpic:mainfrom
jgamblin:issue/17-purl-validation

Conversation

@jgamblin
Copy link
Copy Markdown
Contributor

Summary

This PR adds validation for Package URLs (PURLs) in preparation for PURL support being added to the CVE schema. PURLs provide a standardized way to identify packages and their locations.

Impact Analysis

Testing Results (Full CVE dataset: 340,652 files):

Metric Finding
CVEs with PURL Violations 0 (not found in current dataset)
Status No PURLs found in production data yet

This PR is proactive, preparing cvelint for when PURLs are introduced in the CVE schema per PR #407.

Changes

New Validation Rules

  • E012: check-purl-format - Validates PURL strings follow the specification
  • E013: check-purl-consistency - Ensures PURL data matches component information

Features

  • Full PURL specification validation using packageurl-go library
  • Support for checking PURLs in components and affected sections
  • Verification that PURL namespace/name match component data
  • Support for complex PURLs with qualifiers and version information
  • Proper error reporting with JSON path context

PURL Validation Includes

  • Format validation (pkg: prefix required)
  • Namespace/name consistency checks
  • Qualified URL support (e.g., pkg:npm/lodash@4.17.21?arch=x86_64)
  • Clear error messages with problematic values

Testing

  • 10 comprehensive unit tests
  • Tests cover valid PURLs, invalid formats, namespace/name mismatches
  • Tests for components and affected section PURLs
  • Edge cases for empty/missing PURLs

References

@jgamblin jgamblin force-pushed the issue/17-purl-validation branch from e014ff4 to 7679961 Compare May 14, 2026 19:32
@jgamblin
Copy link
Copy Markdown
Contributor Author

Update: I have rebased this PR on top of #23 and pushed the latest changes. I also ran QC checks (go test ./..., go test -race ./..., go vet ./..., gofmt -l .) and everything is passing on this branch.

@mprpic
Copy link
Copy Markdown
Owner

mprpic commented May 18, 2026

I merged 23, can you rebase on top of it now that it's on main? Thanks!

@jgamblin
Copy link
Copy Markdown
Contributor Author

Rebased and tested

This PR has been rebased on the latest main branch and all tests pass.

Test Results:

  • Build: ✅ PASS
  • Unit tests: ✅ PASS
  • Integration tests: ✅ PASS

Ready for review and merge.

@jgamblin jgamblin force-pushed the issue/17-purl-validation branch from 7679961 to 33a0dab Compare May 20, 2026 13:29
@jgamblin
Copy link
Copy Markdown
Contributor Author

Fixed - Complete commit with ruleset entries

Thanks for the feedback on PR #19. I've now applied the same fix to this PR:

What I did:

  1. Created a fresh temp branch from main
  2. Copied the PURL validation rule files (purl.go + purl_test.go)
  3. Added the complete ruleset.go entries for E012 and E013
  4. Created a single atomic commit with all necessary changes
  5. Verified all tests pass

Result:

  • ✅ Clean history with 1 commit containing all PURL validation changes
  • ✅ Rules are properly registered in the ruleset (E012, E013)
  • ✅ All tests passing
  • ✅ Much cleaner, reviewable diff

The commit now includes both the rule implementations AND their ruleset registration, making it a complete, buildable change.

@jgamblin
Copy link
Copy Markdown
Contributor Author

Fixed - Sequential rule numbering applied

Applied Martin's feedback on sequential numbering:

Changes:

What's included:

  • ✅ Complete PURL validation commit (purl.go + purl_test.go)
  • ✅ Ruleset entries properly registered for E013 and E014
  • ✅ All tests passing
  • ✅ Clean, reviewable diff

Ready for review with correct rule numbering!

Add validation rules for Package URLs (PURLs) in preparation for PURL support in CVE schema.

New validation rules:
- E013: CheckPurlFormat - validates PURL strings follow the specification
- E014: CheckPurlConsistency - ensures PURL data matches component information

Features:
- Full PURL format validation using packageurl-go library
- Support for checking PURLs in components and affected sections
- Verification that PURL namespace/name match component data
- Comprehensive test coverage including qualified URLs
- Proper error reporting with context

Per CVE schema PR #407:
- PURLs provide standardized package identification
- Format validation ensures data quality
- Consistency checks prevent mismatches

Fixes mprpic#17
@jgamblin jgamblin force-pushed the issue/17-purl-validation branch from 040c5a7 to 332e947 Compare May 21, 2026 20:26
@jgamblin
Copy link
Copy Markdown
Contributor Author

READY TO MERGE - Updated for upstream/main

Fixed for current upstream/main state which has Unicode as E020:

Current state:

Rule numbering after merge:

Ready for merge!

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

Successfully merging this pull request may close these issues.

Support PURL validation when they are added to CVE

2 participants