Skip to content

Commit

Permalink
chore: Minor sc-sast refactoring & improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Sep 25, 2024
1 parent d071d25 commit 52a7821
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.fortify.cli.sc_sast.scan.helper.SCSastControllerJobType;
import com.fortify.cli.sc_sast.scan.helper.SCSastControllerScanJobHelper;
import com.fortify.cli.sc_sast.scan.helper.SCSastControllerScanJobHelper.StatusEndpointVersion;
import com.fortify.cli.sc_sast.sensor_pool.cli.mixin.SCSastSensorPoolResolverMixin.AbstractSCSastSensorPoolResolverMixin;
import com.fortify.cli.sc_sast.sensor_pool.cli.mixin.SCSastSensorPoolResolverMixin;
import com.fortify.cli.ssc.access_control.helper.SSCTokenConverter;
import com.fortify.cli.ssc.appversion.cli.mixin.SSCAppVersionResolverMixin.AbstractSSCAppVersionResolverMixin;

Expand All @@ -47,7 +47,7 @@ public final class SCSastControllerScanStartCommand extends AbstractSCSastContro
@Getter @Mixin private OutputHelperMixins.Start outputHelper;
private String userName = System.getProperty("user.name", "unknown"); // TODO Do we want to give an option to override this?
@Option(names = "--notify") private String email; // TODO Add email address validation
@Mixin private SensorPoolResolverMixin sensorPoolResolver;
@Mixin private SCSastSensorPoolResolverMixin.OptionalOption sensorPoolResolver;
@Mixin private PublishToAppVersionResolverMixin sscAppVersionResolver;
@Option(names = "--ssc-ci-token") private String ciToken;

Expand Down Expand Up @@ -169,10 +169,4 @@ private static final class PublishToAppVersionResolverMixin extends AbstractSSCA
@Getter private String appVersionNameOrId;
public final boolean hasValue() { return StringUtils.isNotBlank(appVersionNameOrId); }
}

private static final class SensorPoolResolverMixin extends AbstractSCSastSensorPoolResolverMixin {
@Option(names = {"--sensor-pool"}, required = false, descriptionKey = "fcli.sc-sast.sensor-pool.resolver.nameOrUuid")
@Getter private String sensorPoolNameOrUuid;
public final boolean hasValue() { return StringUtils.isNotBlank(sensorPoolNameOrUuid); }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

@Command(
name = "sensor-pool",
aliases = {"pool"},
subcommands = {
SCSastSensorPoolListCommand.class,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
*******************************************************************************/
package com.fortify.cli.sc_sast.sensor_pool.cli.mixin;

import org.apache.commons.lang3.StringUtils;

import com.fortify.cli.common.cli.util.EnvSuffix;
import com.fortify.cli.sc_sast.sensor_pool.cli.helper.SCSastSensorPoolDescriptor;
import com.fortify.cli.sc_sast.sensor_pool.cli.helper.SCSastSensorPoolHelper;

import kong.unirest.UnirestInstance;
import lombok.Getter;
import picocli.CommandLine.Option;
Expand All @@ -31,14 +34,21 @@ public SCSastSensorPoolDescriptor getSensorPoolDescriptor(UnirestInstance unires
public String getSensorPoolUuid(UnirestInstance unirest) {
return getSensorPoolDescriptor(unirest).getUuid();
}

public final boolean hasValue() { return StringUtils.isNotBlank(getSensorPoolNameOrUuid()); }
}

public static final class OptionalOption extends AbstractSCSastSensorPoolResolverMixin {
@Option(names = {"--sensor-pool", "--pool"}, required = false, descriptionKey = "fcli.sc-sast.sensor-pool.resolver.nameOrUuid")
@Getter private String sensorPoolNameOrUuid;
}

public static class RequiredOption extends AbstractSCSastSensorPoolResolverMixin {
@Option(names = {"--sensor-pool"}, required = true, descriptionKey = "fcli.sc-sast.sensor-pool.resolver.nameOrUuid")
public static final class RequiredOption extends AbstractSCSastSensorPoolResolverMixin {
@Option(names = {"--sensor-pool", "--pool"}, required = true, descriptionKey = "fcli.sc-sast.sensor-pool.resolver.nameOrUuid")
@Getter private String sensorPoolNameOrUuid;
}

public static class PositionalParameter extends AbstractSCSastSensorPoolResolverMixin {
public static final class PositionalParameter extends AbstractSCSastSensorPoolResolverMixin {
@EnvSuffix("SENSORPOOL") @Parameters(index = "0", arity = "1", descriptionKey = "fcli.sc-sast.sensor-pool.resolver.nameOrUuid")
@Getter private String sensorPoolNameOrUuid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ fcli.sc-sast.scan.wait-for.any-ssc-state=One or more SSC artifact processing sta
fcli.sc-sast.scan-job.resolver.jobToken = Scan job token.

# fcli sc-sast sensor
fcli.sc-sast.sensor.usage.header = Manage ScanCentral SAST sensors
fcli.sc-sast.sensor.list.usage.header = List ScanCentral SAST sensors
fcli.sc-sast.sensor.usage.header = Manage ScanCentral SAST sensors.
fcli.sc-sast.sensor.list.usage.header = List ScanCentral SAST sensors.
fcli.sc-sast.sensor.list.usage.description = This command lists sensor information for all \
available SanCentral SAST sensors. It calls the SSC API and as such requires an active SSC session.

# fcli sc-sast sensor-pool
fcli.sc-sast.sensor-pool.usage.header = Manage ScanCentral SAST sensor pools
fcli.sc-sast.sensor-pool.resolver.nameOrUuid = Sensor pool Uuid or Name
fcli.sc-sast.sensor-pool.list.usage.header = List ScanCentral SAST sensor pools
fcli.sc-sast.sensor-pool.usage.header = Manage ScanCentral SAST sensor pools.
fcli.sc-sast.sensor-pool.resolver.nameOrUuid = Sensor pool Uuid or Name.
fcli.sc-sast.sensor-pool.list.usage.header = List ScanCentral SAST sensor pools.

# fcli sc-sast rest
fcli.sc-sast.rest.usage.header = Interact with ScanCentral SAST Controller REST API endpoints.
Expand Down

0 comments on commit 52a7821

Please sign in to comment.