Skip to content

Implement checksumPolicy for TrustedChecksums to enforce strict version matching - #7510

Open
chrisrueger with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-trusted-checksums-failure
Open

chrisrueger with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-trusted-checksums-failure

Conversation

Copilot AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Currently, TrustedChecksums only validates checksums when entries exist in the .checksums file, allowing builds to pass when a dependency version is updated without corresponding checksum updates. This adds a new checksumPolicy configuration to enforce that all dependencies have matching BSN+version entries.

Changes

Configuration & Policy Enum

  • Added checksumPolicy() method to Configuration interface (default: "lenient")
  • Created ChecksumPolicy enum with STRICT and LENIENT modes

TrustedChecksums Validation Logic

  • Modified checkTrustedChecksum() to enforce policies:
    • Strict mode: Throws TrustedChecksumException when .checksums file missing or entry not found
    • Lenient mode: Returns false for missing entries (preserves backward-compatible behavior)
  • Added setChecksumPolicy() and getChecksumPolicy() methods

MavenRepository & MavenBndRepository Integration

  • MavenRepository: Added setTrustedChecksumsPolicy() to apply policy
  • MavenBndRepository: Reads checksumPolicy from configuration and applies it during initialization

Test Coverage

  • Added comprehensive tests covering all policy scenarios: missing files, missing entries, version mismatches in both modes

Usage Example

Configure in bnd.bnd or repository configuration:

checksumPolicy = strict  # Require all dependencies in .checksums (fails on version mismatch)
checksumPolicy = lenient # Current behavior, only validates existing entries (default)

Backward Compatibility

Default behavior unchanged (lenient mode). Existing configurations continue to work without modification.

Scenario Strict Lenient (default)
Missing .checksums file ❌ Fail ✅ Pass
Dependency not in .checksums ❌ Fail ✅ Pass
Version mismatch (e.g., 1.33→1.37) ❌ Fail ✅ Pass
Checksum mismatch ❌ Fail ❌ Fail

Package versions incremented to reflect new APIs: aQute.bnd.repository.maven.provider (2.4.0→2.5.0) and aQute.maven.provider (2.9.0→2.10.0).

Copilot AI changed the title [WIP] Fix trusted checksums to fail build on new dependencies Implement checksumPolicy for TrustedChecksums to enforce strict version matching Oct 29, 2026
Copilot AI requested a review from chrisrueger October 29, 2026 13:11
@chrisrueger

Copy link
Copy Markdown
Contributor

@peterkir Does that look ok for you in principle?

- Add checksumPolicy configuration property to Configuration interface
- Create ChecksumPolicy enum with STRICT and LENIENT modes
- Implement policy-based validation in TrustedChecksums
- Add setter methods to pass policy to MavenRepository
- Initialize policy from configuration in MavenBndRepository
- Add comprehensive unit tests for both policy modes
- Update package versions (2.4.0->2.5.0 and 2.9.0->2.10.0)

Apply checksumPolicy integration to BndPomRepository

- Add checksumPolicy() method to PomConfiguration interface
- Implement checksumPolicy initialization in BndPomRepository.prepareAsync()
- Update package version 2.3.0 -> 2.4.0

Extend docs for checksumPolicy feature in maven.md

- Add checksumPolicy property to configuration table
- Add new "Checksum Policy" subsection explaining strict vs lenient modes
- Update "Expected Behavior" table with policy-specific behaviors
- Add configuration examples for both modes
- Document use cases for strict mode in production/CI environments

add checksumPolicy=strict to examples

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Co-Authored-By: chrisrueger <188422+chrisrueger@users.noreply.github.com>
@chrisrueger
chrisrueger force-pushed the copilot/fix-trusted-checksums-failure branch from c6bf785 to f5fadb9 Compare October 30, 2026 06:28
@chrisrueger
chrisrueger marked this pull request as ready for review October 30, 2026 06:28

@peterkir peterkir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really useful security feature in zero-trust times!
Looks fine for me

This branch has not been deployed

No deployments
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.

Trusted Checksums should fail build on new dependencies which are not yet in .checksums file

3 participants