Skip to content

fix: G118: Goroutine uses context.Background/TODO (gosec)#6666

Draft
thaJeztah wants to merge 2 commits into
moby:masterfrom
thaJeztah:fix_gosec_G118
Draft

fix: G118: Goroutine uses context.Background/TODO (gosec)#6666
thaJeztah wants to merge 2 commits into
moby:masterfrom
thaJeztah:fix_gosec_G118

Conversation

@thaJeztah

Copy link
Copy Markdown
Member
cache/manager.go:238:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
        go link.Release(context.TODO())
        ^
cache/refs.go:1519:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
    go func() {
    ^
session/testutil/testutil.go:22:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
        go func() {
        ^
solver/edge.go:975:4: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
            go results[i].Release(context.TODO())
            ^
util/leaseutil/manager.go:79:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
    go l.Discard()
    ^

Comment thread cache/blobs.go Outdated
defer func() {
if err != nil {
l.Discard()
_ = l.Discard(ctx)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defers should not use original context

Comment thread util/leaseutil/manager.go
func (l *LeaseRef) Discard() error {
return l.lm.Delete(context.Background(), l.l)
func (l *LeaseRef) Discard(ctx context.Context) error {
return l.lm.Delete(context.WithoutCancel(ctx), l.l)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This WithoutCancel should not be added in Discard

    cache/manager.go:238:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
            go link.Release(context.TODO())
            ^
    cache/refs.go:1519:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
        go func() {
        ^
    session/testutil/testutil.go:22:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
            go func() {
            ^
    solver/edge.go:975:4: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
                go results[i].Release(context.TODO())
                ^
    util/leaseutil/manager.go:79:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
        go l.Discard()
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
    client/build_test.go:2363:14: SA1019: proxy.Director has been deprecated since Go 1.26 and an alternative has been available since Go 1.20: Use Rewrite instead. (staticcheck)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants