public class SarifLogger extends AutomaticBean implements AuditListener
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
private static int |
BUFFER_SIZE
Input stream buffer size.
|
private boolean |
closeStream
Close output stream in auditFinished.
|
private static java.lang.String |
COLUMN_PLACEHOLDER
The placeholder for column.
|
private static java.lang.String |
LINE_PLACEHOLDER
The placeholder for line.
|
private static java.lang.String |
MESSAGE_PLACEHOLDER
The placeholder for message.
|
private java.lang.String |
report
Content for the entire report.
|
private java.lang.String |
resultErrorOnly
Content for result representing an error without filename or location.
|
private java.lang.String |
resultFileOnly
Content for result representing an error with filename only and without source location.
|
private java.lang.String |
resultLineColumn
Content for result representing an error with source line and column.
|
private java.lang.String |
resultLineOnly
Content for result representing an error with source line only.
|
private java.util.List<java.lang.String> |
results
The results.
|
private static java.lang.String |
RESULTS_PLACEHOLDER
The placeholder for results.
|
private static java.lang.String |
RULE_ID_PLACEHOLDER
The placeholder for rule id.
|
private static java.lang.String |
SEVERITY_LEVEL_PLACEHOLDER
The placeholder for severity level.
|
private static int |
UNICODE_ESCAPE_UPPER_LIMIT
Unicode escaping upper limit.
|
private static int |
UNICODE_LENGTH
The length of unicode placeholder.
|
private static java.lang.String |
URI_PLACEHOLDER
The placeholder for uri.
|
private static java.lang.String |
VERSION_PLACEHOLDER
The placeholder for version.
|
private java.io.PrintWriter |
writer
Helper writer that allows easy encoding and printing.
|
| Constructor and Description |
|---|
SarifLogger(java.io.OutputStream outputStream,
AutomaticBean.OutputStreamOptions outputStreamOptions)
Creates a new
SarifLogger instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
addError(AuditEvent event)
Notify that an audit error was discovered on a specific file.
|
void |
addException(AuditEvent event,
java.lang.Throwable throwable)
Notify that an exception happened while performing audit.
|
void |
auditFinished(AuditEvent event)
Notify that the audit is finished.
|
void |
auditStarted(AuditEvent event)
Notify that the audit is about to start.
|
static java.lang.String |
escape(java.lang.String value)
Escape \b, \f, \n, \r, \t, \", \\ and U+0000 through U+001F.
|
private static java.lang.String |
escapeUnicode1F(char chr)
Escape the character between 0x00 to 0x1F in JSON.
|
void |
fileFinished(AuditEvent event)
Notify that audit is finished on a specific file.
|
void |
fileStarted(AuditEvent event)
Notify that audit is about to start on a specific file.
|
protected void |
finishLocalSetup()
Provides a hook to finish the part of this component's setup that
was not handled by the bean introspection.
|
static java.lang.String |
readResource(java.lang.String name)
Read string from given resource.
|
private static java.lang.String |
renderSeverityLevel(SeverityLevel severityLevel)
Render the severity level into SARIF severity level.
|
configure, contextualize, getConfiguration, setupChildprivate static final int UNICODE_LENGTH
private static final int UNICODE_ESCAPE_UPPER_LIMIT
private static final int BUFFER_SIZE
private static final java.lang.String MESSAGE_PLACEHOLDER
private static final java.lang.String SEVERITY_LEVEL_PLACEHOLDER
private static final java.lang.String URI_PLACEHOLDER
private static final java.lang.String LINE_PLACEHOLDER
private static final java.lang.String COLUMN_PLACEHOLDER
private static final java.lang.String RULE_ID_PLACEHOLDER
private static final java.lang.String VERSION_PLACEHOLDER
private static final java.lang.String RESULTS_PLACEHOLDER
private final java.io.PrintWriter writer
private final boolean closeStream
private final java.util.List<java.lang.String> results
private final java.lang.String report
private final java.lang.String resultLineColumn
private final java.lang.String resultLineOnly
private final java.lang.String resultFileOnly
private final java.lang.String resultErrorOnly
public SarifLogger(java.io.OutputStream outputStream, AutomaticBean.OutputStreamOptions outputStreamOptions) throws java.io.IOException
SarifLogger instance.outputStream - where to log audit eventsoutputStreamOptions - if CLOSE that should be closed in auditFinished()java.lang.IllegalArgumentException - if outputStreamOptions is nulljava.io.IOException - if there is reading errors.protected void finishLocalSetup()
AutomaticBeanThe default implementation does nothing.
finishLocalSetup in class AutomaticBeanpublic void auditStarted(AuditEvent event)
AuditListenerauditStarted in interface AuditListenerevent - the event detailspublic void auditFinished(AuditEvent event)
auditFinished in interface AuditListenerevent - the event detailspublic void addError(AuditEvent event)
addError in interface AuditListenerevent - the event detailspublic void addException(AuditEvent event, java.lang.Throwable throwable)
addException in interface AuditListenerevent - the event detailsthrowable - details of the exceptionpublic void fileStarted(AuditEvent event)
AuditListenerfileStarted in interface AuditListenerevent - the event detailspublic void fileFinished(AuditEvent event)
AuditListenerfileFinished in interface AuditListenerevent - the event detailsprivate static java.lang.String renderSeverityLevel(SeverityLevel severityLevel)
severityLevel - the Severity level.public static java.lang.String escape(java.lang.String value)
value - the value to escape.private static java.lang.String escapeUnicode1F(char chr)
chr - the character to be escaped.public static java.lang.String readResource(java.lang.String name) throws java.io.IOException
name - name of the desired resourcejava.io.IOException - if there is reading errorsCopyright © 2001-2022. All Rights Reserved.