Skip to content

Commit

Permalink
Ignore a couple of new gosec lints
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Sep 13, 2024
1 parent 7ba2584 commit 2421e70
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions mmdbtype/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (t Int32) Equal(other DataType) bool {
}

func (t Int32) size() int {
//nolint:gosec // this is correct.
return 4 - bits.LeadingZeros32(uint32(t))/8
}

Expand Down
2 changes: 2 additions & 0 deletions mmdbtype/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ func TestUint128(t *testing.T) {
}
for i := 1; i <= bits/8; i++ {
expected := &big.Int{}

//nolint:gosec // i is positive.
expected.Lsh(big.NewInt(1), 8*uint(i))
expected = expected.Sub(expected, big.NewInt(1))
input := hex.EncodeToString([]byte{byte(i)}) + ctrlByte + strings.Repeat("ff", i)
Expand Down
10 changes: 7 additions & 3 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,9 +656,13 @@ func (t *Tree) writeMetadata(dw *dataWriter) (int64, error) {
metadata := mmdbtype.Map{
"binary_format_major_version": mmdbtype.Uint16(2),
"binary_format_minor_version": mmdbtype.Uint16(0),
"build_epoch": mmdbtype.Uint64(t.buildEpoch),
"database_type": mmdbtype.String(t.databaseType),
"description": description,

// Although it might make sense to change the type on this, there is no use
// case where someone would reasonably pass a negative build epoch.
//nolint:gosec // See above.
"build_epoch": mmdbtype.Uint64(t.buildEpoch),
"database_type": mmdbtype.String(t.databaseType),
"description": description,
//nolint:gosec // no risk. Will be 4 or 6.
"ip_version": mmdbtype.Uint16(t.ipVersion),
"languages": languages,
Expand Down

0 comments on commit 2421e70

Please sign in to comment.