-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add/update
issue list
commands
fix: `fcli ssc issue list`: Add `--include` option to allow for retrieving `hidden`, `fixed` and/or `suppressed` issues chore: Update behavior of `fcli fod issue list --include` option to allow retrieval of only fixed/suppressed issues, without `visible` issues
- Loading branch information
Showing
5 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...core/fcli-ssc/src/main/java/com/fortify/cli/ssc/issue/cli/mixin/SSCIssueIncludeMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.fortify.cli.ssc.issue.cli.mixin; | ||
|
||
import java.util.Set; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fortify.cli.common.json.JsonHelper; | ||
import com.fortify.cli.common.output.transform.IRecordTransformer; | ||
import com.fortify.cli.common.rest.unirest.IHttpRequestUpdater; | ||
import com.fortify.cli.common.util.DisableTest; | ||
import com.fortify.cli.common.util.DisableTest.TestType; | ||
|
||
import kong.unirest.HttpRequest; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import picocli.CommandLine.Option; | ||
|
||
public class SSCIssueIncludeMixin implements IHttpRequestUpdater, IRecordTransformer { | ||
@DisableTest(TestType.MULTI_OPT_PLURAL_NAME) | ||
@Option(names = {"--include", "-i"}, split = ",", defaultValue = "visible", descriptionKey = "fcli.ssc.issue.list.includeIssue", paramLabel="<status>") | ||
private Set<SSCIssueInclude> includes; | ||
|
||
public HttpRequest<?> updateRequest(HttpRequest<?> request) { | ||
// TODO Check whether we can potentially perform any server-side filtering | ||
// to retrieve ONLY suppressed/fixed/hidden issues, although SSC doesn't | ||
// seem to allow server-side filtering on the respective boolean fields. | ||
// See FoDIssueIncludeMixin for additional details. | ||
if ( includes!=null ) { | ||
for ( var include : includes) { | ||
var queryParameterName = include.getRequestParameterName(); | ||
if ( queryParameterName!=null ) { | ||
request = request.queryString(queryParameterName, "true"); | ||
} | ||
} | ||
} | ||
return request; | ||
} | ||
|
||
@Override | ||
public JsonNode transformRecord(JsonNode record) { | ||
// If includes doesn't include 'visible', we return null for any visible (non-suppressed | ||
// & non-fixed) issues. We don't need explicit handling for other cases, as suppressed or | ||
// fixed issues won't be returned by FoD if not explicitly specified through the --include | ||
// option. | ||
return !includes.contains(SSCIssueInclude.visible) | ||
&& JsonHelper.evaluateSpelExpression(record, "!hidden && !removed && !suppressed", Boolean.class) | ||
? null | ||
: record; | ||
} | ||
|
||
@RequiredArgsConstructor | ||
public static enum SSCIssueInclude { | ||
visible(null), hidden("showhidden"), fixed("showremoved"), suppressed("showsuppressed"); | ||
|
||
@Getter | ||
private final String requestParameterName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters