Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

False positive G307: Deferring unsafe method "Close" on type "*os.File" (gosec) linting error #70

@atc0005

Description

@atc0005

These linting errors were surfaced from an upgraded golangci-lint:

activefile/activefile.go:141:2: G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
	defer func() {
		if err := f.Close(); err != nil {
			// Ignore "file already closed" errors
			if !errors.Is(err, os.ErrClosed) {
				ezproxy.Logger.Printf(
					"filterEntries: failed to close file %q: %s",
					afr.Filename,
					err.Error(),
				)
			}
		}
	}()
auditlog/auditlog.go:164:2: G307: Deferring unsafe method "Close" on type "*os.File" (gosec)
	defer func() {
		if err := f.Close(); err != nil {
			// Ignore "file already closed" errors
			if !errors.Is(err, os.ErrClosed) {
				ezproxy.Logger.Printf(
					"AllSessionEntries: failed to close file %q: %s",
					alr.Filename,
					err.Error(),
				)
			}
		}
	}()
make: *** [Makefile:67: linting] Error 1

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglinting

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions