Class SarifEmitter
- All Implemented Interfaces:
TestMethodSink
flush(PrintWriter) is called.
SARIF (Static Analysis Results Interchange Format) is an OASIS standard for
representing the results of static analysis tools. MethodAtlas uses it to
emit a machine-readable inventory of discovered test methods, with
security-relevant methods distinguished from ordinary test methods via the
SARIF result level (note vs none).
Each test method becomes one SARIF result. Security-relevant methods receive
level note and a rule derived from the first non-umbrella AI tag
(e.g. security/auth). All other methods receive level none
and rule test-method.
AI enrichment fields (display name, tags, reason, confidence) are stored in
the SARIF result properties bag when an AiMethodSuggestion
is available. The interaction score and, when confidence reporting is
enabled, the confidence percentage are also embedded directly in the
result message text so they remain visible in tooling (such as GitHub Code
Scanning) that does not render the properties bag.
This class implements TestMethodSink so it can be passed directly to
the orchestration layer in MethodAtlasApp.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSarifEmitter(boolean aiEnabled, boolean confidenceEnabled, String filePrefix) Creates a new SARIF emitter with scores embedded in result message text (the default behaviour).SarifEmitter(boolean aiEnabled, boolean confidenceEnabled, String filePrefix, boolean scoresInMessage) Creates a new SARIF emitter. -
Method Summary
Modifier and TypeMethodDescriptionvoidflush(PrintWriter out) Serializes all buffered records as a SARIF 2.1.0 JSON document and writes it to the supplied writer.voidrecord(String fqcn, String method, int beginLine, int loc, String contentHash, List<String> tags, String displayName, AiMethodSuggestion suggestion) Buffers a single test method record.
-
Constructor Details
-
SarifEmitter
Creates a new SARIF emitter with scores embedded in result message text (the default behaviour).- Parameters:
aiEnabled- whether AI enrichment columns should be includedconfidenceEnabled- whether theaiConfidenceproperty should be included; only meaningful whenaiEnabledistruefilePrefix- forward-slash path prefix prepended to every artifact URI to produce a repo-relative path (e.g."src/test/java/"); use empty string when the scan root is already the repository root
-
SarifEmitter
public SarifEmitter(boolean aiEnabled, boolean confidenceEnabled, String filePrefix, boolean scoresInMessage) Creates a new SARIF emitter.- Parameters:
aiEnabled- whether AI enrichment columns should be includedconfidenceEnabled- whether theaiConfidenceproperty should be included; only meaningful whenaiEnabledistruefilePrefix- forward-slash path prefix prepended to every artifact URI to produce a repo-relative path (e.g."src/test/java/"); use empty string when the scan root is already the repository rootscoresInMessage- whentrue(the default), the interaction score and confidence percentage are embedded in the result message text so they are visible in tooling (such as GitHub Code Scanning) that does not render thepropertiesbag; set tofalsewhen the consuming system already displayspropertiesand the extra text is unwanted
-
-
Method Details
-
record
public void record(String fqcn, String method, int beginLine, int loc, String contentHash, List<String> tags, String displayName, AiMethodSuggestion suggestion) Buffers a single test method record.- Specified by:
recordin interfaceTestMethodSink- Parameters:
fqcn- fully qualified name of the class that declares the methodmethod- simple method namebeginLine- one-based line number of the first line of the method declaration;0when the parser cannot determine the locationloc- inclusive line count of the method declarationcontentHash- lowercase-hex SHA-256 fingerprint of the enclosing class source, ornullwhen-content-hashis not enabledtags- source-level test-framework tag values declared on the method; nevernulldisplayName- text from an existing display-name annotation on the method;nullwhen no such annotation is present;""when the annotation is present but has an empty value — which is a malformed annotation and may be treated as a quality finding by implementationssuggestion- AI-generated security classification for the method, ornullwhen AI enrichment is disabled or unavailable for this class
-
flush
Serializes all buffered records as a SARIF 2.1.0 JSON document and writes it to the supplied writer.- Parameters:
out- destination writer- Throws:
IllegalStateException- if JSON serialization fails
-