Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-5.26] Backport #2547

Merged
merged 9 commits into from
Sep 4, 2024
Merged

Commits on Aug 30, 2024

  1. Fix TestOCI1IndexChooseInstanceByCompression on non-amd64

    Setting SystemContext.ArchitectureChoice to "" does not mean "match any/the first platform";
    it's the default behavior of SystemContext, and it means "choose for the current runtime
    architecture". (Originally discussed in
    containers#1789 (comment) )
    
    I.e. on amd64 these two test cases are redundant with the first two instances above,
    and on other architectures (notably ARM) they cause failures.
    
    So just drop them.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    a65cb25 View commit details
    Browse the repository at this point in the history
  2. Use a reasonably unique context key type

    This makes the test a tiny bit more realistic, and avoids
    a linter warning.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    525014b View commit details
    Browse the repository at this point in the history
  3. Validate digests before using them

    If doing it makes sense at all, it should happen before
    the values are used.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    0024e3a View commit details
    Browse the repository at this point in the history
  4. Call .Validate() before digest.Hex() / digest.Encoded()

    ... to prevent panics if the value does not contain a :, or other unexpected
    values (e.g. a path traversal).
    
    Don't bother on paths where we computed the digest ourselves, or it is already trusted
    for other reasons.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    4c27d4c View commit details
    Browse the repository at this point in the history
  5. Refactor the error handling path of saveStream

    Use defer() to remove the temporary file, instead
    of duplicating the call.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    7ad9240 View commit details
    Browse the repository at this point in the history
  6. Refactor the error handling further

    Use defer, a nested function, and early returns.
    
    Besides being a bit more directly related to what
    we want to achieve, this now does not call decompressed.Close()
    on a nil value if DecompressStream fails.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    4746460 View commit details
    Browse the repository at this point in the history
  7. Call .Validate() before digest.Digest.String() if necessary

    ... to prevent unexpected behavior on invalid values.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    87da25f View commit details
    Browse the repository at this point in the history
  8. Validate the tags returned by a registry

    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    e477fa1 View commit details
    Browse the repository at this point in the history
  9. Don't abort listing tags when we encounter a digest

    Per containers/skopeo#2346, that happens
    in the wild.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
    mtrmac committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    097fa04 View commit details
    Browse the repository at this point in the history