Skip to content
Draft
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
4 changes: 2 additions & 2 deletions pkg/config/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
ContextOptionSSHAddPrivateKeys = "SSH_ADD_PRIVATE_KEYS"
ContextOptionGPGAgentForwarding = "GPG_AGENT_FORWARDING"
ContextOptionGitSSHSignatureForwarding = "GIT_SSH_SIGNATURE_FORWARDING"
ContextOptionSSHInjectDockerCredentials = "SSH_INJECT_DOCKER_CREDENTIALS"
ContextOptionSSHInjectGitCredentials = "SSH_INJECT_GIT_CREDENTIALS"
ContextOptionSSHInjectDockerCredentials = "SSH_INJECT_DOCKER_CREDENTIALS" //nolint:gosec // G101: context option name, not a credential

Check failure on line 13 in pkg/config/context.go

View workflow job for this annotation

GitHub Actions / Lint

The line is 136 characters long, which exceeds the maximum of 120 characters. (lll)
ContextOptionSSHInjectGitCredentials = "SSH_INJECT_GIT_CREDENTIALS" //nolint:gosec // G101: context option name, not a credential

Check failure on line 14 in pkg/config/context.go

View workflow job for this annotation

GitHub Actions / Lint

The line is 136 characters long, which exceeds the maximum of 120 characters. (lll)
ContextOptionExitAfterTimeout = "EXIT_AFTER_TIMEOUT"
ContextOptionTelemetry = "TELEMETRY"
ContextOptionAgentURL = "AGENT_URL"
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)
)

const tokenFileLocation = "/var/run/secrets/kubernetes.io/serviceaccount/token"
const tokenFileLocation = "/var/run/secrets/kubernetes.io/serviceaccount/token" //nolint:gosec // G101: projected service account token file path, not a credential

Check failure on line 27 in pkg/image/auth.go

View workflow job for this annotation

GitHub Actions / Lint

The line is 163 characters long, which exceeds the maximum of 120 characters. (lll)

// See https://github.com/kubernetes/kubernetes/blob/30ae12d018697d3c5f04e225b11f242f5310e097/pkg/serviceaccount/claims.go#L55
type privateClaims struct {
Expand Down
18 changes: 15 additions & 3 deletions pkg/random/random.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package random

import "math/rand"
import (
"crypto/rand"
"math/big"
)

var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz")

// String creates a new random string with the given length.
func String(length int) string {
b := make([]rune, length)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
b[i] = letterRunes[randInt(len(letterRunes))]
}
return string(b)
}
Expand All @@ -17,5 +20,14 @@
if max <= min {
return min
}
return rand.Intn(max-min) + min
return randInt(max-min) + min
}

// randInt returns a cryptographically secure random int in [0, max).
func randInt(max int) int {

Check notice on line 27 in pkg/random/random.go

View check run for this annotation

codefactor.io / CodeFactor

pkg/random/random.go#L27

Redefinition of the built-in function max. (redefines-builtin-id)
n, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
panic("crypto/rand failed: " + err.Error())
}
return int(n.Int64())
}
14 changes: 12 additions & 2 deletions pkg/util/rand.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package util

import (
"math/rand"
"crypto/rand"
"math/big"
)

const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

func RandStringBytes(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
b[i] = letterBytes[randInt(len(letterBytes))]
}
return string(b)
}

// randInt returns a cryptographically secure random int in [0, max).
func randInt(max int) int {

Check notice on line 19 in pkg/util/rand.go

View check run for this annotation

codefactor.io / CodeFactor

pkg/util/rand.go#L19

Redefinition of the built-in function max. (redefines-builtin-id)
n, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
panic("crypto/rand failed: " + err.Error())
}
return int(n.Int64())
}
Loading