Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from donebd/task/4.7.1-support
Browse files Browse the repository at this point in the history
Task/4.7.1 support
  • Loading branch information
alyadusov authored Jun 6, 2024
2 parents 06bbb93 + 7ef8170 commit 64a620e
Show file tree
Hide file tree
Showing 96 changed files with 26,560 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,5 @@
+ [Feature] Advanced setting ast.diagnostic.json.filename added. Its value defines file name where AST job execution details like scan status, PT AI agent name, policy assessment result, etc. will be saved to
### 20240320
+ [Feature] PT AI v.4.7.0 support approved
### 20240429
+ [Feature] PT AI v.4.7.1 support approved
1 change: 1 addition & 0 deletions docs/new-version-support-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ To add new PT AI version we need to:

## Add new OpenAPI definitions to ptai-rest-api module
- Download definitions from https://${your.ptai.server}/swagger/vXXX/swagger.yaml and save it as `ptai-rest-api/src/main/resources/api/vXXX/original/yml/swagger.yaml` file
- For ScanResultModel v4.7.1^ remove `format: date-time` of queueDate, cause model has two different date format, which can't be resolved
- As original definition defines global "Bearer" authentication scheme but we need to use API key for initial authentication, move all the /api/auth endpoints and type definitions into `ptai-rest-api/src/main/resources/api/vXXX/auth.yaml` file. Add API key security scheme to `auth.yaml`
- Save original `swagger.yaml` with /api/auth definitions removed as `ptai-rest-api/src/main/resources/api/vXXX/swagger.yaml` file
- Use online OpenAPI editor to quickly find and fix semantic errors in `swagger.yaml` like `Declared path parameter "language" needs to be defined as a path parameter at either the path or operation level`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import static com.ptsecurity.misc.tools.helpers.CallHelper.call;

@Slf4j
@VersionRange(min = { 4, 7, 0, 0 }, max = { 4, 7, 99999, 99999 })
@VersionRange(min = { 4, 7, 0, 0 }, max = { 4, 7, 0, 99999 })
public class ApiClient extends AbstractApiClient {
@Getter
protected final String id = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public static ProjectSettingsModel apply(

model.setSourceType(SourceType.EMPTY);
model.setProjectName(settings.getProjectName());
model.setWhiteBoxSettings(apply(settings, new WhiteBoxSettingsModel()));
model.setDotNetSettings(apply(settings, new DotNetSettingsModel()));
model.setJsaDotNetSettings(apply(settings, new JsaDotNetSettingsModel()));
model.setJavaSettings(apply(settings, new JavaSettingsModel()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ptsecurity.appsec.ai.ee.utils.ci.integration.api.v470.tasks;

import com.ptsecurity.appsec.ai.ee.scan.settings.AiProjV13ScanSettings;
import com.ptsecurity.appsec.ai.ee.scan.settings.Policy;
import com.ptsecurity.appsec.ai.ee.scan.settings.UnifiedAiProjScanSettings;
import com.ptsecurity.appsec.ai.ee.server.v470.api.ApiException;
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.ptsecurity.appsec.ai.ee.utils.ci.integration.api.v471.converters;

import com.ptsecurity.appsec.ai.ee.scan.progress.Stage;
import lombok.NonNull;

import java.util.HashMap;
import java.util.Map;

public class EnumsConverter {
public static final Map<com.ptsecurity.appsec.ai.ee.server.v471.api.model.Stage, Stage> PROJECT_STAGE_MAP = new HashMap<>();
public static final Map<com.ptsecurity.appsec.ai.ee.server.v471.notifications.model.Stage, Stage> NOTIFICATION_STAGE_MAP = new HashMap<>();

static {
for (com.ptsecurity.appsec.ai.ee.server.v471.api.model.Stage stage : com.ptsecurity.appsec.ai.ee.server.v471.api.model.Stage.values())
PROJECT_STAGE_MAP.put(stage, Stage.valueOf(stage.name().toUpperCase()));
for (com.ptsecurity.appsec.ai.ee.server.v471.notifications.model.Stage stage : com.ptsecurity.appsec.ai.ee.server.v471.notifications.model.Stage.values())
NOTIFICATION_STAGE_MAP.put(stage, Stage.valueOf(stage.name().toUpperCase()));
}

@NonNull
public static Stage convert(@NonNull final com.ptsecurity.appsec.ai.ee.server.v471.api.model.Stage stage) {
return PROJECT_STAGE_MAP.get(stage);
}

@NonNull
public static Stage convert(@NonNull final com.ptsecurity.appsec.ai.ee.server.v471.notifications.model.Stage stage) {
return NOTIFICATION_STAGE_MAP.get(stage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.ptsecurity.appsec.ai.ee.utils.ci.integration.api.v471.converters;

import com.ptsecurity.appsec.ai.ee.HealthData;
import com.ptsecurity.appsec.ai.ee.server.v471.api.model.HealthCheckServiceResult;
import com.ptsecurity.appsec.ai.ee.server.v471.api.model.HealthCheckSummaryResult;
import com.ptsecurity.appsec.ai.ee.server.v471.api.model.HealthStatus;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Slf4j
public class HealthDataConverter {
@NonNull
public static HealthData convert(@NonNull final HealthCheckSummaryResult health) {
List<HealthData.Service> services = new ArrayList<>();
if (null == health.getServices() || health.getServices().isEmpty()) {
log.warn("Health data services list is empty");
log.trace(health.toString());
} else {
for (HealthCheckServiceResult serviceHealth : health.getServices()) {
if (null == serviceHealth) continue;
services.add(convert(serviceHealth));
}
}
return HealthData.builder().services(services).build();
}

@NonNull
public static HealthData.Service convert(@NonNull final HealthCheckServiceResult serviceHealth) {
return HealthData.Service.builder()
.name(Objects.requireNonNull(serviceHealth.getService(), "Health data service name is null"))
.ok(HealthStatus.HEALTHY == Objects.requireNonNull(serviceHealth.getStatus(), "Health data service status is null"))
.build();
}
}
Loading

0 comments on commit 64a620e

Please sign in to comment.