Skip to content

Commit

Permalink
chore: Refactor SSC commands
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Oct 19, 2023
1 parent 62a11d8 commit 198acd4
Show file tree
Hide file tree
Showing 38 changed files with 196 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static class Delete extends TableNoQuery {
public static final String CMD_NAME = "delete";
}

@Command(aliases = {"rm-template", "rmt"})
@Command(aliases = {"rmt"})
public static class DeleteTemplate extends TableNoQuery {
public static final String CMD_NAME = "delete-template";
}
Expand All @@ -124,7 +124,7 @@ public static class List extends TableWithQuery {
public static final String CMD_NAME = "list";
}

@Command(aliases = {"listdef", "lsd"})
@Command(aliases = {"lsd"})
public static class ListDefinitions extends TableWithQuery {
public static final String CMD_NAME = "list-definitions";
}
Expand All @@ -138,7 +138,6 @@ public static class Get extends DetailsNoQuery {
public static final String CMD_NAME = "get";
}

@Command(aliases = {"getdef"})
public static class GetDefinition extends DetailsNoQuery {
public static final String CMD_NAME = "get-definition";
}
Expand All @@ -159,6 +158,10 @@ public static class Set extends TableNoQuery {
public static class Update extends TableNoQuery {
public static final String CMD_NAME = "update";
}

public static class UpdateTemplate extends TableNoQuery {
public static final String CMD_NAME = "update-template";
}


public static class Enable extends TableNoQuery {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.fortify.cli.common.output.cli.mixin.IOutputHelper;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins.DetailsNoQuery;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins.TableNoQuery;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins.TableWithQuery;

import picocli.CommandLine.Command;
Expand Down Expand Up @@ -49,12 +50,11 @@ public static class ImportDebricked extends OutputHelperMixins.TableNoQuery {
public static final String CMD_NAME = "import-debricked";
}

@Command(aliases = {"list-fs", "lsfs"})
@Command(aliases = {"lsfs"})
public static class ListFilterSets extends TableWithQuery {
public static final String CMD_NAME = "list-filtersets";
}

@Command(aliases = {"get-fs"})
public static class GetFilterSet extends DetailsNoQuery {
public static final String CMD_NAME = "get-filterset";
}
Expand Down Expand Up @@ -90,5 +90,34 @@ public static class VulnCount extends OutputHelperMixins.TableWithQuery {
public static final String CMD_NAME = "count";
}


@Command(aliases = {"lsa"})
public static class ListActivities extends TableWithQuery {
public static final String CMD_NAME = "list-activities";
}

@Command(aliases = {"lse"})
public static class ListEvents extends TableWithQuery {
public static final String CMD_NAME = "list-events";
}

@Command(aliases = {"lsj"})
public static class ListJobs extends TableWithQuery {
public static final String CMD_NAME = "list-jobs";
}

public static class CancelJob extends TableNoQuery {
public static final String CMD_NAME = "cancel-job";
}

public static class UpdateJob extends TableNoQuery {
public static final String CMD_NAME = "update-job";
}

public static class GetJob extends DetailsNoQuery {
public static final String CMD_NAME = "get-job";
}

public static class UploadSeedBundle extends TableNoQuery {
public static final String CMD_NAME = "upload-seed-bundle";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.fortify.cli.common.util.StringUtils;
import com.fortify.cli.ssc.token.helper.SSCTokenCreateRequest;
import com.fortify.cli.ssc.token.helper.SSCTokenCreateResponse;
import com.fortify.cli.ssc.token.helper.SSCTokenHelper;
import com.fortify.cli.ssc.token.helper.SSCTokenCreateResponse.SSCTokenData;
import com.fortify.cli.ssc.token.helper.SSCTokenHelper;

import lombok.Data;
import lombok.EqualsAndHashCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@

import com.fortify.cli.common.cli.cmd.AbstractContainerCommand;
import com.fortify.cli.ssc._common.session.cli.cmd.SSCSessionCommands;
import com.fortify.cli.ssc.activity_feed.cli.cmd.SSCActivityFeedCommands;
import com.fortify.cli.ssc.alert.cli.cmd.SSCAlertCommands;
import com.fortify.cli.ssc.app.cli.cmd.SSCAppCommands;
import com.fortify.cli.ssc.appversion.cli.cmd.SSCAppVersionCommands;
import com.fortify.cli.ssc.appversion_user.cli.cmd.SSCAppVersionUserCommands;
import com.fortify.cli.ssc.artifact.cli.cmd.SSCArtifactCommands;
import com.fortify.cli.ssc.attribute.cli.cmd.SSCAttributeCommands;
import com.fortify.cli.ssc.event.cli.cmd.SSCEventCommands;
import com.fortify.cli.ssc.issue.cli.cmd.SSCIssueCommands;
import com.fortify.cli.ssc.issue_template.cli.cmd.SSCIssueTemplateCommands;
import com.fortify.cli.ssc.job.cli.cmd.SSCJobCommands;
import com.fortify.cli.ssc.performance_indicator.cli.cmd.SSCPerformanceIndicatorCommands;
import com.fortify.cli.ssc.plugin.cli.cmd.SSCPluginCommands;
import com.fortify.cli.ssc.report.cli.cmd.SSCReportCommands;
import com.fortify.cli.ssc.rest.cli.cmd.SSCRestCommands;
import com.fortify.cli.ssc.role.cli.cmd.SSCRoleCommands;
import com.fortify.cli.ssc.seed_bundle.cli.cmd.SSCSeedBundleCommands;
import com.fortify.cli.ssc.system_state.cli.cmd.SSCSystemStateCommands;
import com.fortify.cli.ssc.token.cli.cmd.SSCTokenCommands;
import com.fortify.cli.ssc.user.cli.cmd.SSCUserCommands;

Expand All @@ -49,22 +45,18 @@
// 'rest' has a different header ('Interact with' compared to most
// other commands ('Manage').
SSCSessionCommands.class,
SSCActivityFeedCommands.class,
SSCAlertCommands.class,
SSCAppCommands.class,
SSCAppVersionCommands.class,
SSCAppVersionUserCommands.class,
SSCArtifactCommands.class,
SSCAttributeCommands.class,
SSCEventCommands.class,
SSCIssueCommands.class,
SSCIssueTemplateCommands.class,
SSCJobCommands.class,
SSCPerformanceIndicatorCommands.class,
SSCPluginCommands.class,
SSCReportCommands.class,
SSCRoleCommands.class,
SSCSeedBundleCommands.class,
SSCSystemStateCommands.class,
SSCTokenCommands.class,
SSCUserCommands.class,
SSCRestCommands.class,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import com.fortify.cli.ssc.appversion_user.helper.SSCAppVersionUserUpdateBuilder;
import com.fortify.cli.ssc.attribute.cli.mixin.SSCAttributeUpdateMixin;
import com.fortify.cli.ssc.attribute.helper.SSCAttributeUpdateBuilder;
import com.fortify.cli.ssc.issue_template.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue_template.helper.SSCIssueTemplateDescriptor;
import com.fortify.cli.ssc.issue.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue.helper.SSCIssueTemplateDescriptor;

import kong.unirest.HttpRequest;
import kong.unirest.UnirestInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import com.fortify.cli.ssc.appversion_user.helper.SSCAppVersionUserUpdateBuilder;
import com.fortify.cli.ssc.attribute.cli.mixin.SSCAttributeUpdateMixin;
import com.fortify.cli.ssc.attribute.helper.SSCAttributeUpdateBuilder;
import com.fortify.cli.ssc.issue_template.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue_template.helper.SSCIssueTemplateDescriptor;
import com.fortify.cli.ssc.issue.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue.helper.SSCIssueTemplateDescriptor;

import kong.unirest.HttpRequest;
import kong.unirest.UnirestInstance;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
@Command(
name = "issue", aliases = "vulnerability",
subcommands = {
SSCIssueTemplateCreateCommand.class,
SSCIssueTemplateDeleteCommand.class,
SSCIssueTemplateDownloadCommand.class,
SSCIssueTemplateGetCommand.class,
SSCIssueTemplateListCommand.class,
SSCIssueTemplateUpdateCommand.class,
SSCIssueFilterSetGetCommand.class,
SSCIssueFilterSetListCommand.class,
SSCIssueFilterGetCommand.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
* herein. The information contained herein is subject to change
* without notice.
*******************************************************************************/
package com.fortify.cli.ssc.issue_template.cli.cmd;
package com.fortify.cli.ssc.issue.cli.cmd;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fortify.cli.common.cli.mixin.CommonOptionMixins;
import com.fortify.cli.common.cli.util.CommandGroup;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins;
import com.fortify.cli.common.output.transform.IActionCommandResultSupplier;
import com.fortify.cli.ssc._common.output.cli.cmd.AbstractSSCJsonNodeOutputCommand;
Expand All @@ -27,9 +28,9 @@
import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;

@Command(name = OutputHelperMixins.Create.CMD_NAME)
@Command(name = OutputHelperMixins.CreateTemplate.CMD_NAME) @CommandGroup("template")
public class SSCIssueTemplateCreateCommand extends AbstractSSCJsonNodeOutputCommand implements IActionCommandResultSupplier {
@Getter @Mixin private OutputHelperMixins.Create outputHelper;
@Getter @Mixin private OutputHelperMixins.CreateTemplate outputHelper;
@Option(names={"--name","-n"}, required = true) private String issueTemplateName;
@Mixin private CommonOptionMixins.RequiredFile fileMixin;
@Option(names={"--description","-d"}, required = false, defaultValue = "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@
* herein. The information contained herein is subject to change
* without notice.
*******************************************************************************/
package com.fortify.cli.ssc.issue_template.cli.cmd;
package com.fortify.cli.ssc.issue.cli.cmd;

import com.fasterxml.jackson.databind.JsonNode;
import com.fortify.cli.common.cli.util.CommandGroup;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins;
import com.fortify.cli.common.output.transform.IActionCommandResultSupplier;
import com.fortify.cli.ssc._common.output.cli.cmd.AbstractSSCJsonNodeOutputCommand;
import com.fortify.cli.ssc._common.rest.SSCUrls;
import com.fortify.cli.ssc.issue_template.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue_template.helper.SSCIssueTemplateDescriptor;
import com.fortify.cli.ssc.issue.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue.helper.SSCIssueTemplateDescriptor;

import kong.unirest.UnirestInstance;
import lombok.Getter;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;

@Command(name = OutputHelperMixins.Delete.CMD_NAME)
@Command(name = OutputHelperMixins.DeleteTemplate.CMD_NAME) @CommandGroup("template")
public class SSCIssueTemplateDeleteCommand extends AbstractSSCJsonNodeOutputCommand implements IActionCommandResultSupplier {
@Getter @Mixin private OutputHelperMixins.Delete outputHelper;
@Getter @Mixin private OutputHelperMixins.DeleteTemplate outputHelper;
@CommandLine.Mixin private SSCIssueTemplateResolverMixin.PositionalParameterSingle issueTemplateResolver;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@
* herein. The information contained herein is subject to change
* without notice.
*******************************************************************************/
package com.fortify.cli.ssc.issue_template.cli.cmd;
package com.fortify.cli.ssc.issue.cli.cmd;

import java.io.File;

import com.fasterxml.jackson.databind.JsonNode;
import com.fortify.cli.common.cli.mixin.CommonOptionMixins;
import com.fortify.cli.common.cli.util.CommandGroup;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins;
import com.fortify.cli.common.output.transform.IActionCommandResultSupplier;
import com.fortify.cli.ssc._common.output.cli.cmd.AbstractSSCJsonNodeOutputCommand;
import com.fortify.cli.ssc._common.rest.transfer.SSCFileTransferHelper;
import com.fortify.cli.ssc._common.rest.transfer.SSCFileTransferHelper.ISSCAddDownloadTokenFunction;
import com.fortify.cli.ssc.issue_template.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue_template.helper.SSCIssueTemplateDescriptor;
import com.fortify.cli.ssc.issue.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue.helper.SSCIssueTemplateDescriptor;

import kong.unirest.UnirestInstance;
import lombok.Getter;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;

@Command(name = OutputHelperMixins.Download.CMD_NAME)
@Command(name = OutputHelperMixins.DownloadTemplate.CMD_NAME) @CommandGroup("template")
public class SSCIssueTemplateDownloadCommand extends AbstractSSCJsonNodeOutputCommand implements IActionCommandResultSupplier {
@Getter @Mixin private OutputHelperMixins.Download outputHelper;
@Getter @Mixin private OutputHelperMixins.DownloadTemplate outputHelper;
@Mixin private CommonOptionMixins.OptionalFile fileMixin;

@CommandLine.Mixin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@
* herein. The information contained herein is subject to change
* without notice.
*******************************************************************************/
package com.fortify.cli.ssc.issue_template.cli.cmd;
package com.fortify.cli.ssc.issue.cli.cmd;

import com.fasterxml.jackson.databind.JsonNode;
import com.fortify.cli.common.cli.util.CommandGroup;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins;
import com.fortify.cli.ssc._common.output.cli.cmd.AbstractSSCJsonNodeOutputCommand;
import com.fortify.cli.ssc.issue_template.cli.mixin.SSCIssueTemplateResolverMixin;
import com.fortify.cli.ssc.issue.cli.mixin.SSCIssueTemplateResolverMixin;

import kong.unirest.UnirestInstance;
import lombok.Getter;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;

@Command(name = OutputHelperMixins.Get.CMD_NAME)
@Command(name = OutputHelperMixins.GetTemplate.CMD_NAME) @CommandGroup("template")
public class SSCIssueTemplateGetCommand extends AbstractSSCJsonNodeOutputCommand {
@Getter @Mixin private OutputHelperMixins.Get outputHelper;
@Getter @Mixin private OutputHelperMixins.GetTemplate outputHelper;
@Mixin private SSCIssueTemplateResolverMixin.PositionalParameterSingle issueTemplateResolver;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* herein. The information contained herein is subject to change
* without notice.
*******************************************************************************/
package com.fortify.cli.ssc.issue_template.cli.cmd;
package com.fortify.cli.ssc.issue.cli.cmd;

import com.fortify.cli.common.cli.util.CommandGroup;
import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins;
import com.fortify.cli.common.rest.query.IServerSideQueryParamGeneratorSupplier;
import com.fortify.cli.common.rest.query.IServerSideQueryParamValueGenerator;
Expand All @@ -27,9 +28,9 @@
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;

@Command(name = OutputHelperMixins.List.CMD_NAME)
@Command(name = OutputHelperMixins.ListTemplates.CMD_NAME) @CommandGroup("template")
public class SSCIssueTemplateListCommand extends AbstractSSCBaseRequestOutputCommand implements IServerSideQueryParamGeneratorSupplier {
@Getter @Mixin private OutputHelperMixins.List outputHelper;
@Getter @Mixin private OutputHelperMixins.ListTemplates outputHelper;
@Mixin private SSCQParamMixin qParamMixin;
@Getter private IServerSideQueryParamValueGenerator serverSideQueryParamGenerator = new SSCQParamGenerator()
.add("id", SSCQParamValueGenerators::plain)
Expand Down
Loading

0 comments on commit 198acd4

Please sign in to comment.