build: use consistent length for project build ID #456
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
git describe returns a SHA1 of variable length depending on the number
of objects in a git repository
https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1
For example, at time of writing bottlerocket-kernel-kit returns a SHA1
with a length of 7, whereas the bottlerocket-core-kit returns a SHA1 of
length 8. This is due to the bottlerocket-kernel-kit having a much
smaller git history than the core-kit (or bottlerocket-os/bottlerocket)
the build ID is used in application inventory generation. Application
inventory is used by various software to evaluate vulnerability
applicability along with Bottlerocket's updateinfo.xml. The build ID
length being non-deterministic resulted in inconsistencies for
comparisons between the updateinfo.xml generated by Bottlerocket and the
application inventory embedded into Bottlerocket AMIs.
This commit sets a consistent length of 8 for commits returned by git
describe and used as project build ID. This is done for
historical purposes given advisories published to
https://advisories.bottlerocket.aws/updateinfo.xml.gz have been
referenced with their build ID.
Testing done:
cargo test
Run
git describe --always --dirty --exclude '*' --abbrev=8
in various git reposTerms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.