Skip to content

Commit

Permalink
change the way cloudAccountId is parsed from Job Paramaters (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohammad Zuber Khan <[email protected]>
  • Loading branch information
mzkhan and Mohammad Zuber Khan authored Sep 1, 2020
1 parent afd8f07 commit dfbd7ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ def parse(self, payload):
finding_info = notification_info.get("FindingInfo", None)
source_bucket = finding_info.get("ObjectId", None)

cloud_account = remediation_entry.get("cloudAccount")
role_arn = cloud_account.get("roleArn")
cloud_account_id = role_arn.split(":")[4]
object_chain = remediation_entry["notificationInfo"]["FindingInfo"][
"ObjectChain"
]
object_chain_dict = json.loads(object_chain)
cloud_account_id = object_chain_dict["cloudAccountId"]
region = finding_info.get("Region")

logging.info(f"cloud_account_id: {cloud_account_id}")
Expand Down
8 changes: 0 additions & 8 deletions test/unit/test_s3_enable_access_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ def invalid_payload():
def full_payload():
return json.dumps(
{
"cloudAccount": {
"provider": "",
"roleArn": "arn:aws:iam::530342348278:role/SecureStateRemediation",
},
"notificationInfo": {
"RuleId": "5c6cc5cc03dcc90f3631468d",
"RuleName": "",
Expand Down Expand Up @@ -117,10 +113,6 @@ def full_payload():
def self_payload():
return json.dumps(
{
"cloudAccount": {
"provider": "",
"roleArn": "arn:aws:iam::530342348278:role/SecureStateRemediation",
},
"notificationInfo": {
"RuleId": "5c6cc5cc03dcc90f3631468d",
"RuleName": "",
Expand Down

0 comments on commit dfbd7ce

Please sign in to comment.