Skip to content

Commit

Permalink
fix: Added X-Amz-Bypass-Governance-Retention header check to both che…
Browse files Browse the repository at this point in the history
…ck 'true' and 'True' values for DeleteObject(s) actions.
  • Loading branch information
0x180 committed Jul 22, 2024
1 parent d521c66 commit 12da1e2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions s3api/controllers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ func (c S3ApiController) PutActions(ctx *fiber.Ctx) error {
}

bypassHdr := ctx.Get("X-Amz-Bypass-Governance-Retention")
bypass := bypassHdr == "true"
bypass := strings.EqualFold(bypassHdr, "true")
if bypass {
policy, err := c.be.GetBucketPolicy(ctx.Context(), bucket)
if err != nil {
Expand Down Expand Up @@ -2289,7 +2289,7 @@ func (c S3ApiController) DeleteObjects(ctx *fiber.Ctx) error {
acct := ctx.Locals("account").(auth.Account)
isRoot := ctx.Locals("isRoot").(bool)
parsedAcl := ctx.Locals("parsedAcl").(auth.ACL)
bypass := ctx.Get("X-Amz-Bypass-Governance-Retention")
bypassHdr := ctx.Get("X-Amz-Bypass-Governance-Retention")
var dObj s3response.DeleteObjects

err := xml.Unmarshal(ctx.Body(), &dObj)
Expand Down Expand Up @@ -2326,7 +2326,10 @@ func (c S3ApiController) DeleteObjects(ctx *fiber.Ctx) error {
})
}

err = auth.CheckObjectAccess(ctx.Context(), bucket, acct.Access, utils.ParseDeleteObjects(dObj.Objects), bypass == "true", c.be)
// The AWS CLI sends 'True', while Go SDK sends 'true'
bypass := strings.EqualFold(bypassHdr, "true")

err = auth.CheckObjectAccess(ctx.Context(), bucket, acct.Access, utils.ParseDeleteObjects(dObj.Objects), bypass, c.be)
if err != nil {
return SendResponse(ctx, err,
&MetaOpts{
Expand Down Expand Up @@ -2365,7 +2368,7 @@ func (c S3ApiController) DeleteActions(ctx *fiber.Ctx) error {
acct := ctx.Locals("account").(auth.Account)
isRoot := ctx.Locals("isRoot").(bool)
parsedAcl := ctx.Locals("parsedAcl").(auth.ACL)
bypass := ctx.Get("X-Amz-Bypass-Governance-Retention")
bypassHdr := ctx.Get("X-Amz-Bypass-Governance-Retention")

if keyEnd != "" {
key = strings.Join([]string{key, keyEnd}, "/")
Expand Down Expand Up @@ -2470,7 +2473,10 @@ func (c S3ApiController) DeleteActions(ctx *fiber.Ctx) error {
})
}

err = auth.CheckObjectAccess(ctx.Context(), bucket, acct.Access, []string{key}, bypass == "true", c.be)
// The AWS CLI sends 'True', while Go SDK sends 'true'
bypass := strings.EqualFold(bypassHdr, "true")

err = auth.CheckObjectAccess(ctx.Context(), bucket, acct.Access, []string{key}, bypass, c.be)
if err != nil {
return SendResponse(ctx, err,
&MetaOpts{
Expand Down

0 comments on commit 12da1e2

Please sign in to comment.