Class RegexMatcher
java.lang.Object
com.tnsai.quality.security.harness.RegexMatcher
- All Implemented Interfaces:
MatcherSpi
Generic regex-based
MatcherSpi (TNS-291).
Each built-in matcher is an instance of this
class with its own set of patterns, file-extension filter, and default
severity. Custom matchers can either extend this class or implement
MatcherSpi directly (e.g. for AST-based or import-graph-based
checks that regex can't express).
Hits are reported with line numbers derived from the byte offset
of the regex match against the content string.
- Since:
- 0.10.0 (TNS-291)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tnsai.quality.security.harness.MatcherSpi
MatcherSpi.Hit -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
RegexMatcher
public RegexMatcher(String id, String cwe, Severity severity, String description, List<Pattern> patterns, Set<String> extensions) - Parameters:
id- stable matcher idcwe- CWE idseverity- default severity (used when no agent revisits the hit)description- short summary of what the matcher looks forpatterns- regex patterns; eachfind()produces oneMatcherSpi.Hitextensions- file extensions (with leading dot, e.g.".java") this matcher applies to. Empty = match every file.
-
-
Method Details
-
id
Description copied from interface:MatcherSpiStable id, e.g."sql-injection".- Specified by:
idin interfaceMatcherSpi
-
cwe
Description copied from interface:MatcherSpiCWE id this matcher targets, e.g."CWE-89".- Specified by:
cwein interfaceMatcherSpi
-
defaultSeverity
Description copied from interface:MatcherSpiDefault severity assigned when this matcher fires alone (no agent).- Specified by:
defaultSeverityin interfaceMatcherSpi
-
description
Description copied from interface:MatcherSpiHuman-readable description of what this matcher looks for.- Specified by:
descriptionin interfaceMatcherSpi
-
scan
Description copied from interface:MatcherSpiScancontentand return the locations where the matcher found a candidate. Returning an empty list means the file is clean w.r.t. this matcher.- Specified by:
scanin interfaceMatcherSpi- Parameters:
file- relative path inside the project — only used for language gating (e.g. skip non-Java files)content- full file content as UTF-8
-