-
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 #6626 from Checkmarx/kics-968-allow-unsafe-lookups
feat(query): ansible config allow unsafe lookups
- Loading branch information
Showing
8 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
assets/queries/ansible/config/allow_unsafe_lookups_enabled/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": "86b97bb4-85c9-462d-8635-cbc057c5c8c5", | ||
"queryName": "Allow Unsafe Lookups Enabled", | ||
"severity": "HIGH", | ||
"category": "Insecure Configurations", | ||
"descriptionText": "When enabled, this option allows lookup plugins to return data that is not marked 'unsafe'.", | ||
"descriptionUrl": "https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-allow-unsafe-lookups", | ||
"platform": "Ansible", | ||
"descriptionID": "0d491461", | ||
"cloudProvider": "common" | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
assets/queries/ansible/config/allow_unsafe_lookups_enabled/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 | ||
|
||
import data.generic.ansible as ansLib | ||
|
||
CxPolicy[result] { | ||
defaultsGroup := input.document[i].groups.defaults | ||
|
||
defaultsGroup.allow_unsafe_lookups == true | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceName": "defaults", | ||
"resourceType": "n/a", | ||
"searchKey": "defaults.allow_unsafe_lookups", | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "allow_unsafe_lookups should be set to 'False'", | ||
"keyActualValue": "allow_unsafe_lookups is set to 'True'", | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
assets/queries/ansible/config/allow_unsafe_lookups_enabled/test/negative1.cfg
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 @@ | ||
[defaults] | ||
action_warnings=True | ||
cowsay_enabled_stencils=bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in-snake, elephant, eyes, hellokitty, kitty, luke-koala, meow, milk, moofasa, moose, ren, sheep, small, stegosaurus, stimpy, supermilker, three-eyes, turkey, turtle, tux, udder, vader-koala, vader, www | ||
cow_selection=default | ||
force_color=False | ||
nocolor=False | ||
nocows=False | ||
any_errors_fatal=False | ||
become_plugins=~/.ansible/plugins/become:/usr/share/ansible/plugins/become | ||
fact_caching=memory | ||
fact_caching_prefix=ansible_facts | ||
fact_caching_timeout=86400 | ||
collections_on_ansible_version_mismatch=warning | ||
collections_path=~/.ansible/collections:/usr/share/ansible/collections | ||
collections_scan_sys_path=True | ||
command_warnings=False | ||
action_plugins=~/.ansible/plugins/action:/usr/share/ansible/plugins/action | ||
|
||
allow_unsafe_lookups=False |
17 changes: 17 additions & 0 deletions
17
assets/queries/ansible/config/allow_unsafe_lookups_enabled/test/negative2.cfg
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,17 @@ | ||
[defaults] | ||
action_warnings=True | ||
cowsay_enabled_stencils=bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in-snake, elephant, eyes, hellokitty, kitty, luke-koala, meow, milk, moofasa, moose, ren, sheep, small, stegosaurus, stimpy, supermilker, three-eyes, turkey, turtle, tux, udder, vader-koala, vader, www | ||
cow_selection=default | ||
force_color=False | ||
nocolor=False | ||
nocows=False | ||
any_errors_fatal=False | ||
become_plugins=~/.ansible/plugins/become:/usr/share/ansible/plugins/become | ||
fact_caching=memory | ||
fact_caching_prefix=ansible_facts | ||
fact_caching_timeout=86400 | ||
collections_on_ansible_version_mismatch=warning | ||
collections_path=~/.ansible/collections:/usr/share/ansible/collections | ||
collections_scan_sys_path=True | ||
command_warnings=False | ||
action_plugins=~/.ansible/plugins/action:/usr/share/ansible/plugins/action |
19 changes: 19 additions & 0 deletions
19
assets/queries/ansible/config/allow_unsafe_lookups_enabled/test/positive1.cfg
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 @@ | ||
[defaults] | ||
action_warnings=True | ||
cowsay_enabled_stencils=bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in-snake, elephant, eyes, hellokitty, kitty, luke-koala, meow, milk, moofasa, moose, ren, sheep, small, stegosaurus, stimpy, supermilker, three-eyes, turkey, turtle, tux, udder, vader-koala, vader, www | ||
cow_selection=default | ||
force_color=False | ||
nocolor=False | ||
nocows=False | ||
any_errors_fatal=False | ||
become_plugins=~/.ansible/plugins/become:/usr/share/ansible/plugins/become | ||
fact_caching=memory | ||
fact_caching_prefix=ansible_facts | ||
fact_caching_timeout=86400 | ||
collections_on_ansible_version_mismatch=warning | ||
collections_path=~/.ansible/collections:/usr/share/ansible/collections | ||
collections_scan_sys_path=True | ||
command_warnings=False | ||
action_plugins=~/.ansible/plugins/action:/usr/share/ansible/plugins/action | ||
|
||
allow_unsafe_lookups=True |
7 changes: 7 additions & 0 deletions
7
...ts/queries/ansible/config/allow_unsafe_lookups_enabled/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,7 @@ | ||
[ | ||
{ | ||
"queryName": "Allow Unsafe Lookups Enabled", | ||
"severity": "HIGH", | ||
"line": 19 | ||
} | ||
] |
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