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

Upgrade to libddwaf 1.18.0 (libddwaf-java 10.0.0) #7006

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dd-java-agent/appsec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
implementation project(':internal-api')
implementation project(':communication')
implementation project(':telemetry')
implementation group: 'io.sqreen', name: 'libsqreen', version: '9.1.1'
implementation group: 'io.sqreen', name: 'libsqreen', version: '10.0.0'
implementation group: 'com.squareup.moshi', name: 'moshi', version: versions.moshi

testImplementation deps.bytebuddy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,13 @@ public void onDataAvailable(
log.warn("WAF signalled result {}: {}", resultWithData.result, resultWithData.data);
}

for (String action : resultWithData.actions) {
ActionInfo actionInfo = ctxAndAddr.actionInfoMap.get(action);
if (actionInfo == null) {
log.warn(
"WAF indicated action {}, but such action id is unknown (not one from {})",
action,
ctxAndAddr.actionInfoMap.keySet());
} else if ("block_request".equals(actionInfo.type)) {
for (Map.Entry<String, Map<String, Object>> action : resultWithData.actions.entrySet()) {
String actionType = action.getKey();
Map<String, Object> actionParams = action.getValue();

ActionInfo actionInfo = new ActionInfo(actionType, actionParams);

if ("block_request".equals(actionInfo.type)) {
Flow.Action.RequestBlockingAction rba = createBlockRequestAction(actionInfo);
flow.setAction(rba);
break;
Expand All @@ -467,8 +466,15 @@ public void onDataAvailable(

private Flow.Action.RequestBlockingAction createBlockRequestAction(ActionInfo actionInfo) {
try {
int statusCode =
((Number) actionInfo.parameters.getOrDefault("status_code", 403)).intValue();
int statusCode;
Object statusCodeObj = actionInfo.parameters.get("status_code");
if (statusCodeObj instanceof Number) {
statusCode = ((Number) statusCodeObj).intValue();
} else if (statusCodeObj instanceof String) {
statusCode = Integer.parseInt((String) statusCodeObj);
} else {
statusCode = 403;
}
String contentType = (String) actionInfo.parameters.getOrDefault("type", "auto");
BlockingContentType blockingContentType = BlockingContentType.AUTO;
try {
Expand All @@ -485,8 +491,15 @@ private Flow.Action.RequestBlockingAction createBlockRequestAction(ActionInfo ac

private Flow.Action.RequestBlockingAction createRedirectRequestAction(ActionInfo actionInfo) {
try {
int statusCode =
((Number) actionInfo.parameters.getOrDefault("status_code", 303)).intValue();
int statusCode;
Object statusCodeObj = actionInfo.parameters.get("status_code");
if (statusCodeObj instanceof Number) {
statusCode = ((Number) statusCodeObj).intValue();
} else if (statusCodeObj instanceof String) {
statusCode = Integer.parseInt((String) statusCodeObj);
} else {
statusCode = 303;
}
if (statusCode < 300 || statusCode > 399) {
statusCode = 303;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ class PowerWAFModuleSpecification extends DDSpecification {
when:
setupWithStubConfigService()
// first initialization to exercise the update path
service.listeners['waf'].onNewSubconfig(service.currentAppSecConfig, reconf)
service.currentAppSecConfig.dirtyStatus.clearDirty()
dataListener = pwafModule.dataSubscriptions.first()

def actions = [
[
Expand Down
Loading