Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sreya committed Nov 26, 2024
1 parent 52ba3d8 commit 925d772
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cli/cliflag/cliflag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ func TestCliflag(t *testing.T) {
flagset, name, shorthand, env, usage := randomFlag()
def, _ := cryptorand.Intn(10)

//nolint:gosec
cliflag.Uint8VarP(flagset, &ptr, name, shorthand, env, uint8(def), usage)
got, err := flagset.GetUint8(name)
require.NoError(t, err)
//nolint:gosec
require.Equal(t, uint8(def), got)
require.Contains(t, flagset.FlagUsages(), usage)
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf("Consumes $%s", env))
Expand All @@ -125,12 +127,14 @@ func TestCliflag(t *testing.T) {
var ptr uint8
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.Intn(10)
//nolint:gosec
t.Setenv(env, strconv.FormatUint(uint64(envValue), 10))
def, _ := cryptorand.Intn(10)

cliflag.Uint8VarP(flagset, &ptr, name, shorthand, env, uint8(def), usage)

Check failure on line 134 in cli/cliflag/cliflag_test.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion int -> uint8 (gosec)
got, err := flagset.GetUint8(name)
require.NoError(t, err)
//nolint:gosec
require.Equal(t, uint8(envValue), got)
})

Expand All @@ -141,9 +145,11 @@ func TestCliflag(t *testing.T) {
t.Setenv(env, envValue)
def, _ := cryptorand.Intn(10)

//nolint:gosec
cliflag.Uint8VarP(flagset, &ptr, name, shorthand, env, uint8(def), usage)
got, err := flagset.GetUint8(name)
require.NoError(t, err)
//nolint:gosec
require.Equal(t, uint8(def), got)
})

Expand All @@ -164,6 +170,7 @@ func TestCliflag(t *testing.T) {
var ptr int
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.Intn(10)
//nolint:gosec
t.Setenv(env, strconv.FormatUint(uint64(envValue), 10))
def, _ := cryptorand.Intn(10)

Expand Down
1 change: 1 addition & 0 deletions dockerutil/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func mustNextIPv4(ip net.IP, inc int) net.IP {
v += uint32(ip4[1]) << 16
v += uint32(ip4[2]) << 8
v += uint32(ip4[3])
//nolint:gosec
v += uint32(inc)
v3 := byte(v & 0xFF)
v2 := byte((v >> 8) & 0xFF)
Expand Down
1 change: 1 addition & 0 deletions xunix/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func createDevice(ctx context.Context, conf deviceConfig) error {
return xerrors.Errorf("ensure parent dir: %w", err)
}

//nolint:gosec
err = fs.Mknod(conf.path, conf.ftype|conf.mode, int(conf.dev))
if err != nil {
return xerrors.Errorf("mknod %s c %d %d: %w", conf.path, conf.major, conf.minor, err)
Expand Down

0 comments on commit 925d772

Please sign in to comment.