Skip to content

Commit cf9ddfe

Browse files
Added option to produce SARIF including pass results.
1 parent dd6890e commit cf9ddfe

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,24 @@ public abstract class AbstractValidateContentCommand
9898
@NonNull
9999
private static final Option CONSTRAINTS_OPTION = ObjectUtils.notNull(
100100
Option.builder("c")
101-
.hasArg()
101+
.hasArgs()
102102
.argName("URI")
103103
.desc("additional constraint definitions")
104104
.build());
105105
@NonNull
106-
private static final Option OUTPUT_FILE_OPTION = ObjectUtils.notNull(
106+
private static final Option SARIF_OUTPUT_FILE_OPTION = ObjectUtils.notNull(
107107
Option.builder("o")
108108
.hasArg()
109109
.argName("FILE")
110110
.desc("write SARIF results to the provided FILE")
111111
.numberOfArgs(1)
112112
.build());
113+
@NonNull
114+
private static final Option SARIF_INCLUDE_PASS_OPTION = ObjectUtils.notNull(
115+
Option.builder()
116+
.longOpt("sarif-include-pass")
117+
.desc("include pass results in SARIF")
118+
.build());
113119

114120
@Override
115121
public String getName() {
@@ -122,7 +128,8 @@ public Collection<? extends Option> gatherOptions() {
122128
return List.of(
123129
AS_OPTION,
124130
CONSTRAINTS_OPTION,
125-
OUTPUT_FILE_OPTION);
131+
SARIF_OUTPUT_FILE_OPTION,
132+
SARIF_INCLUDE_PASS_OPTION);
126133
}
127134

128135
@Override
@@ -250,7 +257,7 @@ public ExitStatus execute() {
250257
}
251258

252259
IMutableConfiguration<ValidationFeature<?>> configuration = new DefaultConfiguration<>();
253-
if (cmdLine.hasOption(OUTPUT_FILE_OPTION)) {
260+
if (cmdLine.hasOption(SARIF_OUTPUT_FILE_OPTION) && cmdLine.hasOption(SARIF_INCLUDE_PASS_OPTION)) {
254261
configuration.enableFeature(ValidationFeature.VALIDATE_GENERATE_PASS_FINDINGS);
255262
}
256263

@@ -267,8 +274,8 @@ public ExitStatus execute() {
267274
return ExitCode.PROCESSING_ERROR.exit().withThrowable(ex);
268275
}
269276

270-
if (cmdLine.hasOption(OUTPUT_FILE_OPTION) && LOGGER.isInfoEnabled()) {
271-
Path sarifFile = Paths.get(cmdLine.getOptionValue(OUTPUT_FILE_OPTION));
277+
if (cmdLine.hasOption(SARIF_OUTPUT_FILE_OPTION) && LOGGER.isInfoEnabled()) {
278+
Path sarifFile = Paths.get(cmdLine.getOptionValue(SARIF_OUTPUT_FILE_OPTION));
272279

273280
IVersionInfo version
274281
= getCallingContext().getCLIProcessor().getVersionInfos().get(CLIProcessor.COMMAND_VERSION);

0 commit comments

Comments
 (0)