diff options
| author | Claude <noreply@anthropic.com> | 2026-11-06 00:54:48 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-11-06 00:54:48 +0000 |
| commit | 7aba3deae3ff17d032c37e07d2929d1426b34278 (patch) | |
| tree | 9c482f9acda1599bd2f9bed95a6a46b75e634e80 /plugins/claude-security/scripts/lib/secret.py | |
| parent | 5472f5f56e0070feeeb464318b316714fe3e9105 (diff) | |
| parent | b8331dd69ab3e132bbf8cd6e89b5d8c1747e21b1 (diff) | |
Merge remote-tracking branch 'origin/main' into add-plugin/xcodeadd-plugin/xcode
Diffstat (limited to 'plugins/claude-security/scripts/lib/secret.py')
| -rw-r--r-- | plugins/claude-security/scripts/lib/secret.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/plugins/claude-security/scripts/lib/secret.py b/plugins/claude-security/scripts/lib/secret.py index 67f4d0f4..df061c2e 100644 --- a/plugins/claude-security/scripts/lib/secret.py +++ b/plugins/claude-security/scripts/lib/secret.py @@ -1,12 +1,15 @@ -"""The snippet of a hard-coded credential finding, withheld from what the products carry. +"""A hard-coded credential finding's snippet and link to the change, withheld from the products. The line such a finding quotes is the credential itself, and the JSONL and SARIF files exist to leave the machine (a code scanning upload, a CI artifact), so neither file quotes it: the finding's file, line and symbol still locate the code, and the SARIF result's message says why no line is -quoted. Only the emitted copy changes: the finding is still placed on the -snippet as the researcher quoted it, and neither its id nor that of a -finding placed near it hashes the credential's line. +quoted. A change scan's link to the change (via_change) describes that same +line in the researcher's words, so it goes with the snippet: here for the +credential finding, in sarif.placed for a finding near the credential's line +or whose link opens there. Only the emitted copy changes: the finding is still +placed on the snippet as the researcher quoted it, and neither its id nor that +of a finding placed near it hashes the credential's line. """ from __future__ import annotations @@ -28,10 +31,13 @@ def is_credential_cwe(number: int) -> bool: def is_credential(finding: Finding) -> bool: - """Whether the finding's CWE rolls up to Use of Hard-coded Credentials.""" - return is_credential_cwe(cwe.id_number(finding["cwe_id"])) + """Whether any CWE the finding carries rolls up to Use of Hard-coded Credentials.""" + ids = (finding["cwe_id"], *finding["other_cwe_ids"]) + return any(is_credential_cwe(cwe.id_number(cwe_id)) for cwe_id in ids) def withheld(finding: Record) -> Record: - """`finding` as the products carry it: a hard-coded credential's snippet is empty.""" - return {**finding, "snippet": ""} if is_credential(finding) else finding + """`finding` as the products carry it: a hard-coded credential's snippet and link withheld.""" + if not is_credential(finding): + return finding + return {**finding, "snippet": "", "via_change": None} |
