Class SarifValidationHandler

java.lang.Object
gov.nist.secauto.metaschema.modules.sarif.SarifValidationHandler

public final class SarifValidationHandler extends Object
Supports building a Static Analysis Results Interchange Format (SARIF) document based on a set of validation findings.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final gov.nist.secauto.metaschema.core.model.IAttributable.Key
     
    static final gov.nist.secauto.metaschema.core.model.IAttributable.Key
     
    static final gov.nist.secauto.metaschema.core.model.IAttributable.Key
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SarifValidationHandler(URI source, gov.nist.secauto.metaschema.core.util.IVersionInfo toolVersion)
    Construct a new validation handler.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFinding(gov.nist.secauto.metaschema.core.model.validation.IValidationFinding finding)
    Register a validation finding.
    void
    addFindings(Collection<? extends gov.nist.secauto.metaschema.core.model.validation.IValidationFinding> findings)
    Register a collection of validation finding.
    void
    write(Path outputFile, IBindingContext bindingContext)
    Write the collection of findings to the provided output file.
    Write the collection of findings to a string in SARIF format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SARIF_HELP_URL_KEY

      @NonNull public static final gov.nist.secauto.metaschema.core.model.IAttributable.Key SARIF_HELP_URL_KEY
    • SARIF_HELP_TEXT_KEY

      @NonNull public static final gov.nist.secauto.metaschema.core.model.IAttributable.Key SARIF_HELP_TEXT_KEY
    • SARIF_HELP_MARKDOWN_KEY

      @NonNull public static final gov.nist.secauto.metaschema.core.model.IAttributable.Key SARIF_HELP_MARKDOWN_KEY
  • Constructor Details

    • SarifValidationHandler

      public SarifValidationHandler(@NonNull URI source, @Nullable gov.nist.secauto.metaschema.core.util.IVersionInfo toolVersion)
      Construct a new validation handler.
      Parameters:
      source - the URI of the content that was validated
      toolVersion - the version information for the tool producing the validation results
  • Method Details

    • addFindings

      public void addFindings(@NonNull Collection<? extends gov.nist.secauto.metaschema.core.model.validation.IValidationFinding> findings)
      Register a collection of validation finding.
      Parameters:
      findings - the findings to register
    • addFinding

      public void addFinding(@NonNull gov.nist.secauto.metaschema.core.model.validation.IValidationFinding finding)
      Register a validation finding.
      Parameters:
      finding - the finding to register
    • writeToString

      @NonNull public String writeToString(@NonNull IBindingContext bindingContext) throws IOException
      Write the collection of findings to a string in SARIF format.
      Parameters:
      bindingContext - the context used to access Metaschema module information based on Java class bindings
      Returns:
      the SARIF document as a string
      Throws:
      IOException - if an error occurred while generating the SARIF document
    • write

      public void write(@NonNull Path outputFile, @NonNull IBindingContext bindingContext) throws IOException
      Write the collection of findings to the provided output file.
      Parameters:
      outputFile - the path to the output file to write to
      bindingContext - the context used to access Metaschema module information based on Java class bindings
      Throws:
      IOException - if an error occurred while writing the SARIF file