-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6691 from Checkmarx/kics-968-ansible_tower_expose…
…d_to_internet feat(query): ansible hosts ansible tower exposed to internet
- Loading branch information
Showing
10 changed files
with
178 additions
and
5 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
assets/queries/ansible/hosts/ansible_tower_exposed_to_internet/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,12 @@ | ||
{ | ||
"id": "1b2bf3ff-31e9-460e-bbfb-45e48f4f20cc", | ||
"queryName": "Ansible Tower Exposed To Internet", | ||
"severity": "MEDIUM", | ||
"category": "Best Practices", | ||
"descriptionText": "Avoid exposing Ansible Tower to the public internet, effectively reducing the potential attack surface of your deployment", | ||
"descriptionUrl": "https://docs.ansible.com/ansible-tower/latest/html/administration/security_best_practices.html#understand-the-architecture-of-ansible-and-tower", | ||
"platform": "Ansible", | ||
"cloudProvider": "common", | ||
"descriptionID": "657a8b1d" | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
assets/queries/ansible/hosts/ansible_tower_exposed_to_internet/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,21 @@ | ||
package Cx | ||
|
||
import data.generic.common as common_lib | ||
|
||
CxPolicy[result] { | ||
doc := input.document[id].all | ||
doc.children.tower.hosts[ip] | ||
|
||
not common_lib.isPrivateIP(ip) | ||
|
||
result := { | ||
"documentId": input.document[id].id, | ||
"hostname": "tower", | ||
"resourceName": "children", | ||
"resourceType": "n/a", | ||
"searchKey": "all.children.tower.hosts", | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "Ansible Tower IP should be private", | ||
"keyActualValue": "Ansible Tower IP is public", | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
assets/queries/ansible/hosts/ansible_tower_exposed_to_internet/test/negative1.ini
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,4 @@ | ||
[tower] | ||
172.27.0.2 | ||
172.27.0.3 | ||
172.27.0.4 |
33 changes: 33 additions & 0 deletions
33
assets/queries/ansible/hosts/ansible_tower_exposed_to_internet/test/negative2.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,33 @@ | ||
all: | ||
children: | ||
automationhub: | ||
hosts: | ||
automationhub.acme.org: | ||
admin_password: <password> | ||
pg_database: awx | ||
pg_host: database-01.acme.org | ||
pg_password: <password> | ||
pg_port: '5432' | ||
pg_sslmode: prefer | ||
pg_username: awx | ||
database: | ||
hosts: | ||
database-01.acme.org: | ||
admin_password: <password> | ||
pg_database: awx | ||
pg_host: database-01.acme.org | ||
pg_password: <password> | ||
pg_port: '5432' | ||
pg_sslmode: prefer | ||
pg_username: awx | ||
tower: | ||
hosts: | ||
172.27.0.5: | ||
admin_password: <password> | ||
pg_database: awx | ||
pg_host: database-01.acme.org | ||
pg_password: <password> | ||
pg_port: '5432' | ||
pg_sslmode: prefer | ||
pg_username: awx | ||
ungrouped: {} |
14 changes: 14 additions & 0 deletions
14
assets/queries/ansible/hosts/ansible_tower_exposed_to_internet/test/positive1.ini
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 @@ | ||
[tower] | ||
150.50.1.1 | ||
[automationhub] | ||
automationhub.acme.org | ||
[database] | ||
database-01.acme.org | ||
[all:vars] | ||
admin_password='<password>' | ||
pg_host='database-01.acme.org' | ||
pg_port='5432' | ||
pg_database='awx' | ||
pg_username='awx' | ||
pg_password='<password>' | ||
pg_sslmode='prefer' |
33 changes: 33 additions & 0 deletions
33
assets/queries/ansible/hosts/ansible_tower_exposed_to_internet/test/positive2.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,33 @@ | ||
all: | ||
children: | ||
automationhub: | ||
hosts: | ||
automationhub.acme.org: | ||
admin_password: <password> | ||
pg_database: awx | ||
pg_host: database-01.acme.org | ||
pg_password: <password> | ||
pg_port: '5432' | ||
pg_sslmode: prefer | ||
pg_username: awx | ||
database: | ||
hosts: | ||
database-01.acme.org: | ||
admin_password: <password> | ||
pg_database: awx | ||
pg_host: database-01.acme.org | ||
pg_password: <password> | ||
pg_port: '5432' | ||
pg_sslmode: prefer | ||
pg_username: awx | ||
tower: | ||
hosts: | ||
139.50.1.1: | ||
admin_password: <password> | ||
pg_database: awx | ||
pg_host: database-01.acme.org | ||
pg_password: <password> | ||
pg_port: '5432' | ||
pg_sslmode: prefer | ||
pg_username: awx | ||
ungrouped: {} |
14 changes: 14 additions & 0 deletions
14
...ueries/ansible/hosts/ansible_tower_exposed_to_internet/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": "Ansible Tower Exposed To Internet", | ||
"severity": "MEDIUM", | ||
"line": 1, | ||
"fileName": "positive1.ini" | ||
}, | ||
{ | ||
"queryName": "Ansible Tower Exposed To Internet", | ||
"severity": "MEDIUM", | ||
"line": 24, | ||
"fileName": "positive2.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
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
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