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

Bump go apk and redact URLs in config YAML marshaling #1141

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.3

require (
github.com/chainguard-dev/clog v1.3.1
github.com/chainguard-dev/go-apk v0.0.0-20240529143655-d11a334256b3
github.com/chainguard-dev/go-apk v0.0.0-20240529154108-3de67a94ddad
github.com/charmbracelet/log v0.4.0
github.com/dominodatalab/os-release v0.0.0-20190522011736-bcdb4a3e3c2f
github.com/go-git/go-git/v5 v5.12.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chainguard-dev/clog v1.3.1 h1:CDNCty5WKQhJzoOPubk0GdXt+bPQyargmfClqebrpaQ=
github.com/chainguard-dev/clog v1.3.1/go.mod h1:cV516KZWqYc/phZsCNwF36u/KMGS+Gj5Uqeb8Hlp95Y=
github.com/chainguard-dev/go-apk v0.0.0-20240529143655-d11a334256b3 h1:fIKTpUNkAhfoo4ecuXhmnUdrUQlf/+zFfqC1KHmoJ78=
github.com/chainguard-dev/go-apk v0.0.0-20240529143655-d11a334256b3/go.mod h1:4UVB5GXk5yVOVwe3QPdmMLMVTpYbvzygjXlRrJxJPMc=
github.com/chainguard-dev/go-apk v0.0.0-20240529154108-3de67a94ddad h1:MweFfBg9pmE4X+3SdlqJy3SVwbm3XEOze94IkXb3uwY=
github.com/chainguard-dev/go-apk v0.0.0-20240529154108-3de67a94ddad/go.mod h1:4UVB5GXk5yVOVwe3QPdmMLMVTpYbvzygjXlRrJxJPMc=
github.com/charmbracelet/lipgloss v0.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s=
github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE=
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=
Expand Down
28 changes: 28 additions & 0 deletions pkg/build/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package types

import (
"fmt"
"net/url"
"runtime"
"sort"

Expand Down Expand Up @@ -95,6 +96,33 @@ type ImageContents struct {
BaseImage *BaseImageDescriptor `json:"baseimage,omitempty" yaml:"baseimage,omitempty"`
}

// MarshalYAML implements yaml.Marshaler for ImageContents, redacting URLs in
// the ImageContents struct fields.
func (i ImageContents) MarshalYAML() (interface{}, error) {
type redactedImageContents ImageContents
ri := redactedImageContents(i)

for idx, repo := range ri.Repositories {
rawURL := repo
parsed, err := url.Parse(rawURL)
if err != nil {
return nil, fmt.Errorf("parsing repository URL: %w", err)
}
ri.Repositories[idx] = parsed.Redacted()
}

for idx, key := range ri.Keyring {
rawURL := key
parsed, err := url.Parse(rawURL)
if err != nil {
return nil, fmt.Errorf("parsing public key URL: %w", err)
}
ri.Keyring[idx] = parsed.Redacted()
}

return ri, nil
}

type ImageEntrypoint struct {
// Optional: The type of entrypoint. Only "service-bundle" is supported.
Type string `json:"type,omitempty"`
Expand Down
Loading