Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
63d8b58
test: add slog shim
hdonnay Oct 1, 2025
8b628a0
test: migrate to slog
hdonnay Oct 2, 2025
f8284e4
alpine: migrate to slog
hdonnay Mar 25, 2025
7b05cbd
apk: migrate to slog
hdonnay Oct 1, 2025
5ccb674
aws: migrate to slog
hdonnay Oct 2, 2025
97aaeb8
debian: migrate to slog
hdonnay Oct 2, 2025
d7ef73b
test/rhel: migrate to slog
hdonnay Oct 2, 2025
4f29725
test/periodic: migrate to slog
hdonnay Oct 2, 2025
0d556cd
test/bisect: migrate to slog
hdonnay Oct 2, 2025
d204fa9
internal/dnf: migrate to slog
hdonnay Oct 2, 2025
13c3c09
internal/matcher: migrate to slog
hdonnay Oct 2, 2025
5a45d00
internal/rpm/bdb: migrate to slog
hdonnay Oct 2, 2025
a0f3ae8
internal/rpm/ndb: migrate to slog
hdonnay Oct 2, 2025
1bde3ae
internal/rpm/rpmdb: migrate to slog
hdonnay Oct 2, 2025
6ee1f92
internal/rpm/sqlite: migrate to slog
hdonnay Oct 2, 2025
426a8ae
internal/rpm: migrate to slog
hdonnay Oct 2, 2025
c0a042d
datastore/postgres: migrate to slog
hdonnay Oct 2, 2025
9f762ae
libvuln/updates: migrate to slog
hdonnay Oct 2, 2025
7cdf1fa
libvuln: migrate to slog
hdonnay Oct 2, 2025
4cd4133
indexer/controller: migrate to slog
hdonnay Oct 2, 2025
6cedab7
pkg/ctxlock/v2: migrate to slog
hdonnay Oct 3, 2025
f02a138
indexer: migrate to slog
hdonnay Oct 3, 2025
d302572
rhel/internal/common: migrate to slog
hdonnay Oct 3, 2025
860efaa
rhel/vex: migrate to slog
hdonnay Oct 3, 2025
39aa522
rhel/rhcc: migrate to slog
hdonnay Oct 3, 2025
b940c70
rhel: migrate to slog
hdonnay Oct 3, 2025
b0c3bfb
test/rpmtest: migrate to slog
hdonnay Oct 2, 2025
e5aee15
java/jar: migrate to slog
hdonnay Oct 3, 2025
9d036db
java: migrate to slog
hdonnay Oct 3, 2025
963162b
docs: migrate to slog
hdonnay Oct 6, 2025
679412c
dpkg: migrate to slog
hdonnay Oct 6, 2025
2713795
gobin: migrate to slog
hdonnay Oct 6, 2025
851d145
libindex: migrate to slog
hdonnay Oct 6, 2025
575f98e
linux: migrate to slog
hdonnay Oct 6, 2025
fb1ce00
matchers: migrate to slog
hdonnay Oct 6, 2025
90521c1
nodejs: migrate to slog
hdonnay Oct 6, 2025
676e9a7
oracle: migrate to slog
hdonnay Oct 6, 2025
ec95a89
osrelease: migrate to slog
hdonnay Oct 6, 2025
f3a0335
photon: migrate to slog
hdonnay Oct 6, 2025
82ff529
python: migrate to slog
hdonnay Oct 6, 2025
5c2b885
rpm: migrate to slog
hdonnay Oct 6, 2025
69b9048
ruby: migrate to slog
hdonnay Oct 6, 2025
8bc9c8b
suse: migrate to slog
hdonnay Oct 6, 2025
50ff13d
ubuntu: migrate to slog
hdonnay Oct 6, 2025
85724f0
updater/osv: migrate to slog
hdonnay Oct 8, 2025
03773c7
pkg/ovalutil: migrate to slog
hdonnay Oct 8, 2025
fc5cb6b
scanner/pkgconfig: migrate to slog
hdonnay Oct 8, 2025
727cd8e
whiteout: migrate to slog
hdonnay Oct 8, 2025
32d0dff
updater: migrate to slog
hdonnay Oct 9, 2025
c5365b5
enricher/cvss: migrate to slog
hdonnay Oct 9, 2025
71986cc
enricher/epss: migrate to slog
hdonnay Oct 9, 2025
616f8b4
enricher/kev: migrate to slog
hdonnay Oct 9, 2025
abae1b4
sbom/spdx: migrate to slog
hdonnay Jan 5, 2026
28be6dc
test: remove zlog
hdonnay Oct 9, 2025
47d1ece
go.mod: remove zlog
hdonnay Oct 31, 2025
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
27 changes: 12 additions & 15 deletions alpine/distributionscanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (
"errors"
"fmt"
"io/fs"
"log/slog"
"regexp"
"runtime/trace"
"strings"

"github.com/quay/zlog"

"github.com/quay/claircore"
"github.com/quay/claircore/indexer"
"github.com/quay/claircore/osrelease"
Expand Down Expand Up @@ -61,12 +60,10 @@ func (*DistributionScanner) Kind() string { return scannerKind }
// If the files are found but all regexp fail to match an empty slice is returned.
func (s *DistributionScanner) Scan(ctx context.Context, l *claircore.Layer) ([]*claircore.Distribution, error) {
defer trace.StartRegion(ctx, "Scanner.Scan").End()
ctx = zlog.ContextWithValues(ctx,
"component", "alpine/DistributionScanner.Scan",
slog.DebugContext(ctx, "start",
"version", s.Version(),
"layer", l.Hash.String())
zlog.Debug(ctx).Msg("start")
defer zlog.Debug(ctx).Msg("done")
defer slog.DebugContext(ctx, "done")
sys, err := l.FS()
if err != nil {
return nil, fmt.Errorf("alpine: unable to open layer: %w", err)
Expand Down Expand Up @@ -102,13 +99,13 @@ func readOSRelease(ctx context.Context, sys fs.FS) (*claircore.Distribution, err
return nil, err
}
if id := m[`ID`]; id != `alpine` {
zlog.Debug(ctx).Str("id", id).Msg("seemingly not alpine")
slog.DebugContext(ctx, "seemingly not alpine", "id", id)
break
}
vid := m[`VERSION_ID`]
idx := strings.LastIndexByte(vid, '.')
if idx == -1 {
zlog.Debug(ctx).Str("val", vid).Msg("martian VERSION_ID")
slog.DebugContext(ctx, "martian VERSION_ID", "val", vid)
break
}
v := vid[:idx]
Expand All @@ -126,9 +123,9 @@ func readOSRelease(ctx context.Context, sys fs.FS) (*claircore.Distribution, err
PrettyName: m[`PRETTY_NAME`],
}, nil
case errors.Is(err, fs.ErrNotExist):
zlog.Debug(ctx).
Str("path", osrelease.Path).
Msg("file doesn't exist")
slog.DebugContext(ctx,
"file doesn't exist",
"path", osrelease.Path)
default:
return nil, err
}
Expand All @@ -153,7 +150,7 @@ func readIssue(ctx context.Context, sys fs.FS) (*claircore.Distribution, error)

ms := issueRegexp.FindSubmatch(b)
if ms == nil {
zlog.Debug(ctx).Msg("seemingly not alpine")
slog.DebugContext(ctx, "seemingly not alpine")
break
}
v := string(ms[1])
Expand All @@ -164,9 +161,9 @@ func readIssue(ctx context.Context, sys fs.FS) (*claircore.Distribution, error)
PrettyName: fmt.Sprintf(`Alpine Linux v%s`, v),
}, nil
case errors.Is(err, fs.ErrNotExist):
zlog.Debug(ctx).
Str("path", issuePath).
Msg("file doesn't exist")
slog.DebugContext(ctx,
"file doesn't exist",
"path", issuePath)
default:
return nil, err
}
Expand Down
6 changes: 2 additions & 4 deletions alpine/distributionscanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/quay/zlog"

"github.com/quay/claircore"
"github.com/quay/claircore/test"
)

func TestScanFs(t *testing.T) {
ctx := context.Background()
ctx = zlog.Test(ctx, t)
ctx := test.Logging(t)

td := os.DirFS("testdata")
ms, err := fs.Glob(td, "3.*")
Expand Down Expand Up @@ -46,7 +45,6 @@ func scanFsTestcase(ctx context.Context, sys fs.FS) func(*testing.T) {
if err != nil {
t.Fatal(err)
}
ctx := zlog.Test(ctx, t)
got, err := s.scanFs(ctx, sys)
if err != nil {
t.Error(err)
Expand Down
35 changes: 17 additions & 18 deletions alpine/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@ import (
"context"
"fmt"
"io"
"log/slog"
"net/http"

"github.com/quay/zlog"

"github.com/quay/claircore/libvuln/driver"
"github.com/quay/claircore/pkg/tmp"
)

func (u *updater) Fetch(ctx context.Context, hint driver.Fingerprint) (io.ReadCloser, driver.Fingerprint, error) {
ctx = zlog.ContextWithValues(ctx, "component", "alpine/Updater.Fetch")

zlog.Info(ctx).Str("database", u.url).Msg("starting fetch")
slog.InfoContext(ctx, "starting fetch", "database", u.url)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.url, nil)
if err != nil {
return nil, hint, fmt.Errorf("alpine: unable to construct request: %w", err)
}

if hint != "" {
zlog.Debug(ctx).
Str("hint", string(hint)).
Msg("using hint")
slog.DebugContext(ctx,
"using hint",
"hint", string(hint))
req.Header.Set("if-none-match", string(hint))
}

Expand All @@ -41,25 +38,27 @@ func (u *updater) Fetch(ctx context.Context, hint driver.Fingerprint) (io.ReadCl
}
fallthrough
case http.StatusNotModified:
zlog.Info(ctx).Msg("database unchanged since last fetch")
slog.InfoContext(ctx, "database unchanged since last fetch")
return nil, hint, driver.Unchanged
default:
return nil, hint, fmt.Errorf("alpine: http response error: %s %d", res.Status, res.StatusCode)
}
zlog.Debug(ctx).Msg("successfully requested database")
slog.DebugContext(ctx, "successfully requested database")

tf, err := tmp.NewFile("", u.Name()+".")
if err != nil {
return nil, hint, fmt.Errorf("alpine: unable to open tempfile: %w", err)
}
zlog.Debug(ctx).
Str("name", tf.Name()).
Msg("created tempfile")
slog.DebugContext(ctx,
"created tempfile",
"name", tf.Name())
var success bool
defer func() {
if !success {
if err := tf.Close(); err != nil {
zlog.Warn(ctx).Err(err).Msg("unable to close spool")
slog.WarnContext(ctx,
"unable to close spool",
"reason", err)
}
}
}()
Expand All @@ -71,13 +70,13 @@ func (u *updater) Fetch(ctx context.Context, hint driver.Fingerprint) (io.ReadCl
if n, err := tf.Seek(0, io.SeekStart); err != nil || n != 0 {
return nil, hint, fmt.Errorf("alpine: unable to seek database to start: at %d, %v", n, err)
}
zlog.Debug(ctx).Msg("decompressed and buffered database")
slog.DebugContext(ctx, "decompressed and buffered database")

success = true
hint = driver.Fingerprint(res.Header.Get("etag"))
zlog.Debug(ctx).
Str("hint", string(hint)).
Msg("using new hint")
slog.DebugContext(ctx,
"using new hint",
"hint", string(hint))

return tf, hint, nil
}
7 changes: 4 additions & 3 deletions alpine/fetcher_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package alpine

import (
"context"
"net/http"
"net/http/httptest"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/quay/zlog"

"github.com/quay/claircore/test"
)

func serveSecDB(t *testing.T) (string, *http.Client) {
Expand All @@ -17,7 +17,8 @@ func serveSecDB(t *testing.T) (string, *http.Client) {
}

func TestFactory(t *testing.T) {
ctx := zlog.Test(context.Background(), t)
ctx := test.Logging(t)

root, c := serveSecDB(t)
fac := &Factory{}
err := fac.Configure(ctx, func(v any) error {
Expand Down
7 changes: 3 additions & 4 deletions alpine/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"context"
"encoding/json"
"io"

"github.com/quay/zlog"
"log/slog"

"github.com/quay/claircore"
"github.com/quay/claircore/libvuln/driver"
Expand All @@ -18,8 +17,8 @@ const (
var _ driver.Parser = (*updater)(nil)

func (u *updater) Parse(ctx context.Context, r io.ReadCloser) ([]*claircore.Vulnerability, error) {
ctx = zlog.ContextWithValues(ctx, "component", "alpine/Updater.Parse")
zlog.Info(ctx).Msg("starting parse")
slog.InfoContext(ctx, "parse start")
defer slog.InfoContext(ctx, "parse done")
defer r.Close()

var db SecurityDB
Expand Down
9 changes: 5 additions & 4 deletions alpine/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/quay/zlog"

"github.com/quay/claircore"
"github.com/quay/claircore/test"
)

var dist310 = stableRelease{3, 10}.Distribution()
Expand Down Expand Up @@ -128,8 +128,8 @@ var v3_10CommunityTruncatedVulns = []*claircore.Vulnerability{

func TestParser(t *testing.T) {
t.Parallel()
ctx := context.Background()
var table = []struct {
ctx := test.Logging(t)
table := []struct {
release release
repo string
testFile string
Expand All @@ -145,7 +145,8 @@ func TestParser(t *testing.T) {

for _, test := range table {
t.Run(test.testFile, func(t *testing.T) {
ctx := zlog.Test(ctx, t)
ctx, done := context.WithCancel(ctx)
t.Cleanup(done)

path := fmt.Sprintf("testdata/%s", test.testFile)
f, err := os.Open(path)
Expand Down
2 changes: 1 addition & 1 deletion alpine/secdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var v3_10CommunityTruncatedSecDB = SecurityDB{
}

func TestSecDBParse(t *testing.T) {
var table = []struct {
table := []struct {
testFile string
expected SecurityDB
}{
Expand Down
Loading
Loading