mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(core): prevent REST JSON requests falling through to S3 (#3498)
This commit is contained in:
1 parent
cfe9f84ffe
commit
e62e99f060
4 files changed
+125
-1
No files matched your search
+21
@@ -1,8 +1,10 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -19,6 +21,11 @@ import static org.hamcrest.Matchers.containsString;
|
||||
@TestProfile(UnknownServiceScopeGuardDisabledIntegrationTest.GuardDisabledProfile.class)
|
||||
class UnknownServiceScopeGuardDisabledIntegrationTest {
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsupportedScopeFallsThroughWhenRejectionDisabled() {
|
||||
given()
|
||||
@@ -33,6 +40,20 @@ class UnknownServiceScopeGuardDisabledIntegrationTest {
|
||||
.body(containsString("<Code>NoSuchBucket</Code>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void knownRestJsonScopeFallsThroughWhenRejectionDisabled() {
|
||||
given()
|
||||
.header("Authorization", "AWS4-HMAC-SHA256 Credential=test/20260707/us-east-1/bedrock"
|
||||
+ "/aws4_request, SignedHeaders=host;x-amz-date, Signature=deadbeef")
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.body("{\"name\":\"probe\"}")
|
||||
.when()
|
||||
.post("/prompts")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("<Code>InvalidArgument</Code>"));
|
||||
}
|
||||
|
||||
public static final class GuardDisabledProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
|
||||
+36
@@ -1,6 +1,8 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -17,6 +19,11 @@ import static org.hamcrest.Matchers.not;
|
||||
@QuarkusTest
|
||||
class UnknownServiceScopeGuardIntegrationTest {
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
private static String authorization(String service) {
|
||||
return "AWS4-HMAC-SHA256 Credential=test/20260707/us-east-1/" + service
|
||||
+ "/aws4_request, SignedHeaders=host;x-amz-date, Signature=deadbeef";
|
||||
@@ -38,6 +45,35 @@ class UnknownServiceScopeGuardIntegrationTest {
|
||||
.body("__type", equalTo("UnknownOperationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void knownRestJsonScopeCannotFallThroughToS3Wildcard() {
|
||||
given()
|
||||
.header("Authorization", authorization("bedrock"))
|
||||
.contentType("application/x-amz-json-1.1")
|
||||
.body("{\"name\":\"probe\"}")
|
||||
.when()
|
||||
.post("/prompts")
|
||||
.then()
|
||||
.statusCode(404)
|
||||
.contentType(containsString("application/json"))
|
||||
.header("X-Amzn-Errortype", "UnknownOperationException")
|
||||
.body("__type", equalTo("UnknownOperationException"))
|
||||
.body("message", equalTo("Unknown operation: POST /prompts"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bedrockScopeStillReachesBedrockRuntimeRoutes() {
|
||||
given()
|
||||
.header("Authorization", authorization("bedrock"))
|
||||
.contentType("application/json")
|
||||
.body("{\"prompt\":\"hello\"}")
|
||||
.when()
|
||||
.post("/model/test-model/invoke")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.contentType(containsString("application/json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void s3ScopedRequestKeepsS3Behavior() {
|
||||
given()
|
||||
|
||||
Reference in new issue
Block a user