Repository navigation
fix(security): mark the parseJSON-filled extracted map as a reviewed Semgrep false positive - #788
Conversation
…Semgrep false positive Semgrep's trailofbits.go.iterate-over-empty-map flags the range over extracted in unwrapParseLine, but plan.parseJSON fills the map before the loop. Mark the declaration with an inline nosemgrep and the reason, like the repository's other reviewed Semgrep exceptions. No behaviour change.
⚪ Performance A/B: no change beyond noise65 shape×range — 65 ⚪ same · results vs Loki: 51 same, 0 new difference(s), 14 pre-existing Every shape is within noise of the base build (±30% and 100 ms). 65 unchanged shape×range (within noise)
Cold (first-run) timings — what a user opening a panel sees
↺ Loki cold taken from the first set that ran the same query; Loki's cache answered this one. Why these shapes
base |
✅ Visual smoke: passed with warningsBase
Gate: a base-vs-PR data difference passes when the PR is closer to Loki, and fails when the PR diverges from Loki or Loki cannot decide it (at a range Loki does not hold, a difference passes when the same page proved it closer to Loki at a shorter range; otherwise label the pull request dd-fields-1h: history-dependent difference, not gated (1): resource /api/datasources/uid/*/resources/patterns?end=2026-10-21T13%3A14%3
dd-service-logs-1h: history-dependent difference, not gated (1): resource /api/datasources/uid/*/resources/patterns?end=2026-10-21T13%3A14%3
All montages of this run: |
PR Quality ReportCompared against base branch Coverage and tests
Compatibility
Performance smokeLower CPU cost (
State
|





Summary
Code-scanning alert 607 (Semgrep OSS,
trailofbits.go.iterate-over-empty-map) flags thefor name := range extractedloop inunwrapParseLine(internal/proxy/unwrap_conversion_error.go). The map is filled byplan.parseJSON(line, before, labels, extracted)on the line before the loop, so the finding is a false positive.Change
An inline
// nosemgrep: trailofbits.go.iterate-over-empty-map.iterate-over-empty-map -- parseJSON fills it before the loop belowon the map's declaration, the line Semgrep anchors the finding to, following the repository's existing reviewed exceptions (otlp.go,patterns.go,proxy.go,quantile_histogram.go). No code or behaviour change. PassingparsedtoparseJSONdirectly was considered and rejected: it would also skip names an earlier parser stage extracted, which changes the result.Proof
Semgrep 1.161.0 (the version the scheduled security workflow pins) with
p/default p/golang p/owasp-top-ten:mainiterate-over-empty-map:970,no-direct-write-to-responsewriter:1187(excluded in CI)no-direct-write-to-responsewriter:1187(excluded in CI)go build, changelog gate. The alert closes when the scheduled Semgrep run scansmainafter merge.Not applicable: no behaviour change, so e2e vs Loki, the Grafana range matrix, visual proof, A/B, benchstat and the load test do not apply.