Skip to content

Commit

Permalink
chore: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Sep 20, 2023
1 parent 072c13c commit 7510977
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 117 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@
*/
package com.fortify.cli.fod.assessment_type.helper;

import java.time.Instant;
import java.util.Date;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fortify.cli.common.json.JsonHelper;
import com.fortify.cli.common.progress.helper.IProgressWriterI18n;
import com.fortify.cli.fod._common.rest.FoDUrls;
import com.fortify.cli.fod._common.util.FoDEnums;
import com.fortify.cli.fod.scan.helper.FoDScanType;

import kong.unirest.GetRequest;
import kong.unirest.UnirestInstance;
import lombok.Getter;

import java.time.Instant;
import java.util.Date;
import java.util.Optional;

public final class FoDAssessmentTypeHelper {
@Getter
private static final ObjectMapper objectMapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@

package com.fortify.cli.fod.scan.cli.cmd;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;

import com.fasterxml.jackson.databind.JsonNode;
import com.fortify.cli.common.output.transform.IActionCommandResultSupplier;
import com.fortify.cli.common.output.transform.IRecordTransformer;
Expand All @@ -34,19 +41,13 @@
import com.fortify.cli.fod.scan.helper.dast.FoDScanDastStartRequest;
import com.fortify.cli.fod.scan_config.helper.FoDScanConfigDastDescriptor;
import com.fortify.cli.fod.scan_config.helper.FoDScanConfigDastHelper;

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

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;

@Command(name = FoDOutputHelperMixins.StartDast.CMD_NAME)
public class FoDScanStartDastCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

package com.fortify.cli.fod.scan.cli.cmd;

import java.io.File;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;

import com.fasterxml.jackson.databind.JsonNode;
import com.fortify.cli.common.output.transform.IActionCommandResultSupplier;
import com.fortify.cli.common.output.transform.IRecordTransformer;
Expand All @@ -31,29 +39,20 @@
import com.fortify.cli.fod.scan.helper.FoDScanType;
import com.fortify.cli.fod.scan.helper.mobile.FoDScanMobileHelper;
import com.fortify.cli.fod.scan.helper.mobile.FoDScanMobileStartRequest;

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

import java.io.File;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;

@Command(name = FoDOutputHelperMixins.StartMobile.CMD_NAME)
public class FoDScanStartMobileCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm");
@Getter @Mixin private FoDOutputHelperMixins.StartMobile outputHelper;
@Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins
@Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.PositionalParameter releaseResolver;
private enum MobileAssessmentTypes { Mobile, MobilePlus, Remediation }
@Option(names = {"--assessment-type"}, required = true)
//private MobileAssessmentTypes mobileAssessmentType;
private String mobileAssessmentType;
@Option(names = {"--entitlement-id"})
private Integer entitlementId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

package com.fortify.cli.fod.scan.cli.cmd;

import java.io.File;
import java.util.Properties;

import com.fasterxml.jackson.databind.JsonNode;
import com.fortify.cli.common.output.transform.IActionCommandResultSupplier;
import com.fortify.cli.common.output.transform.IRecordTransformer;
Expand All @@ -28,15 +31,13 @@
import com.fortify.cli.fod.scan.helper.sast.FoDScanSastHelper;
import com.fortify.cli.fod.scan.helper.sast.FoDScanSastStartRequest;
import com.fortify.cli.fod.scan_config.helper.FoDScanConfigSastDescriptor;

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

import java.io.File;
import java.util.Properties;

@Command(name = FoDOutputHelperMixins.StartSast.CMD_NAME)
public class FoDScanStartSastCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier {
@Getter @Mixin private FoDOutputHelperMixins.StartSast outputHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,25 @@

package com.fortify.cli.fod.scan.helper;

import static java.util.function.Predicate.not;

import java.util.Optional;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fortify.cli.common.json.JsonHelper;
import com.fortify.cli.common.output.transform.fields.RenameFieldsTransformer;
import com.fortify.cli.common.progress.helper.IProgressWriterI18n;
import com.fortify.cli.fod._common.rest.FoDUrls;
import com.fortify.cli.fod._common.util.FoDEnums;
import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeDescriptor;
import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeHelper;
import com.fortify.cli.fod.rest.lookup.helper.FoDLookupDescriptor;
import com.fortify.cli.fod.rest.lookup.helper.FoDLookupHelper;
import com.fortify.cli.fod.rest.lookup.helper.FoDLookupType;

import kong.unirest.UnirestInstance;
import lombok.Getter;

import java.util.Optional;

import static java.util.function.Predicate.not;

// TODO Class contains some fairly long methods; consider splitting methods
public class FoDScanHelper {
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import com.fortify.cli.common.progress.helper.IProgressWriterI18n;
import com.fortify.cli.fod._common.rest.FoDUrls;
import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper;
import com.fortify.cli.fod._common.rest.helper.FoDUploadResponse;
import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor;
import com.fortify.cli.fod.scan.helper.FoDScanDescriptor;
import com.fortify.cli.fod.scan.helper.FoDScanHelper;
import com.fortify.cli.fod.scan.helper.FoDScanType;
import com.fortify.cli.fod.scan.helper.FoDStartScanResponse;

import kong.unirest.HttpRequest;
import kong.unirest.UnirestInstance;
Expand All @@ -50,8 +50,8 @@ public static final FoDScanDescriptor startScan(UnirestInstance unirest, IProgre
request = request.queryString("entitlementId", req.getEntitlementId());
}

JsonNode uploadResponse = FoDFileTransferHelper.uploadChunked(unirest, request, scanFile);
FoDUploadResponse startScanResponse = JsonHelper.treeToValue(uploadResponse, FoDUploadResponse.class);
JsonNode response = FoDFileTransferHelper.uploadChunked(unirest, request, scanFile);
FoDStartScanResponse startScanResponse = JsonHelper.treeToValue(response, FoDStartScanResponse.class);
if (startScanResponse == null || startScanResponse.getScanId() <= 0) {
throw new RuntimeException("Unable to retrieve scan id from response when starting Static scan.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,29 @@

package com.fortify.cli.fod.scan.helper.sast;

import java.io.File;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fortify.cli.common.json.JsonHelper;
import com.fortify.cli.common.util.StringUtils;
import com.fortify.cli.fod._common.rest.FoDUrls;
import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper;
import com.fortify.cli.fod._common.rest.helper.FoDUploadResponse;
import com.fortify.cli.fod._common.util.FoDConstants;
import com.fortify.cli.fod._common.util.FoDEnums;
import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor;
import com.fortify.cli.fod.scan.helper.FoDScanDescriptor;
import com.fortify.cli.fod.scan.helper.FoDScanHelper;
import com.fortify.cli.fod.scan.helper.FoDScanType;
import com.fortify.cli.fod.scan.helper.FoDStartScanResponse;
import com.fortify.cli.fod.scan_config.helper.FoDScanConfigSastDescriptor;

import kong.unirest.GetRequest;
import kong.unirest.HttpRequest;
import kong.unirest.UnirestInstance;
import lombok.Getter;

import java.io.File;

public class FoDScanSastHelper extends FoDScanHelper {
@Getter
private static final ObjectMapper objectMapper = new ObjectMapper();
Expand Down Expand Up @@ -79,8 +80,8 @@ public static final FoDScanDescriptor startScanAdvanced(UnirestInstance unirest,
}

private static FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, HttpRequest<?> request, File scanFile) {
JsonNode uploadResponse = FoDFileTransferHelper.uploadChunked(unirest, request, scanFile);
FoDUploadResponse startScanResponse = JsonHelper.treeToValue(uploadResponse, FoDUploadResponse.class);
JsonNode response = FoDFileTransferHelper.uploadChunked(unirest, request, scanFile);
FoDStartScanResponse startScanResponse = JsonHelper.treeToValue(response, FoDStartScanResponse.class);
if (startScanResponse == null || startScanResponse.getScanId() <= 0) {
throw new RuntimeException("Unable to retrieve scan id from response when starting Static scan.");
}
Expand Down

0 comments on commit 7510977

Please sign in to comment.