Expand description
Code context analysis (comments, assignments, test files). Structural context analysis: understand WHERE in code a potential secret appears.
Instead of treating code as flat text, we infer the structural context of each match (assignment, comment, test code, encrypted block, documentation) and adjust confidence accordingly. Not an AST parser - just fast, language-agnostic structural inference.
Structs§
- Context
Regions - Per-line region membership precomputed once per chunk.
Enums§
- Code
Context - The structural context of a code location.
Functions§
- documentation_
line_ flags - Mark lines that appear to be documentation or docstrings.
- infer_
context - Infer the structural context of a match at a given line.
- infer_
context_ with_ documentation - Infer context when documentation-line flags have already been computed.
- infer_
context_ with_ regions - Like
infer_context_with_documentation, but reads encrypted-block and test-function membership from aContextRegionstable precomputed once per chunk instead of re-walking up to 100 lines backward per match. - is_
false_ positive_ context - Check whether a line-level match sits in known false-positive context.
- is_
false_ positive_ context_ with_ path - Same as
is_false_positive_context. Retained for source compatibility with callers that historically pre-lowered the path; the body no longer requires a lowered string thanks to byte-wise case-insensitive checks. - is_
false_ positive_ match_ context - Returns
trueif the match is in a context that indicates a false positive. - is_
known_ example_ credential - Detect example/placeholder credentials using ONLY algorithmic heuristics. No hardcoded credential lists - every suppression is based on a structural property that generalizes to all credentials of that shape.
- is_
sequential_ placeholder