diff options
| author | Claude <noreply@anthropic.com> | 2026-09-10 20:49:44 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-09-10 20:49:44 +0000 |
| commit | 8459dfc26ec93b3d7f53353a902fa2d530bcb154 (patch) | |
| tree | 9b87c6ca0f487f396d792c793a2f0ff56cf693bb /plugins/claude-security/scripts/lib/secret.py | |
| parent | 4d2a599463bf3966c368dd8bfb30cfa1682cf126 (diff) | |
| parent | 3b600518a637492d37c9877aeb49c2a55d939c04 (diff) | |
Merge remote-tracking branch 'origin/main' into tobin/add-dynatrace
# Conflicts:
# .claude-plugin/marketplace.json
Diffstat (limited to 'plugins/claude-security/scripts/lib/secret.py')
| -rw-r--r-- | plugins/claude-security/scripts/lib/secret.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/plugins/claude-security/scripts/lib/secret.py b/plugins/claude-security/scripts/lib/secret.py index 9bf90a3a..67f4d0f4 100644 --- a/plugins/claude-security/scripts/lib/secret.py +++ b/plugins/claude-security/scripts/lib/secret.py @@ -5,8 +5,8 @@ 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 its fingerprint hashes no text of -the file (see sarif.fingerprint). +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 @@ -16,17 +16,22 @@ from typing import TYPE_CHECKING from . import cwe if TYPE_CHECKING: - from .finding import Finding + from .finding import Finding, Record # CWE's Simplified Mapping entry Use of Hard-coded Credentials; CWE-259, 321 and 671 roll up to it. CREDENTIALS = 798 +def is_credential_cwe(number: int) -> bool: + """Whether CWE `number` rolls up to Use of Hard-coded Credentials.""" + return cwe.catalog.category_of.get(number) == CREDENTIALS + + def is_credential(finding: Finding) -> bool: """Whether the finding's CWE rolls up to Use of Hard-coded Credentials.""" - return cwe.catalog.category_of.get(cwe.id_number(finding["cwe_id"])) == CREDENTIALS + return is_credential_cwe(cwe.id_number(finding["cwe_id"])) -def withheld(finding: Finding) -> Finding: +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 |
