Skip to content

golangci: Disable gosec rules that don't apply to CLI tools#387

Merged
nirs merged 1 commit intoRamenDR:mainfrom
nirs:gosec-lints
Mar 4, 2026
Merged

golangci: Disable gosec rules that don't apply to CLI tools#387
nirs merged 1 commit intoRamenDR:mainfrom
nirs:gosec-lints

Conversation

@nirs
Copy link
Member

@nirs nirs commented Mar 4, 2026

After upgrading golangci-lint, gosec reports new errors that are false positives for this project:

G602 (slice bounds out of range):
Flagged in fingerprint.go where we iterate over a sha256 sum and index into a slice created with the same length. Gosec cannot prove the lengths match through static analysis. Since Go has runtime bounds checking, out of bounds access causes a panic with a clear stack trace rather than silent memory corruption. With good test coverage, this check adds noise without value.

G703 (path traversal via taint analysis):
Flagged in htmlfmt when reading/writing files from command line args. This rule is designed for web services where user input could escape a sandboxed directory. For CLI tools, the user can specify any path - this is the intended behavior, not a vulnerability.

G705 (XSS via taint analysis):
Flagged in htmlfmt when printing to stderr. This rule is designed for web services outputting HTML. Stderr is plain text, not rendered as HTML, so XSS is not possible. Disabled only for tools/ directory to keep XSS checks active for HTML report generation in pkg/.

After upgrading golangci-lint, gosec reports new errors that are false
positives for this project:

G602 (slice bounds out of range):
Flagged in fingerprint.go where we iterate over a sha256 sum and index
into a slice created with the same length. Gosec cannot prove the lengths
match through static analysis. Since Go has runtime bounds checking, out
of bounds access causes a panic with a clear stack trace rather than
silent memory corruption. With good test coverage, this check adds noise
without value.

G703 (path traversal via taint analysis):
Flagged in htmlfmt when reading/writing files from command line args.
This rule is designed for web services where user input could escape a
sandboxed directory. For CLI tools, the user can specify any path - this
is the intended behavior, not a vulnerability.

G705 (XSS via taint analysis):
Flagged in htmlfmt when printing to stderr. This rule is designed for
web services outputting HTML. Stderr is plain text, not rendered as HTML,
so XSS is not possible. Disabled only for tools/ directory to keep XSS
checks active for HTML report generation in pkg/.

Assisted-by: Cursor/Claude Opus 4.5
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
@nirs nirs requested a review from parikshithb March 4, 2026 10:53
@nirs nirs merged commit 0741c1e into RamenDR:main Mar 4, 2026
13 checks passed
@nirs nirs deleted the gosec-lints branch March 4, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants