forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query to check if MQ Broker is publicly accessible for CF Checkma…
- Loading branch information
1 parent
3ba36a6
commit 3a9cb87
Showing
7 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
assets/queries/cloudFormation/mq_broker_is_publicly_accessible/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "68b6a789-82f8-4cfd-85de-e95332fe6a61", | ||
"queryName": "MQ Broker Is Publicly Accessible", | ||
"severity": "MEDIUM", | ||
"category": "Insecure Configurations", | ||
"descriptionText": "Check if any MQ Broker is not publicly accessible", | ||
"descriptionUrl": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-publiclyaccessible", | ||
"platform": "CloudFormation" | ||
} |
19 changes: 19 additions & 0 deletions
19
assets/queries/cloudFormation/mq_broker_is_publicly_accessible/query.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package Cx | ||
|
||
CxPolicy[result] { | ||
document := input.document | ||
resource = document[i].Resources[name] | ||
resource.Type == "AWS::AmazonMQ::Broker" | ||
properties := resource.Properties | ||
object.get(properties, "PubliclyAccessible", "undefined") != "undefined" | ||
|
||
properties.PubliclyAccessible | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"searchKey": sprintf("Resources.%s.Properties.PubliclyAccessible", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": sprintf("Resources.%s.Properties.PubliclyAccessible is false or undefined", [name]), | ||
"keyActualValue": sprintf("Resources.%s.Properties.PubliclyAccessible is true", [name]), | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
assets/queries/cloudFormation/mq_broker_is_publicly_accessible/test/negative1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
Description: "Create a basic ActiveMQ broker" | ||
Resources: | ||
BasicBroker: | ||
Type: "AWS::AmazonMQ::Broker" | ||
Properties: | ||
AutoMinorVersionUpgrade: "false" | ||
BrokerName: MyBasicBroker | ||
DeploymentMode: SINGLE_INSTANCE | ||
EncryptionOptions: | ||
UseAwsOwnedKey: true | ||
EngineType: ActiveMQ | ||
EngineVersion: "5.15.0" | ||
HostInstanceType: mq.t2.micro | ||
PubliclyAccessible: false | ||
Users: | ||
- | ||
ConsoleAccess: "true" | ||
Groups: | ||
- MyGroup | ||
Password: | ||
Ref: "BrokerPassword" | ||
Username: | ||
Ref: "BrokerUsername" |
34 changes: 34 additions & 0 deletions
34
assets/queries/cloudFormation/mq_broker_is_publicly_accessible/test/negative2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"AWSTemplateFormatVersion": "2010-09-09", | ||
"Description": "Create a basic ActiveMQ broker", | ||
"Resources": { | ||
"BasicBroker2": { | ||
"Type": "AWS::AmazonMQ::Broker", | ||
"Properties": { | ||
"BrokerName": "MyBasicBroker", | ||
"DeploymentMode": "SINGLE_INSTANCE", | ||
"EncryptionOptions": { | ||
"UseAwsOwnedKey": true | ||
}, | ||
"EngineType": "ActiveMQ", | ||
"EngineVersion": "5.15.0", | ||
"HostInstanceType": "mq.t2.micro", | ||
"Users": [ | ||
{ | ||
"ConsoleAccess": "true", | ||
"Groups": [ | ||
"MyGroup" | ||
], | ||
"Password": { | ||
"Ref": "BrokerPassword" | ||
}, | ||
"Username": { | ||
"Ref": "BrokerUsername" | ||
} | ||
} | ||
], | ||
"AutoMinorVersionUpgrade": "false" | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
assets/queries/cloudFormation/mq_broker_is_publicly_accessible/test/positive1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
Description: "Create a basic ActiveMQ broker" | ||
Resources: | ||
BasicBroker: | ||
Type: "AWS::AmazonMQ::Broker" | ||
Properties: | ||
AutoMinorVersionUpgrade: "false" | ||
BrokerName: MyBasicBroker | ||
DeploymentMode: SINGLE_INSTANCE | ||
EncryptionOptions: | ||
UseAwsOwnedKey: true | ||
EngineType: ActiveMQ | ||
EngineVersion: "5.15.0" | ||
HostInstanceType: mq.t2.micro | ||
PubliclyAccessible: true | ||
Users: | ||
- | ||
ConsoleAccess: "true" | ||
Groups: | ||
- MyGroup | ||
Password: | ||
Ref: "BrokerPassword" | ||
Username: | ||
Ref: "BrokerUsername" |
35 changes: 35 additions & 0 deletions
35
assets/queries/cloudFormation/mq_broker_is_publicly_accessible/test/positive2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"AWSTemplateFormatVersion": "2010-09-09", | ||
"Description": "Create a basic ActiveMQ broker", | ||
"Resources": { | ||
"BasicBroker2": { | ||
"Type": "AWS::AmazonMQ::Broker", | ||
"Properties": { | ||
"BrokerName": "MyBasicBroker", | ||
"DeploymentMode": "SINGLE_INSTANCE", | ||
"EncryptionOptions": { | ||
"UseAwsOwnedKey": true | ||
}, | ||
"EngineType": "ActiveMQ", | ||
"EngineVersion": "5.15.0", | ||
"HostInstanceType": "mq.t2.micro", | ||
"Users": [ | ||
{ | ||
"ConsoleAccess": "true", | ||
"Groups": [ | ||
"MyGroup" | ||
], | ||
"Password": { | ||
"Ref": "BrokerPassword" | ||
}, | ||
"Username": { | ||
"Ref": "BrokerUsername" | ||
} | ||
} | ||
], | ||
"AutoMinorVersionUpgrade": "false", | ||
"PubliclyAccessible": true | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ueries/cloudFormation/mq_broker_is_publicly_accessible/test/positive_expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"queryName": "MQ Broker Is Publicly Accessible", | ||
"severity": "MEDIUM", | ||
"line": 15, | ||
"fileName": "positive1.yaml" | ||
}, | ||
{ | ||
"queryName": "MQ Broker Is Publicly Accessible", | ||
"severity": "MEDIUM", | ||
"line": 31, | ||
"fileName": "positive2.json" | ||
} | ||
] |