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.
Merge branch 'master' into kics-1033
- Loading branch information
Showing
13 changed files
with
167 additions
and
15 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
assets/queries/ansible/config/communication_over_http/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,11 @@ | ||
{ | ||
"id": "d7dc9350-74bc-485b-8c85-fed22d276c43", | ||
"queryName": "Communication over HTTP", | ||
"severity": "MEDIUM", | ||
"category": "Insecure Configurations", | ||
"descriptionText": "Using HTTP URLs (without encryption) could lead to security vulnerabilities and risks", | ||
"descriptionUrl": "https://docs.ansible.com/ansible/latest/plugins/httpapi.html", | ||
"platform": "Ansible", | ||
"descriptionID": "8c03b0c0", | ||
"cloudProvider": "common" | ||
} |
21 changes: 21 additions & 0 deletions
21
assets/queries/ansible/config/communication_over_http/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.ansible as ansLib | ||
import data.generic.common as common_lib | ||
|
||
CxPolicy[result] { | ||
galaxyGroup := input.document[i].groups.galaxy | ||
|
||
url := galaxyGroup.server | ||
startswith(url, "http://") | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": "n/a", | ||
"resourceName": "n/a", | ||
"searchKey": "[galaxy].server", | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "'server' from galaxy group should be accessed via the HTTPS protocol", | ||
"keyActualValue": "'server' from galaxy group is accessed via the HTTP protocol'", | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
assets/queries/ansible/config/communication_over_http/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,5 @@ | ||
[galaxy] | ||
cache_dir=~/.ansible/galaxy_cache | ||
ignore_certs=False | ||
role_skeleton_ignore=^.git$, ^.*/.git_keep$ | ||
server=https://galaxy.ansible.com |
5 changes: 5 additions & 0 deletions
5
assets/queries/ansible/config/communication_over_http/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,5 @@ | ||
[galaxy] | ||
cache_dir=~/.ansible/galaxy_cache | ||
ignore_certs=False | ||
role_skeleton_ignore=^.git$, ^.*/.git_keep$ | ||
server=http://galaxy.ansible.com |
7 changes: 7 additions & 0 deletions
7
assets/queries/ansible/config/communication_over_http/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": "Communication over HTTP", | ||
"severity": "MEDIUM", | ||
"line": 5 | ||
} | ||
] |
12 changes: 12 additions & 0 deletions
12
assets/queries/ansible/config/privilege_escalation_using_become_plugin/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": "404908b6-4954-4611-98f0-e8ceacdabcb1", | ||
"queryName": "Privilege Escalation Using Become Plugin", | ||
"severity": "MEDIUM", | ||
"category": "Access Control", | ||
"descriptionText": "In order to perform an action as a different user with the become_user, 'become' must be defined and set to 'true'", | ||
"descriptionUrl": "https://docs.ansible.com/ansible/latest/plugins/become.html", | ||
"platform": "Ansible", | ||
"descriptionID": "00396668", | ||
"cloudProvider": "common" | ||
} | ||
|
38 changes: 38 additions & 0 deletions
38
assets/queries/ansible/config/privilege_escalation_using_become_plugin/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,38 @@ | ||
package Cx | ||
|
||
import data.generic.ansible as ansLib | ||
import data.generic.common as common_lib | ||
|
||
CxPolicy[result] { | ||
defaultsGroup := input.document[i].groups.defaults | ||
|
||
not common_lib.valid_key(defaultsGroup, "become") | ||
common_lib.valid_key(defaultsGroup, "become_user") | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": "n/a", | ||
"resourceName": "n/a", | ||
"searchKey": "defaults.become_user", | ||
"issueType": "MissingAttribute", | ||
"keyExpectedValue": "'become' should be defined and set to 'true'", | ||
"keyActualValue": "'become' is not defined", | ||
} | ||
} | ||
|
||
CxPolicy[result] { | ||
defaultsGroup := input.document[i].groups.defaults | ||
|
||
defaultsGroup.become == false | ||
common_lib.valid_key(defaultsGroup, "become_user") | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": "n/a", | ||
"resourceName": "n/a", | ||
"searchKey": "defaults.become", | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "'become' should be set to 'true'", | ||
"keyActualValue": "'become' is set to 'false'", | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
assets/queries/ansible/config/privilege_escalation_using_become_plugin/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,10 @@ | ||
[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 |
13 changes: 13 additions & 0 deletions
13
assets/queries/ansible/config/privilege_escalation_using_become_plugin/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,13 @@ | ||
[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 | ||
fact_caching=memory | ||
become_ask_pass=False | ||
become_method=sudo | ||
become=True | ||
become_user=root |
13 changes: 13 additions & 0 deletions
13
assets/queries/ansible/config/privilege_escalation_using_become_plugin/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,13 @@ | ||
[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 | ||
fact_caching=memory | ||
become=False | ||
become_ask_pass=False | ||
become_method=sudo | ||
become_user=root |
12 changes: 12 additions & 0 deletions
12
assets/queries/ansible/config/privilege_escalation_using_become_plugin/test/positive2.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,12 @@ | ||
[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 | ||
fact_caching=memory | ||
become_ask_pass=False | ||
become_method=sudo | ||
become_user=root |
14 changes: 14 additions & 0 deletions
14
...nsible/config/privilege_escalation_using_become_plugin/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": "Privilege Escalation Using Become Plugin", | ||
"severity": "MEDIUM", | ||
"filename": "positive1.cfg", | ||
"line": 10 | ||
}, | ||
{ | ||
"queryName": "Privilege Escalation Using Become Plugin", | ||
"severity": "MEDIUM", | ||
"filename": "positive2.cfg", | ||
"line": 12 | ||
} | ||
] |
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