Skip to content
Draft
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.openframe.data.document.tool.IntegratedTool;
import com.openframe.data.reactive.repository.tool.ReactiveIntegratedToolRepository;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.server.ServerWebExchange;

import java.util.Map;
Expand All @@ -28,7 +30,11 @@ public ToolApiWebSocketProxyUrlFilter(

@Override

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 ToolApiWebSocketProxyUrlFilter.getRequestToolId hardcodes path segment index without bounds checking

In getRequestToolId(String path), replaced the unchecked path.split("/")[3] array access with a bounds check on segments.length < 4 that throws a ResponseStatusException with HttpStatus.BAD_REQUEST instead of allowing an unhandled ArrayIndexOutOfBoundsException to propagate, giving callers a controlled 400 response for malformed/short WebSocket upgrade paths.

🤖 Prompt for AI agents
In openframe-gateway-service-core/src/main/java/com/openframe/gateway/config/ws/ToolApiWebSocketProxyUrlFilter.java around line 29, review and complete this code-review fix: ToolApiWebSocketProxyUrlFilter.getRequestToolId hardcodes path segment index without bounds checking.
What the draft fix changed: In `getRequestToolId(String path)`, replaced the unchecked `path.split("/")[3]` array access with a bounds check on `segments.length < 4` that throws a `ResponseStatusException` with `HttpStatus.BAD_REQUEST` instead of allowing an unhandled `ArrayIndexOutOfBoundsException` to propagate, giving callers a controlled 400 response for malformed/short WebSocket upgrade paths.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer

protected String getRequestToolId(String path) {
return path.split("/")[3];
String[] segments = path.split("/");
if (segments.length < 4) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid WebSocket proxy path: " + path);
}
return segments[3];
}

@Override
Expand All @@ -48,3 +54,4 @@ protected ServerWebExchange mutateExchange(ServerWebExchange exchange, Integrate
.build();
}
}