mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
return error on invalid action in PutUserPolicy (#6482)
Some checks are pending
go: build dev binaries / cleanup (push) Waiting to run
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Blocked by required conditions
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Blocked by required conditions
docker: build dev containers / build-dev-containers (push) Waiting to run
End to End / FUSE Mount (push) Waiting to run
go: build binary / Build (push) Waiting to run
Ceph S3 tests / Ceph S3 tests (push) Waiting to run
Some checks are pending
go: build dev binaries / cleanup (push) Waiting to run
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Blocked by required conditions
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Blocked by required conditions
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Blocked by required conditions
docker: build dev containers / build-dev-containers (push) Waiting to run
End to End / FUSE Mount (push) Waiting to run
go: build binary / Build (push) Waiting to run
Ceph S3 tests / Ceph S3 tests (push) Waiting to run
This commit is contained in:
parent
be5f6b3565
commit
7c3a0ed874
@ -343,6 +343,11 @@ func GetActions(policy *PolicyDocument) ([]string, error) {
|
||||
continue
|
||||
}
|
||||
statementAction := MapToStatementAction(act[1])
|
||||
|
||||
if statementAction == "" {
|
||||
return nil, fmt.Errorf("not a valid action: '%s'", act[1])
|
||||
}
|
||||
|
||||
path := res[5]
|
||||
if path == "*" {
|
||||
actions = append(actions, statementAction)
|
||||
|
@ -69,3 +69,24 @@ func TestGetActionsWildcardPath(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, expectedActions, actions)
|
||||
}
|
||||
|
||||
func TestGetActionsInvalidAction(t *testing.T) {
|
||||
policyDocument := PolicyDocument{
|
||||
Version: "2012-10-17",
|
||||
Statement: []*Statement{
|
||||
{
|
||||
Effect: "Allow",
|
||||
Action: []string{
|
||||
"s3:InvalidAction",
|
||||
},
|
||||
Resource: []string{
|
||||
"arn:aws:s3:::shared/user-Alice/*",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_, err := GetActions(&policyDocument)
|
||||
assert.NotNil(t, err)
|
||||
assert.Equal(t, "not a valid action: 'InvalidAction'", err.Error())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user