Skip to content

ROX-33792: Make ossls audit --export output deterministic for reproducible builds#52

Open
janisz wants to merge 2 commits into
masterfrom
make_it_reproducible
Open

ROX-33792: Make ossls audit --export output deterministic for reproducible builds#52
janisz wants to merge 2 commits into
masterfrom
make_it_reproducible

Conversation

@janisz
Copy link
Copy Markdown

@janisz janisz commented May 6, 2026

Adds support for reproducible builds by making export output deterministic:

  • Sort license files alphabetically before export
  • Normalize file timestamps using SOURCE_DATE_EPOCH environment variable
  • Falls back to current time when SOURCE_DATE_EPOCH is not set

This enables byte-for-byte identical output across multiple runs when SOURCE_DATE_EPOCH is set, allowing Docker layer deduplication and build verification for compliance.

Implementation:

  • Added getExportTimestamp() helper to parse SOURCE_DATE_EPOCH
  • Modified export() to sort dependency.Files and set timestamps with os.Chtimes()
  • Updated README with usage documentation

Refs:

@janisz janisz force-pushed the make_it_reproducible branch from 0369d69 to 4fe3cc8 Compare May 6, 2026 12:51
Adds support for reproducible builds by making export output deterministic:

- Sort license files alphabetically before export
- Normalize file timestamps using SOURCE_DATE_EPOCH environment variable
- Falls back to current time when SOURCE_DATE_EPOCH is not set

This enables byte-for-byte identical output across multiple runs when
SOURCE_DATE_EPOCH is set, allowing build verification for compliance.

Implementation:
- Added getExportTimestamp() helper to parse SOURCE_DATE_EPOCH
- Modified export() to sort dependency.Files and set timestamps with os.Chtimes()
- Updated README with usage documentation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@janisz janisz force-pushed the make_it_reproducible branch from 4fe3cc8 to c1ab840 Compare May 6, 2026 13:05
janisz added a commit to stackrox/stackrox that referenced this pull request May 6, 2026
Problem: OSS notice generation was non-deterministic, preventing Docker
layer deduplication.

Solution:
- Update ossls to stackrox/ossls#52 (make_it_reproducible branch)
- Set SOURCE_DATE_EPOCH=978307200 in ossls-notice Makefile target
- Version: v0.0.0-20260506130332-c1ab840812a7 (with manifest.csv sorting)

Verified: All 3313 files in THIRD_PARTY_NOTICES have identical SHA256
hashes across two clean builds. manifest.csv is now sorted alphabetically.

Why: When dependencies unchanged, Docker detects identical layer content
and reuses existing registry layers, saving 30-60s upload time per build.

Related: stackrox/ossls#52

Partially AI-assisted.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- TestGetExportTimestamp: SOURCE_DATE_EPOCH parsing (6 test cases)
- TestCopyPackageJsonContents: package.json extraction (4 test cases)
- TestExportDependencyFile: file export with timestamps (5 test cases)
- TestExport: complete export workflow (3 test cases)
- TestExportManifest: deterministic CSV generation (6 test cases)
- TestReproducibleExport: end-to-end integration test
- TestExportDependencyFileErrors: error path testing (3 test cases)

Total: 28 test cases across 7 test functions
Coverage: 100% for getExportTimestamp and exportDependencyFile,
92%+ for exportManifest, 82%+ for copyPackageJsonContents
@janisz janisz changed the title Make ossls audit --export output deterministic for reproducible builds ROX-33792: Make ossls audit --export output deterministic for reproducible builds May 11, 2026
@janisz janisz requested review from davdhacs, dvail and mtodor May 11, 2026 12:45
@vikin91
Copy link
Copy Markdown

vikin91 commented May 12, 2026

We discussed that in a meeting and we should rather check whether this can be removed completely in favor of SBOM.

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.

2 participants