Skip to content

Commit

Permalink
Added option to produce SARIF including pass results.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Jun 21, 2024
1 parent dd6890e commit 6b44364
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,24 @@ public abstract class AbstractValidateContentCommand
@NonNull
private static final Option CONSTRAINTS_OPTION = ObjectUtils.notNull(
Option.builder("c")
.hasArg()
.hasArgs()
.argName("URI")
.desc("additional constraint definitions")
.build());
@NonNull
private static final Option OUTPUT_FILE_OPTION = ObjectUtils.notNull(
private static final Option SARIF_OUTPUT_FILE_OPTION = ObjectUtils.notNull(
Option.builder("o")
.hasArg()
.argName("FILE")
.desc("write SARIF results to the provided FILE")
.numberOfArgs(1)
.build());
@NonNull
private static final Option SARIF_INCLUDE_PASS_OPTION = ObjectUtils.notNull(
Option.builder()
.longOpt("sarif-include-pass")
.desc("include pass results in SARIF")
.build());

@Override
public String getName() {
Expand All @@ -122,7 +128,7 @@ public Collection<? extends Option> gatherOptions() {
return List.of(
AS_OPTION,
CONSTRAINTS_OPTION,
OUTPUT_FILE_OPTION);
SARIF_OUTPUT_FILE_OPTION);
}

@Override
Expand Down Expand Up @@ -250,7 +256,7 @@ public ExitStatus execute() {
}

IMutableConfiguration<ValidationFeature<?>> configuration = new DefaultConfiguration<>();
if (cmdLine.hasOption(OUTPUT_FILE_OPTION)) {
if (cmdLine.hasOption(SARIF_OUTPUT_FILE_OPTION) && cmdLine.hasOption(SARIF_INCLUDE_PASS_OPTION)) {
configuration.enableFeature(ValidationFeature.VALIDATE_GENERATE_PASS_FINDINGS);
}

Expand All @@ -267,8 +273,8 @@ public ExitStatus execute() {
return ExitCode.PROCESSING_ERROR.exit().withThrowable(ex);
}

if (cmdLine.hasOption(OUTPUT_FILE_OPTION) && LOGGER.isInfoEnabled()) {
Path sarifFile = Paths.get(cmdLine.getOptionValue(OUTPUT_FILE_OPTION));
if (cmdLine.hasOption(SARIF_OUTPUT_FILE_OPTION) && LOGGER.isInfoEnabled()) {
Path sarifFile = Paths.get(cmdLine.getOptionValue(SARIF_OUTPUT_FILE_OPTION));

IVersionInfo version
= getCallingContext().getCLIProcessor().getVersionInfos().get(CLIProcessor.COMMAND_VERSION);
Expand Down

0 comments on commit 6b44364

Please sign in to comment.