Skip to content

Commit 04c67fd

Browse files
security: add leading \b to v1 token rule (round 3 Gemini)
Without a leading word boundary, the v1 token regex would partial-match the substring 'Token' inside identifiers like PowerShell's `$CancellationToken` or .NET's `CancellationToken`, producing false positives on any 40-hex value assigned to such a variable. Verified empirically: $CancellationToken = '<40-hex>' Before: flagged by netbox-v1-token rule (FP) After: flagged only by generic-api-key entropy rule (correct default gitleaks behavior; my custom rule now correctly abstains) `$Token = '<40-hex>'` still flagged by netbox-v1-token (intended). Baseline unchanged at 9 entries — all historic findings use `Token =` or equivalent identifiers that already start at a word boundary.
1 parent 69a2fea commit 04c67fd

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

.gitleaks-baseline.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,16 @@
152152
{
153153
"RuleID": "netbox-v1-token",
154154
"Description": "NetBox v1 API token (40-char hex key)",
155-
"StartLine": 12,
156-
"EndLine": 12,
155+
"StartLine": 21,
156+
"EndLine": 21,
157157
"StartColumn": 2,
158158
"EndColumn": 49,
159159
"Match": "TOKEN=\"a9717b9520d54d19383649066ef3b25e313bf219\"",
160160
"Secret": "a9717b9520d54d19383649066ef3b25e313bf219",
161-
"File": ".claude/commands/implement.md",
161+
"File": ".claude/commands/netbox-api.md",
162162
"SymlinkFile": "",
163163
"Commit": "ef1726d42f622dedf4579016dd6a4fa13df26f17",
164-
"Link": "https://github.com/ctrl-alt-automate/PowerNetbox/blob/ef1726d42f622dedf4579016dd6a4fa13df26f17/.claude/commands/implement.md?plain=1#L12",
164+
"Link": "https://github.com/ctrl-alt-automate/PowerNetbox/blob/ef1726d42f622dedf4579016dd6a4fa13df26f17/.claude/commands/netbox-api.md?plain=1#L21",
165165
"Entropy": 3.7659574,
166166
"Author": "ctrl-alt-automate",
167167
"Email": "elvis@deployment-team.nl",
@@ -172,21 +172,21 @@
172172
"token",
173173
"v1"
174174
],
175-
"Fingerprint": "ef1726d42f622dedf4579016dd6a4fa13df26f17:.claude/commands/implement.md:netbox-v1-token:12"
175+
"Fingerprint": "ef1726d42f622dedf4579016dd6a4fa13df26f17:.claude/commands/netbox-api.md:netbox-v1-token:21"
176176
},
177177
{
178178
"RuleID": "netbox-v1-token",
179179
"Description": "NetBox v1 API token (40-char hex key)",
180-
"StartLine": 21,
181-
"EndLine": 21,
180+
"StartLine": 8,
181+
"EndLine": 8,
182182
"StartColumn": 2,
183183
"EndColumn": 49,
184184
"Match": "TOKEN=\"a9717b9520d54d19383649066ef3b25e313bf219\"",
185185
"Secret": "a9717b9520d54d19383649066ef3b25e313bf219",
186-
"File": ".claude/commands/netbox-api.md",
186+
"File": ".claude/commands/test-endpoint.md",
187187
"SymlinkFile": "",
188188
"Commit": "ef1726d42f622dedf4579016dd6a4fa13df26f17",
189-
"Link": "https://github.com/ctrl-alt-automate/PowerNetbox/blob/ef1726d42f622dedf4579016dd6a4fa13df26f17/.claude/commands/netbox-api.md?plain=1#L21",
189+
"Link": "https://github.com/ctrl-alt-automate/PowerNetbox/blob/ef1726d42f622dedf4579016dd6a4fa13df26f17/.claude/commands/test-endpoint.md?plain=1#L8",
190190
"Entropy": 3.7659574,
191191
"Author": "ctrl-alt-automate",
192192
"Email": "elvis@deployment-team.nl",
@@ -197,21 +197,21 @@
197197
"token",
198198
"v1"
199199
],
200-
"Fingerprint": "ef1726d42f622dedf4579016dd6a4fa13df26f17:.claude/commands/netbox-api.md:netbox-v1-token:21"
200+
"Fingerprint": "ef1726d42f622dedf4579016dd6a4fa13df26f17:.claude/commands/test-endpoint.md:netbox-v1-token:8"
201201
},
202202
{
203203
"RuleID": "netbox-v1-token",
204204
"Description": "NetBox v1 API token (40-char hex key)",
205-
"StartLine": 8,
206-
"EndLine": 8,
205+
"StartLine": 12,
206+
"EndLine": 12,
207207
"StartColumn": 2,
208208
"EndColumn": 49,
209209
"Match": "TOKEN=\"a9717b9520d54d19383649066ef3b25e313bf219\"",
210210
"Secret": "a9717b9520d54d19383649066ef3b25e313bf219",
211-
"File": ".claude/commands/test-endpoint.md",
211+
"File": ".claude/commands/implement.md",
212212
"SymlinkFile": "",
213213
"Commit": "ef1726d42f622dedf4579016dd6a4fa13df26f17",
214-
"Link": "https://github.com/ctrl-alt-automate/PowerNetbox/blob/ef1726d42f622dedf4579016dd6a4fa13df26f17/.claude/commands/test-endpoint.md?plain=1#L8",
214+
"Link": "https://github.com/ctrl-alt-automate/PowerNetbox/blob/ef1726d42f622dedf4579016dd6a4fa13df26f17/.claude/commands/implement.md?plain=1#L12",
215215
"Entropy": 3.7659574,
216216
"Author": "ctrl-alt-automate",
217217
"Email": "elvis@deployment-team.nl",
@@ -222,6 +222,6 @@
222222
"token",
223223
"v1"
224224
],
225-
"Fingerprint": "ef1726d42f622dedf4579016dd6a4fa13df26f17:.claude/commands/test-endpoint.md:netbox-v1-token:8"
225+
"Fingerprint": "ef1726d42f622dedf4579016dd6a4fa13df26f17:.claude/commands/implement.md:netbox-v1-token:12"
226226
}
227227
]

.gitleaks.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags = ["netbox", "token", "v2"]
2929
[[rules]]
3030
id = "netbox-v1-token"
3131
description = "NetBox v1 API token (40-char hex key)"
32-
regex = '''(?i)(?:token|netbox[_-]?token|nb[_-]?token|api[_-]?token|api[_-]?key)\s*[:=]\s*["']?\b([a-f0-9]{40})\b["']?'''
32+
regex = '''(?i)\b(?:token|netbox[_-]?token|nb[_-]?token|api[_-]?token|api[_-]?key)\s*[:=]\s*["']?\b([a-f0-9]{40})\b["']?'''
3333
keywords = ["token", "apikey", "api_key", "api-key"]
3434
secretGroup = 1
3535
tags = ["netbox", "token", "v1"]

0 commit comments

Comments
 (0)