Skip to content

Commit

Permalink
feat(query): cloud formation api gateway access logging disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioSCX committed Jan 30, 2024
1 parent 1f4a7af commit c54628a
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"id": "999ecb35-10df-4d73-8f17-3f4b8c3beec5",
"queryName": "API Gateway Access Logging Disabled",
"severity": "MEDIUM",
"category": "Observability",
"descriptionText": "API Gateway should have Access Log Settings defined",
"descriptionUrl": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-stage.html",
"platform": "CloudFormation",
"descriptionID": "d7151524",
"cloudProvider": "aws",
"cwe": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package Cx

import data.generic.cloudformation as cf_lib

CxPolicy[result] {
doc := input.document[i]
res := doc.Resources[stage]
properties := res.Properties
res.Type == "AWS::ApiGatewayV2::Stage"

not properties.AccessLogSettings

result := {
"documentId": doc.id,
"issueType": "MissingAttribute",
"keyExpectedValue": "'AccessLogSettings' should be defined",
"keyActualValue": "'AccessLogSettings' is not defined",
"resourceType": res.Type,
"resourceName": cf_lib.get_resource_name(res, stage),
"searchKey": sprintf("Resources.%s.Properties", [stage]),
}
}

CxPolicy[result] {
doc := input.document[i]
res := doc.Resources[stage]
properties := res.Properties
res.Type == "AWS::ApiGateway::Stage"

not properties.AccessLogSetting

result := {
"documentId": doc.id,
"issueType": "MissingAttribute",
"keyExpectedValue": "'AccessLogSetting' should be defined",
"keyActualValue": "'AccessLogSetting' is not defined",
"resourceType": res.Type,
"resourceName": cf_lib.get_resource_name(res, stage),
"searchKey": sprintf("Resources.%s.Properties", [stage]),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"MyStage": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
"StageName": "Prod",
"Description": "Prod Stage",
"AccessLogSettings": {
"DestinationArn": "dest",
"Format": "format"
},
"DeploymentId": {
"Ref": "MyDeployment"
},
"ApiId": {
"Ref": "CFNWebSocket"
},
"DefaultRouteSettings": {
"DetailedMetricsEnabled": true,
"LoggingLevel": "INFO",
"DataTraceEnabled": false,
"ThrottlingBurstLimit": 10,
"ThrottlingRateLimit": 10
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"AWSTemplateFormatVersion": "2010-09-09T00:00:00Z",
"Resources": {
"NewAmpApp-1": {
"Type": "AWS::Amplify::App",
"Properties": {
"OauthToken": "String",
"Repository": "String",
"BasicAuthConfig": {
"Username": "admin",
"EnableBasicAuth": true,
"Password": "@skdsjdk0234!AB"
},
"CustomHeaders": "String",
"Description": "String",
"Name": "NewAmpApp",
"BuildSpec": "String",
"EnableBranchAutoDeletion": true,
"IAMServiceRole": "String"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"MyStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"StageName": "Prod",
"Description": "Prod Stage",
"AccessLogSetting": {
"DestinationArn": "dest",
"Format": "format"
},
"DeploymentId": {
"Ref": "MyDeployment"
},
"RestApiId": {
"Ref": "CFNWebSocket"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"MyStage": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
"StageName": "Prod",
"Description": "Prod Stage",
"DeploymentId": {
"Ref": "MyDeployment"
},
"ApiId": {
"Ref": "CFNWebSocket"
},
"DefaultRouteSettings": {
"DetailedMetricsEnabled": true,
"LoggingLevel": "INFO",
"DataTraceEnabled": false,
"ThrottlingBurstLimit": 10,
"ThrottlingRateLimit": 10
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"MyStage": {
"Type": "AWS::ApiGateway::Stage",
"Properties": {
"StageName": "Prod",
"Description": "Prod Stage",
"DeploymentId": {
"Ref": "MyDeployment"
},
"RestApiId": {
"Ref": "CFNWebSocket"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"queryName": "API Gateway Access Logging Disabled",
"severity": "MEDIUM",
"line": 6,
"filename": "positive1.json"
},
{
"queryName": "API Gateway Access Logging Disabled",
"severity": "MEDIUM",
"line": 6,
"filename": "positive2.json"
}
]

0 comments on commit c54628a

Please sign in to comment.