You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add expected-commit verification to git sources
This commit implements the feature requested in issue #1895, adding
an optional `expected-commit` field to git source configurations.
Changes:
- Added `expected_commit` field to GitSource struct in source.rs
- Added GitCommitMismatch error variant to SourceError enum for
structured error handling with expected, actual, and rev fields
- Implemented verification logic in git_source.rs to compare actual
commit against expected commit after checkout
- Added comprehensive unit tests for serialization/deserialization
- Added integration tests for both success and failure cases
- Created test recipe demonstrating the feature
- Updated documentation in recipe_file.md with usage examples
The feature helps ensure security and reproducibility by detecting
when a git tag or branch has been moved to point to a different
commit than expected. Inspired by Wolfi/Melange.
Closes#1895
Copy file name to clipboardExpand all lines: docs/reference/recipe_file.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,6 +246,19 @@ source:
246
246
lfs: true # note: defaults to false
247
247
```
248
248
249
+
##### Verifying commit hash with `expected-commit`
250
+
251
+
For security and reproducibility, you can specify an `expected-commit` field to verify that the checked out commit matches the expected SHA hash. This is useful to detect if a tag or branch has been moved to point to a different commit:
If the actual commit does not match the expected commit, the build will fail with an error message indicating the mismatch. This feature is inspired by [Wolfi/Melange](https://github.com/wolfi-dev/wolfi-os) and provides an additional layer of security for your builds.
261
+
249
262
#### Source from a local path
250
263
251
264
If the path is relative, it is taken relative to the recipe directory. The
0 commit comments