-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* allow force unit tests * tweaked phrasing * add readme stuff * tweak some formattin
- Loading branch information
1 parent
2ea4485
commit 5e8c009
Showing
10 changed files
with
210 additions
and
25 deletions.
There are no files selected for viewing
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
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 @@ | ||
import panther | ||
IGNORED_USERS = {} | ||
|
||
|
||
def policy(resource): | ||
if resource['UserName'] in IGNORED_USERS: | ||
return False | ||
|
||
cred_report = resource.get('CredentialReport', {}) | ||
if not cred_report: | ||
return True | ||
|
||
return cred_report.get('PasswordEnabled', False) and cred_report.get( | ||
'MfaActive', False) |
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 @@ | ||
AnalysisType: policy | ||
Filename: example_policy_required_tests.py | ||
DisplayName: MFA Is Enabled For User | ||
Description: MFA is a security best practice that adds an extra layer of protection for your AWS account logins. | ||
Severity: High | ||
PolicyID: IAM.MFAEnabled.Required.Tests | ||
Enabled: true | ||
ResourceTypes: | ||
- AWS.IAM.RootUser.Snapshot | ||
- AWS.IAM.User.Snapshot | ||
Tags: | ||
- AWS Managed Rules - Security, Identity & Compliance | ||
- AWS | ||
- CIS | ||
- SOC2 | ||
Runbook: > | ||
Find out who disabled MFA on the account. | ||
Reference: https://www.link-to-info.io | ||
Suppressions: | ||
- aws:resource:1 | ||
- aws:.*:other-resource | ||
Tests: | ||
- | ||
Name: Root MFA not enabled triggers a violation. | ||
ExpectedResult: false | ||
ResourceType: AWS.IAM.User.Snapshot (extraneous field) | ||
Resource: | ||
Arn: arn:aws:iam::123456789012:user/root | ||
CreateDate: 2019-01-01T00:00:00Z | ||
CredentialReport: | ||
MfaActive: false | ||
PasswordEnabled: true | ||
UserName: root |
14 changes: 14 additions & 0 deletions
14
tests/fixtures/valid_analysis/policies/example_policy_extraneous_fields.py
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 @@ | ||
import panther | ||
IGNORED_USERS = {} | ||
|
||
|
||
def policy(resource): | ||
if resource['UserName'] in IGNORED_USERS: | ||
return False | ||
|
||
cred_report = resource.get('CredentialReport', {}) | ||
if not cred_report: | ||
return True | ||
|
||
return cred_report.get('PasswordEnabled', False) and cred_report.get( | ||
'MfaActive', False) |
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
22 changes: 22 additions & 0 deletions
22
tests/fixtures/valid_analysis/rules/example_rule_extraneous_fields.py
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,22 @@ | ||
from panther import test_helper # pylint: disable=import-error | ||
|
||
IGNORED_USERS = {} | ||
|
||
|
||
def rule(event): | ||
if event['UserName'] in IGNORED_USERS: | ||
return False | ||
|
||
cred_report = event.get('CredentialReport', {}) | ||
if not cred_report: | ||
return True | ||
|
||
return (test_helper() and | ||
cred_report.get('PasswordEnabled', False) and | ||
cred_report.get('MfaActive', False)) | ||
|
||
def dedup(event): | ||
return event['UserName'] | ||
|
||
def title(event): | ||
return '{} does not have MFA enabled'.format(event['UserName']) |
2 changes: 1 addition & 1 deletion
2
tests/fixtures/valid_analysis/rules/example_rule_extraneous_fields.yml
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