mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
fix(lambdaweb): accept a policy Action of "*" or any case of lambda (#6883)
Lambda takes "*" or "<service>:<action>" with a service of letters, digits, dots and dashes. Each action names lambda in any case, unless the list also holds "*", which lets actions of other services through.
This commit is contained in:
1 parent
3f36c4e99e
commit
177f8e9360
4 files changed
+42
-4
No files matched your search
+6
@@ -533,6 +533,12 @@ class LambdaWebIntegrationTest {
|
||||
.then().statusCode(400)
|
||||
.body("message", equalTo("Lambda blocked the creation of this policy because it would grant public"
|
||||
+ " access to your function."));
|
||||
given().contentType("application/json")
|
||||
.body(Map.of("Policy", publicPolicy.replace("\"lambda:InvokeWebFunctionEndpoint\"", "\"*\"")))
|
||||
.when().put(policyPath)
|
||||
.then().statusCode(400)
|
||||
.body("message", equalTo("Lambda blocked the creation of this policy because it would grant public"
|
||||
+ " access to your function."));
|
||||
given().contentType("application/json").body(Map.of("Policy", publicPolicy.replace("\"Allow\"", "\"Maybe\"")))
|
||||
.when().put(policyPath)
|
||||
.then().statusCode(400)
|
||||
|
||||
+26
-1
@@ -944,8 +944,33 @@ class LambdaWebServiceTest {
|
||||
}
|
||||
|
||||
private static String resourcePolicy(String resource) {
|
||||
return grantPolicy("\"lambda:GetWebFunction\"", resource);
|
||||
}
|
||||
|
||||
private static String grantPolicy(String action, String resource) {
|
||||
return "{\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"000000000000\"},"
|
||||
+ "\"Action\":\"lambda:GetWebFunction\",\"Resource\":" + resource + "}]}";
|
||||
+ "\"Action\":" + action + ",\"Resource\":" + resource + "}]}";
|
||||
}
|
||||
|
||||
@Test
|
||||
void aPolicyActionIsAStarOrALambdaActionInAnyCase() {
|
||||
LambdaWebService service = service();
|
||||
String missing = "arn:aws:lambda:us-east-1:000000000000:web-function/missing";
|
||||
for (String accepted : List.of("\"*\"", "\"Lambda:GetWebFunction\"", "\"LAMBDA:GetWebFunction\"", "\"lambda:\"",
|
||||
"\"lambda:*x\"", "\"lambda:Get?ebFunction\"", "\"lambda:a b!c\"", "[\"*\",\"s3:GetObject\"]",
|
||||
"[\"s3:GetObject\",\"*\"]", "[\"*\",\"*\"]", "[\"*\",\"a.b:x\"]", "[\"*\",\"9:x\"]", "[\"*\",\"s3:\"]",
|
||||
"[\"lambda:GetWebFunction\",\"Lambda:x\"]")) {
|
||||
assertEquals("ResourceNotFoundException", error(() -> service.putResourcePolicy(REGION, missing,
|
||||
policy(grantPolicy(accepted, "\"" + missing + "\"")))).getErrorCode(), accepted);
|
||||
}
|
||||
for (String refused : List.of("\"lambda*\"", "\"*:*\"", "\"*:GetWebFunction\"", "\" lambda:GetWebFunction\"",
|
||||
"\"lambda :GetWebFunction\"", "\"lambda\"", "\"**\"", "\"*x\"", "\"?\"", "\"lambda::x\"", "\"\"",
|
||||
"\"s3:GetObject\"", "[\"lambda:GetWebFunction\",\"s3:GetObject\"]", "[\"lambda:*\",\"s3:GetObject\"]",
|
||||
"[\"*\",\"garbage\"]", "[\"*\",\"\"]", "[\"*\",\"lambda::x\"]", "[\"*\",\"a_b:x\"]", "[\"*\",\"a+b:x\"]",
|
||||
"[\"*\",\"l*:x\"]")) {
|
||||
assertEquals("Policy has syntax errors.", message(() -> service.putResourcePolicy(REGION, missing,
|
||||
policy(grantPolicy(refused, "\"" + missing + "\"")))), refused);
|
||||
}
|
||||
}
|
||||
|
||||
private static String principalPolicy(String effect, String principal, String functionArn) {
|
||||
|
||||
Reference in new issue
Block a user