Skip to content

feat(sd001): detect secrets in map entries, parameter defaults and named arguments - #36

Merged
PopovVA merged 2 commits into
mainfrom
feat/sd001-secret-contexts
Jul 17, 2026
Merged

feat(sd001): detect secrets in map entries, parameter defaults and named arguments#36
PopovVA merged 2 commits into
mainfrom
feat/sd001-secret-contexts

Conversation

@PopovVA

@PopovVA PopovVA commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

The high-entropy detector in SD001 only looked at variable declarations, so secrets bound through other syntax were missed. The known-format detector (AWS keys, Stripe keys, PEM blocks, …) already scans every string literal and was never affected — this closes the gap in the name-plus-entropy heuristic only.

_SecretDeclarationVisitor now also collects:

  • map entries — both string keys ('dbPassword': '…') and identifier keys (dbPassword: '…');
  • parameter defaultsvoid connect({String apiKey = '…'});
  • named argumentsconnect(apiKey: '…'), the same leak shape at the call site.

All candidates go through the existing entropy / length / placeholder filters, so the noise profile is unchanged. Finding messages now name the binding context (Variable 'x', Map entry 'x', Parameter 'x', Argument 'x').

Tests

The vulnerable fixture gains one case per new context (all flagged); the clean fixture gains the same contexts with placeholder, low-entropy and unrelated-name values (all quiet). Verified clean against the analyzer lower bound (dart pub downgrade + analyze).

Closes #33

analyzer 14 renamed NamedExpression to NamedArgument and replaced
DefaultFormalParameter with a default clause nested in the parameter,
so the typed visitors did not compile there. The visitor now matches
the shape of the literal's parent node instead of naming the renamed
classes, keeping one code path for the whole supported range.
@PopovVA
PopovVA merged commit 6658f0a into main Jul 17, 2026
1 check passed
@PopovVA
PopovVA deleted the feat/sd001-secret-contexts branch July 17, 2026 19:54
PopovVA added a commit that referenced this pull request Jul 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.6.0](v0.5.1...v0.6.0)
(2026-07-17)


### Features

* **sd001:** detect secrets in map entries, parameter defaults and named
arguments ([#36](#36))
([6658f0a](6658f0a)),
closes [#33](#33)


### Bug Fixes

* **rules:** locate() skips matches inside XML comments
([#35](#35))
([a429cac](a429cac)),
closes [#32](#32)


### Performance Improvements

* **engine:** skip ignored directories before descending into them
([#34](#34))
([2911ae9](2911ae9)),
closes [#31](#31)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

Feature: Expand SD001 check to scan Map Literals and Parameter Defaults

1 participant