Skip to content

fix(G110): track decompression readers declared with var - #1852

Open
VISHNU0906 wants to merge 1 commit into
securego:masterfrom
VISHNU0906:fix/g110-var-decl-readers
Open

VISHNU0906 wants to merge 1 commit into
securego:masterfrom
VISHNU0906:fix/g110-var-decl-readers

Conversation

@VISHNU0906

Copy link
Copy Markdown
Contributor

G110 tracks decompression readers created with := or =, but not ones declared with var, so this gives no finding:

var r, err = gzip.NewReader(f)
...
data, err := io.ReadAll(r)

This adds *ast.ValueSpec to the nodes G110 visits and records the declared variable the same way as an assignment. The assignment and declaration paths now share one small helper.

Tests: three new G110 samples. var r, gzErr = gzip.NewReader(f) with io.ReadAll(r) and var r = flate.NewReader(&buf) with io.Copy are flagged; the same var reader behind io.LimitReader is not. The two positive samples fail with the rule change reverted. make test passes on Go 1.26.11 and 1.27.4, make test-coverage (go test -race ./...) passes, golangci-lint run (v2.15.0) reports 0 issues and the taint benchmark guard passes.

@VISHNU0906
VISHNU0906 deployed to security-review November 30, 2026 14:50 — with GitHub Actions Active
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.35%. Comparing base (d33c626) to head (f713c24).

Files with missing lines Patch % Lines
rules/decompression_bomb.go 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1852      +/-   ##
==========================================
- Coverage   86.35%   86.35%   -0.01%     
==========================================
  Files         112      112              
  Lines        9805     9812       +7     
==========================================
+ Hits         8467     8473       +6     
- Misses       1338     1339       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch was successfully deployed

1 active deployment
security-review — f713c247 Deployed Nov 30, 2026 by VISHNU0906 via barry-ai-security-review #2907
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.

1 participant