Skip to content

Commit

Permalink
[backend] add elevation_required into paylaod model
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 committed Sep 11, 2024
1 parent 8c789b7 commit 64da7e5
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
import java.sql.Statement;

@Component
public class V3_34__Add_column_requires_elevation extends BaseJavaMigration {
public class V3_34__Add_column_elevation_required_payload extends BaseJavaMigration {

@Override
public void migrate(final Context context) throws Exception {
final Statement select = context.getConnection().createStatement();
select.execute("ALTER TABLE asset_agent_jobs ADD asset_agent_elevation_required bool default false;");
select.execute("ALTER TABLE payloads ADD payload_elevation_required bool default false;");
}
}
5 changes: 0 additions & 5 deletions openbas-api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ logging.logback.rollingpolicy.file-name-pattern=${LOG_FILE}.-%d{yyyy-MM-dd}.%i
logging.logback.rollingpolicy.max-file-size=10MB
logging.logback.rollingpolicy.max-history=7


# Non-system service account credentials for OpenBAS agent
openbas.agent.non-system-user=<nonsystemuser>
openbas.agent.non-system-pwd=<ChangeMe>

#############
# EXECUTORS #
#############
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.openbas.asset;

import io.openbas.config.OpenBASAgentConfig;
import io.openbas.config.OpenBASConfig;
import io.openbas.database.model.Endpoint;
import io.openbas.database.repository.EndpointRepository;
Expand Down Expand Up @@ -34,9 +33,6 @@ public class EndpointService {
@Resource
private OpenBASConfig openBASConfig;

@Resource
private OpenBASAgentConfig openBASAgentConfig;

@Value("${openbas.admin.token:#{null}}")
private String adminToken;

Expand Down Expand Up @@ -113,9 +109,7 @@ public String getFileOrDownloadFromJfrog(String platform, String file, String ad
}
return IOUtils.toString(in, StandardCharsets.UTF_8)
.replace("${OPENBAS_URL}", openBASConfig.getBaseUrl())
.replace("${OPENBAS_TOKEN}", adminToken)
.replace("${NON_SYSTEM_USER}", openBASAgentConfig.getNonSystemUser())
.replace("${NON_SYSTEM_PWD}", openBASAgentConfig.getNonSystemPwd());
.replace("${OPENBAS_TOKEN}", adminToken);
}

public String generateInstallCommand(String platform, String token) throws IOException {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,10 @@ public void launchExecutorSubprocess(@NotNull final Inject inject, @NotNull fina
assetAgentJob.setCommand(computeCommand(inject, platform, arch));
assetAgentJob.setAsset(asset);
assetAgentJob.setInject(inject);
assetAgentJob.setElevationRequired(this.isElevationRequired(inject));
assetAgentJobRepository.save(assetAgentJob);
}

public void launchExecutorClear(@NotNull final Injector injector, @NotNull final Asset asset) {
// TODO
}

private boolean isElevationRequired(final Inject inject) {
return inject.getInjectorContract().map(injectorContract -> injectorContract.getPayload()).map(payload->payload.isElevationRequired()).orElse(false).booleanValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public class AssetAgentJob implements Base {
@NotBlank
private String command;

@Getter
@Column(name = "asset_agent_elevation_required")
@JsonProperty("asset_agent_elevation_required")
private boolean elevationRequired;

@Override
public String toString() {
return this.id;
Expand Down

0 comments on commit 64da7e5

Please sign in to comment.