diff --git a/core/metaschema b/core/metaschema index eae19ab94..088bda7f6 160000 --- a/core/metaschema +++ b/core/metaschema @@ -1 +1 @@ -Subproject commit eae19ab94dfc8d1557c849a069995fa3bfe4b762 +Subproject commit 088bda7f6fbad8ad0132f8fdb30b3d81c7b578ab diff --git a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractLoader.java b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractLoader.java index c02344eff..097080c47 100644 --- a/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractLoader.java +++ b/core/src/main/java/gov/nist/secauto/metaschema/core/model/AbstractLoader.java @@ -154,7 +154,7 @@ protected T loadInternal(@NonNull URI resource, @NonNull Deque visitedResou T retval = cache.get(resource); if (retval == null) { - LOGGER.info("Loading module '{}'", resource); + LOGGER.info("Loading '{}'", resource); try { visitedResources.push(resource); diff --git a/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java b/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java index 5e9a905e6..0219cc0b0 100644 --- a/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java +++ b/databind-metaschema/src/main/java/gov/nist/secauto/metaschema/modules/sarif/SarifValidationHandler.java @@ -26,6 +26,7 @@ package gov.nist.secauto.metaschema.modules.sarif; +import gov.nist.secauto.metaschema.core.datatype.markup.MarkupLine; import gov.nist.secauto.metaschema.core.model.IResourceLocation; import gov.nist.secauto.metaschema.core.model.constraint.ConstraintValidationFinding; import gov.nist.secauto.metaschema.core.model.constraint.IConstraint; @@ -46,6 +47,7 @@ import org.schemastore.json.sarif.x210.Location; import org.schemastore.json.sarif.x210.LogicalLocation; import org.schemastore.json.sarif.x210.Message; +import org.schemastore.json.sarif.x210.MultiformatMessageString; import org.schemastore.json.sarif.x210.PhysicalLocation; import org.schemastore.json.sarif.x210.Region; import org.schemastore.json.sarif.x210.ReportingDescriptor; @@ -252,10 +254,24 @@ public void write(@NonNull Path outputFile) throws IOException { private ReportingDescriptor rule(RuleRecord rule) { ReportingDescriptor retval = new ReportingDescriptor(); retval.setId(rule.getId()); - String name = rule.getConstraint().getId(); + IConstraint constraint = rule.getConstraint(); + String name = constraint.getId(); if (name != null) { retval.setName(name); } + + String formalName = constraint.getFormalName(); + if (formalName != null) { + MultiformatMessageString text = new MultiformatMessageString(); + text.setText(formalName); + retval.setShortDescription(text); + } + MarkupLine description = constraint.getDescription(); + if (description != null) { + MultiformatMessageString text = new MultiformatMessageString(); + text.setMarkdown(description.toMarkdown()); + retval.setFullDescription(text); + } return retval; } diff --git a/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java b/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java index b5f14af4e..2339561dc 100644 --- a/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java +++ b/metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java @@ -277,8 +277,6 @@ public ExitStatus execute() { SarifValidationHandler sarifHandler = new SarifValidationHandler(source, version); sarifHandler.addFindings(validationResult.getFindings()); sarifHandler.write(sarifFile); - - LOGGER.error("The file '{}' is invalid.", source); } catch (IOException ex) { return ExitCode.PROCESSING_ERROR.exit().withThrowable(ex); } @@ -288,12 +286,15 @@ public ExitStatus execute() { LoggingValidationHandler.instance().handleValidationResults(validationResult); } - if (validationResult.isPassing() && !cmdLine.hasOption(CLIProcessor.QUIET_OPTION) && LOGGER.isInfoEnabled()) { - LOGGER.info("The file '{}' is valid.", source); + if (validationResult.isPassing()) { + if (LOGGER.isInfoEnabled()) { + LOGGER.info("The file '{}' is valid.", source); + } + } else if (LOGGER.isErrorEnabled()) { + LOGGER.error("The file '{}' is invalid.", source); } return (validationResult.isPassing() ? ExitCode.OK : ExitCode.FAIL).exit(); } - } }