Package org.sonar.iac.terraform.checks
Class AbstractResourceCheck
- java.lang.Object
-
- org.sonar.iac.terraform.checks.AbstractResourceCheck
-
- All Implemented Interfaces:
IacCheck
- Direct Known Subclasses:
AnonymousAccessPolicyCheck,AnonymousAccessToResourceCheck,AwsClearTextProtocolsCheckPart,AwsIpRestrictedAdminAccessCheckPart,AwsPrivilegePolicyCheckPart,AwsTagNameConventionCheck,AwsWeakSSLProtocolCheckPart,AzureIpRestrictedAdminAccessCheckPart,CertificateBasedAuthenticationCheck,HighPrivilegedRoleCheck,ManagedIdentityCheck,PublicApiCheck,ResourceAccessPolicyCheck,ResourceSpecificAdminAccountCheck,SubscriptionRoleAssignmentCheck
public abstract class AbstractResourceCheck extends Object implements IacCheck
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceCheck()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckResource(CheckContext ctx, BlockTree resource)static StringgetReferenceLabel(BlockTree resource)static StringgetResourceType(BlockTree tree)static booleanhasReferenceLabel(BlockTree resource)voidinitialize(InitContext init)static booleanisResource(BlockTree tree)static booleanisResource(BlockTree tree, String type)static booleanisS3Bucket(BlockTree tree)static booleanisS3BucketResource(BlockTree tree)protected voidregister(BiConsumer<CheckContext,BlockTree> resourceCheck)protected voidregister(BiConsumer<CheckContext,BlockTree> resourceCheck, String... resourceNames)protected voidregisterResourceChecks()protected static voidreportOnFalse(CheckContext ctx, AttributeTree attribute, String message, SecondaryLocation... secondaries)protected static voidreportOnTrue(CheckContext ctx, AttributeTree attribute, String message, SecondaryLocation... secondaries)static voidreportResource(CheckContext ctx, BlockTree resource, String message)protected static voidreportSensitiveValue(CheckContext ctx, AttributeTree attribute, String sensitiveValue, String message, SecondaryLocation... secondaries)protected static voidreportUnexpectedValue(CheckContext ctx, AttributeTree attribute, String expectedValue, String message, SecondaryLocation... secondaries)
-
-
-
Field Detail
-
S3_BUCKET
public static final String S3_BUCKET
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
public void initialize(InitContext init)
- Specified by:
initializein interfaceIacCheck
-
registerResourceChecks
protected void registerResourceChecks()
-
register
protected void register(BiConsumer<CheckContext,BlockTree> resourceCheck)
-
register
protected void register(BiConsumer<CheckContext,BlockTree> resourceCheck, String... resourceNames)
-
checkResource
protected void checkResource(CheckContext ctx, BlockTree resource)
-
isResource
public static boolean isResource(BlockTree tree)
-
hasReferenceLabel
public static boolean hasReferenceLabel(BlockTree resource)
-
isS3Bucket
public static boolean isS3Bucket(BlockTree tree)
-
isS3BucketResource
public static boolean isS3BucketResource(BlockTree tree)
-
reportResource
public static void reportResource(CheckContext ctx, BlockTree resource, String message)
-
reportOnTrue
protected static void reportOnTrue(CheckContext ctx, AttributeTree attribute, String message, SecondaryLocation... secondaries)
-
reportOnFalse
protected static void reportOnFalse(CheckContext ctx, AttributeTree attribute, String message, SecondaryLocation... secondaries)
-
reportUnexpectedValue
protected static void reportUnexpectedValue(CheckContext ctx, AttributeTree attribute, String expectedValue, String message, SecondaryLocation... secondaries)
-
reportSensitiveValue
protected static void reportSensitiveValue(CheckContext ctx, AttributeTree attribute, String sensitiveValue, String message, SecondaryLocation... secondaries)
-
-