Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend] Add payload elevation required #1410

Merged
merged 11 commits into from
Sep 17, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.openbas.migration;

import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.springframework.stereotype.Component;

import java.sql.Statement;

@Component
public class V3_37__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 payloads ADD payload_elevation_required bool default false;");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@

@JsonProperty("payload_attack_patterns")
private List<String> attackPatternsExternalIds = new ArrayList<>();

@JsonProperty("payload_elevation_required")
private boolean elevationRequired;

Check warning on line 81 in openbas-api/src/main/java/io/openbas/rest/payload/form/PayloadUpsertInput.java

View check run for this annotation

Codecov / codecov/patch

openbas-api/src/main/java/io/openbas/rest/payload/form/PayloadUpsertInput.java#L81

Added line #L81 was not covered by tests
}


Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.UuidGenerator;
Expand Down Expand Up @@ -94,6 +95,11 @@ public enum PAYLOAD_STATUS {
@JsonProperty("payload_cleanup_command")
private String cleanupCommand;

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

@Setter
@Type(JsonType.class)
@Column(name = "payload_arguments")
Expand Down Expand Up @@ -159,7 +165,7 @@ public enum PAYLOAD_STATUS {

@JsonProperty("payload_collector_type")
private String getCollectorType() {
return this.getCollector() != null ? this.getCollector().getType() : null;
return this.collector != null ? this.collector.getType() : null;
}

@Override
Expand Down
Loading