Class SarifLogger

    • Constructor Detail

      • SarifLogger

        public SarifLogger​(java.io.OutputStream outputStream,
                           AbstractAutomaticBean.OutputStreamOptions outputStreamOptions)
                    throws java.io.IOException
        Creates a new SarifLogger instance.
        Parameters:
        outputStream - where to log audit events
        outputStreamOptions - if CLOSE that should be closed in auditFinished()
        Throws:
        java.lang.IllegalArgumentException - if outputStreamOptions is null
        java.io.IOException - if there is reading errors.
    • Method Detail

      • addException

        public void addException​(AuditEvent event,
                                 java.lang.Throwable throwable)
        Description copied from interface: AuditListener
        Notify that an exception happened while performing audit.
        Specified by:
        addException in interface AuditListener
        Parameters:
        event - the event details
        throwable - details of the exception
      • renderSeverityLevel

        private static java.lang.String renderSeverityLevel​(SeverityLevel severityLevel)
        Render the severity level into SARIF severity level.
        Parameters:
        severityLevel - the Severity level.
        Returns:
        the rendered severity level in string.
      • escape

        public static java.lang.String escape​(java.lang.String value)
        Escape \b, \f, \n, \r, \t, \", \\ and U+0000 through U+001F. See reference - 2.5. Strings
        Parameters:
        value - the value to escape.
        Returns:
        the escaped value if necessary.
      • escapeUnicode1F

        private static java.lang.String escapeUnicode1F​(char chr)
        Escape the character between 0x00 to 0x1F in JSON.
        Parameters:
        chr - the character to be escaped.
        Returns:
        the escaped string.
      • readResource

        public static java.lang.String readResource​(java.lang.String name)
                                             throws java.io.IOException
        Read string from given resource.
        Parameters:
        name - name of the desired resource
        Returns:
        the string content from the give resource
        Throws:
        java.io.IOException - if there is reading errors