Skip to content

Commit aeae19a

Browse files
committed
chore: disable gosec(G115)
A change to the rule gosec(G115) made a large amount of FP for gosec appear when updating to the latest golang-ci linter. securego/gosec#1185 securego/gosec#1149 We're going to ignore this rule for the time being while waiting for gosec to get updates so that bound checking and example snippets of `valid` code is added for this rule Signed-off-by: Christopher Phillips <[email protected]>
1 parent 9486b7c commit aeae19a

File tree

8 files changed

+15
-12
lines changed

8 files changed

+15
-12
lines changed

.golangci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ linters-settings:
5757
settings:
5858
ruleguard:
5959
rules: "test/rules/rules.go"
60+
gosec:
61+
excludes:
62+
- G115
6063
output:
6164
uniq-by-line: false
6265
run:

internal/file/zip_read_closer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func OpenZip(filepath string) (*ZipReadCloser, error) {
5656
if offset > math.MaxInt64 {
5757
return nil, fmt.Errorf("archive start offset too large: %v", offset)
5858
}
59-
offset64 := int64(offset) //nolint:gosec // lint bug, checked above: https://github.com/securego/gosec/issues/1187
59+
offset64 := int64(offset)
6060

6161
size := fi.Size() - offset64
6262

@@ -183,7 +183,7 @@ func findDirectory64End(r io.ReaderAt, directoryEndOffset int64) (int64, error)
183183
if b.uint32() != 1 { // total number of disks
184184
return -1, nil // the file is not a valid zip64-file
185185
}
186-
return int64(p), nil //nolint:gosec
186+
return int64(p), nil
187187
}
188188

189189
// readDirectory64End reads the zip64 directory end and updates the

syft/file/cataloger/executable/elf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func hasElfDynTag(f *elf.File, tag elf.DynTag) bool {
175175
t = elf.DynTag(f.ByteOrder.Uint32(d[0:4]))
176176
d = d[8:]
177177
case elf.ELFCLASS64:
178-
t = elf.DynTag(f.ByteOrder.Uint64(d[0:8])) //nolint:gosec
178+
t = elf.DynTag(f.ByteOrder.Uint64(d[0:8]))
179179
d = d[16:]
180180
}
181181
if t == tag {

syft/format/syftjson/to_syft_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func safeFileModeConvert(val int) (fs.FileMode, error) {
146146
if err != nil {
147147
return 0, err
148148
}
149-
return os.FileMode(mode), nil //nolint:gosec
149+
return os.FileMode(mode), nil
150150
}
151151

152152
func toSyftLicenses(m []model.License) (p []pkg.License) {

syft/pkg/cataloger/debian/parse_dpkg_db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func handleNewKeyValue(line string) (key string, val interface{}, err error) {
230230
if err != nil {
231231
return "", nil, fmt.Errorf("bad installed-size value=%q: %w", val, err)
232232
}
233-
return key, int(s), nil //nolint:gosec
233+
return key, int(s), nil
234234
default:
235235
return key, val, nil
236236
}

syft/pkg/cataloger/java/graalvm_native_image_cataloger.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func newPE(filename string, r io.ReaderAt) (nativeImage, error) {
268268
}
269269
exportSymbolsOffset := uint64(exportSymbolsDataDirectory.VirtualAddress)
270270
exports := make([]byte, exportSymbolsDataDirectory.Size)
271-
_, err = r.ReadAt(exports, int64(exportSymbolsOffset)) //nolint:gosec
271+
_, err = r.ReadAt(exports, int64(exportSymbolsOffset))
272272
if err != nil {
273273
return fileError(filename, fmt.Errorf("could not read the exported symbols data directory: %w", err))
274274
}
@@ -412,7 +412,7 @@ func (ni nativeImagePE) fetchExportAttribute(i int) (uint32, error) {
412412
func (ni nativeImagePE) fetchExportFunctionPointer(functionsBase uint32, i uint32) (uint32, error) {
413413
var pointer uint32
414414

415-
n := uint32(len(ni.exports)) //nolint:gosec
415+
n := uint32(len(ni.exports))
416416
sz := uint32(unsafe.Sizeof(ni.t.functionPointer))
417417
j := functionsBase + i*sz
418418
if j+sz >= n {
@@ -457,7 +457,7 @@ func (ni nativeImagePE) fetchSbomSymbols(content *exportContentPE) {
457457
sbomBytes := []byte(nativeImageSbomSymbol + "\x00")
458458
sbomLengthBytes := []byte(nativeImageSbomLengthSymbol + "\x00")
459459
svmVersionInfoBytes := []byte(nativeImageSbomVersionSymbol + "\x00")
460-
n := uint32(len(ni.exports)) //nolint:gosec
460+
n := uint32(len(ni.exports))
461461

462462
// Find SBOM, SBOM Length, and SVM Version Symbol
463463
for i := uint32(0); i < content.numberOfNames; i++ {

syft/pkg/cataloger/php/parse_pecl_serialized.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ func readStruct(metadata any, fields ...string) string {
6060
if len(fields) > 0 {
6161
value, ok := metadata.(map[any]any)
6262
if !ok {
63-
log.Tracef("unable to read '%s' from: %v", fields[0], metadata) //nolint:gosec
63+
log.Tracef("unable to read '%s' from: %v", fields[0], metadata)
6464
return ""
6565
}
66-
return readStruct(value[fields[0]], fields[1:]...) //nolint:gosec
66+
return readStruct(value[fields[0]], fields[1:]...)
6767
}
6868
value, ok := metadata.(string)
6969
if !ok {

syft/pkg/cataloger/redhat/parse_rpm_archive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ func mapFiles(files []rpmutils.FileInfo, digestAlgorithm string) []pkg.RpmFileRe
8888
}
8989
out = append(out, pkg.RpmFileRecord{
9090
Path: f.Name(),
91-
Mode: pkg.RpmFileMode(f.Mode()), //nolint:gosec
91+
Mode: pkg.RpmFileMode(f.Mode()),
9292
Size: int(f.Size()),
9393
Digest: digest,
9494
UserName: f.UserName(),
9595
GroupName: f.GroupName(),
96-
Flags: rpmdb.FileFlags(f.Flags()).String(), //nolint:gosec
96+
Flags: rpmdb.FileFlags(f.Flags()).String(),
9797
})
9898
}
9999
return out

0 commit comments

Comments
 (0)