-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
mutate
constructs immutable. (#1124)
I noticed that `cosign` was taking advantage of a bug in the mutate package where the `Manifest()` returns a mutable copy of it's internal state, which allowed them to permanently alter the result of `Manifest()`. This mutability violates the philosophy of our abstractions, and should not be allowed, so this change ensures that each of the methods returning state in the `mutate` package return a `.DeepCopy()` instead. In `image` this included the `configFile`, and `manifest`. In `index` this included the `indexManifest`. I have added tests that when the returned copies are mutated, a subsequent invocation of the getter will return a pristine copy. Since I'm not completely heartless, I am also adding a new `mutate.ConfigMediaType` method to enable `cosign` to perform the alteration they want, now that the trick they were using will no longer work. Related: sigstore/cosign#718
- Loading branch information
Showing
6 changed files
with
119 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters