Skip to content

Commit

Permalink
SONARPY-1015 Remove unrelated argument check for S6281 (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-werner-sonarsource authored May 10, 2022
1 parent dbd7115 commit 287ac6b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.sonar.plugins.python.api.tree.CallExpression;
import org.sonar.plugins.python.api.tree.Expression;
import org.sonar.plugins.python.api.tree.QualifiedExpression;
import org.sonar.plugins.python.api.tree.Token;
import org.sonar.plugins.python.api.tree.Tree;

@Rule(key = "S6281")
Expand All @@ -48,12 +47,6 @@ public class S3BucketBlockPublicAccessCheck extends AbstractS3BucketCheck {

@Override
void visitBucketConstructor(SubscriptionContext ctx, CallExpression bucket) {
Optional<ArgumentTrace> publicReadAccess = getArgument(ctx, bucket, "public_read_access");
if (publicReadAccess.isPresent()) {
publicReadAccess.get().addIssueIf(S3BucketBlockPublicAccessCheck::isTrue, MESSAGE);
return;
}

Optional<ArgumentTrace> blockPublicAccess = getArgument(ctx, bucket, "block_public_access");
if (blockPublicAccess.isPresent()) {
checkBlockPublicAccess(ctx, blockPublicAccess.get());
Expand Down Expand Up @@ -94,8 +87,4 @@ private static boolean isBlockPublicAccessConstructor(CallExpression expression)
return Optional.ofNullable(expression.calleeSymbol()).map(Symbol::fullyQualifiedName).filter(BLOCK_PUBLIC_ACCESS_FQN::equals).isPresent();
}

private static boolean isTrue(Expression expression) {
return Optional.ofNullable(expression.firstToken()).map(Token::value).filter("True"::equals).isPresent();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
block_public_access=public_access_only_block_acls_by_reference) # NonCompliant {{Make sure allowing public ACL/policies to be set is safe here.}}
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

bucket = s3.Bucket(self, "AllowPublicReadAccess",
public_read_access=True) # NonCompliant {{Make sure allowing public ACL/policies to be set is safe here.}}

public_read_access = True
# ^^^^^^^^^^^^^^^^^^^^^^^^^> {{Propagated setting.}}
bucket = s3.Bucket(self, "AllowPublicReadAccessByReference",
public_read_access=public_read_access) # NonCompliant {{Make sure allowing public ACL/policies to be set is safe here.}}
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

bucket = s3.Bucket(self, "SingleUnblockPublicAccesses",
block_public_access=s3.BlockPublicAccess(
block_public_acls=False, # NonCompliant {{Make sure allowing public ACL/policies to be set is safe here.}}
Expand Down

0 comments on commit 287ac6b

Please sign in to comment.