use of com.mercedesbenz.sechub.commons.model.SecHubTimeUnit in project sechub by mercedes-benz.
the class WebConfigBuilderStrategy method handleMaxScanDuration.
private <B extends AbstractWebScanAdapterConfigBuilder<B, ?>> void handleMaxScanDuration(B configBuilder, SecHubWebScanConfiguration webscanConfig) {
Optional<WebScanDurationConfiguration> optMaxScanDuration = webscanConfig.getMaxScanDuration();
if (!optMaxScanDuration.isPresent()) {
return;
}
int duration = optMaxScanDuration.get().getDuration();
SecHubTimeUnit unit = optMaxScanDuration.get().getUnit();
SecHubTimeUnitData maxScanDuration = SecHubTimeUnitData.of(duration, unit);
configBuilder.setMaxScanDuration(maxScanDuration);
}
use of com.mercedesbenz.sechub.commons.model.SecHubTimeUnit in project sechub by mercedes-benz.
the class NetsparkerAdapterTestApplication method main.
public static void main(String[] args) throws Exception {
SecHubTimeUnitData maxScanDuration = null;
String maxScanDurationDurationProperty = getSystemProperty("sechub.adapter.netsparker.maxscanduration.duration");
String maxScanDurationUnitProperty = getSystemProperty("sechub.adapter.netsparker.maxscanduration.unit");
if (maxScanDurationDurationProperty != null && maxScanDurationUnitProperty != null) {
int duration = Integer.valueOf(maxScanDurationDurationProperty);
SecHubTimeUnit unit = SecHubTimeUnit.valueOf(maxScanDurationUnitProperty);
maxScanDuration = SecHubTimeUnitData.of(duration, unit);
}
/* @formatter:off */
NetsparkerConfigBuilder builder = NetsparkerConfig.builder().setUser(getSystemProperty("sechub.adapter.netsparker.user")).setTrustAllCertificates(getSystemPropertyBooleanOrFalse("sechub.adapter.netsparker.trustall")).setAgentGroupName(getSystemProperty("sechub.adapter.netsparker.user.agent.groupname")).setPasswordOrAPIToken(getSystemProperty("sechub.adapter.netsparker.apitoken")).setPolicyID(getSystemProperty("sechub.adapter.netsparker.policyid")).setProductBaseUrl(getSystemProperty("sechub.adapter.netsparker.baseurl")).setLicenseID(getSystemProperty("sechub.adapter.netsparker.licenseid", "none")).setTargetURI(new URI(getSystemProperty("sechub.adapter.netsparker.targeturi"))).setMaxScanDuration(maxScanDuration);
/* @formatter:on */
String loginType = getSystemProperty("sechub.adapter.netsparker.login.type", "<none>");
if ("basic".equalsIgnoreCase(loginType)) {
handleBasicLogin(builder);
} else if ("formAutodetect".equalsIgnoreCase(loginType)) {
handleFormAutodetect(builder);
} else if ("formScript".equalsIgnoreCase(loginType)) {
handleFormScript(builder);
} else if ("<none>".equalsIgnoreCase(loginType)) {
/* ignore */
} else {
throw new IllegalArgumentException("login type:" + loginType + " not supported!");
}
NetsparkerAdapterConfig config = builder.build();
NetsparkerAdapter netsparker = new NetsparkerAdapterV1();
String result = netsparker.start(config, new AdapterMetaDataCallback() {
AdapterMetaData metaData;
@Override
public void persist(AdapterMetaData metaData) {
System.out.println("persist:" + metaData);
this.metaData = metaData;
}
@Override
public AdapterMetaData getMetaDataOrNull() {
return metaData;
}
});
System.out.println("result:");
System.out.println(result);
}
use of com.mercedesbenz.sechub.commons.model.SecHubTimeUnit in project sechub by mercedes-benz.
the class SecHubWebScanConfigurationHelper method fetchMaxScanDurationInMillis.
public long fetchMaxScanDurationInMillis(SecHubWebScanConfiguration sechubWebConfig) {
if (!sechubWebConfig.getMaxScanDuration().isPresent()) {
return DEFAULT_MAX_SCAN_DURATION;
}
SecHubTimeUnit sechubTimeUnit = sechubWebConfig.getMaxScanDuration().get().getUnit();
int maxScanDuration = sechubWebConfig.getMaxScanDuration().get().getDuration();
switch(sechubTimeUnit) {
case DAY:
return maxScanDuration * DAYS_IN_MS;
case HOUR:
return maxScanDuration * HOURS_IN_MS;
case MINUTE:
return maxScanDuration * MINUTES_IN_MS;
case SECOND:
return maxScanDuration * SECONDS_IN_MS;
case MILLISECOND:
return maxScanDuration;
default:
return DEFAULT_MAX_SCAN_DURATION;
}
}
use of com.mercedesbenz.sechub.commons.model.SecHubTimeUnit in project sechub by mercedes-benz.
the class SecHubTimeUnitTest method from_json_second.
@ParameterizedTest
@ValueSource(strings = { "\"SECOND\"", "\"second\"", "\"seconds\"", "\"SECONDS\"" })
public void from_json_second(String json) throws JsonMappingException, JsonProcessingException {
/* prepare */
ObjectMapper objectMapper = new ObjectMapper();
/* execute */
SecHubTimeUnit unit = objectMapper.readValue(json, SecHubTimeUnit.class);
/* test */
assertEquals(SecHubTimeUnit.SECOND, unit);
}
use of com.mercedesbenz.sechub.commons.model.SecHubTimeUnit in project sechub by mercedes-benz.
the class SecHubTimeUnitTest method get_multiplicator_milliseconds__get_millisecond.
@Test
public void get_multiplicator_milliseconds__get_millisecond() {
/* execute */
SecHubTimeUnit unit = SecHubTimeUnit.MILLISECOND;
/* test */
assertNotNull(unit);
assertEquals(1, unit.getMultiplicatorMilliseconds());
}
Aggregations