feat(outputS): Output generation format CSV (#1230)

* chore(csv): first version csv output

* chore(pytest): added pytest dependency

* chore(outputs): organizations demo

* chore(compliance): Added new dataclass for each compliance framework

* fix(test org values): deleted test values in orgs instantiation

* fix(csv): formatted to match output format

* fix(csv output): Reformulation of check report and minor changes

* fix(minor issues): Fix various issues coming from PR comments

* fix(csv): Renamed csv output data model

* fix(output dir): create default if not present

* fix(typo): remove s

* fix(oldcode)

* fix(typo)

* fix(output): Only send to csv when -M is passed

Co-authored-by: sergargar <sergio@verica.io>
Co-authored-by: Pepe Fagoaga <pepe@verica.io>
This commit is contained in:
Nacho Rivera
2022-07-04 10:30:47 +02:00
committed by GitHub
parent a1dcc1310a
commit 11652838e2
16 changed files with 532 additions and 90 deletions

View File

@@ -19,6 +19,17 @@
"level2"
],
"Version": "1.4"
},
{
"Control": [
"4.4"
],
"Framework": "PCI-DSS",
"Group": [
"level1",
"level2"
],
"Version": "1.4"
}
],
"DependsOn": [

View File

@@ -10,24 +10,24 @@ class ec2_ebs_snapshots_encrypted(Check):
if hasattr(regional_client, "snapshots"):
if regional_client.snapshots:
for snapshot in regional_client.snapshots:
report = Check_Report(self.metadata)
report.region = region
if snapshot["Encrypted"]:
report = Check_Report()
report.status = "PASS"
report.result_extended = (
report.status_extended = (
f"EBS Snapshot {snapshot['SnapshotId']} is encrypted"
)
report.region = region
report.resource_id = snapshot["SnapshotId"]
else:
report = Check_Report()
report.status = "FAIL"
report.result_extended = (
report.status_extended = (
f"EBS Snapshot {snapshot['SnapshotId']} is unencrypted"
)
report.region = region
report.resource_id = snapshot["SnapshotId"]
else:
report = Check_Report()
report = Check_Report(self.metadata)
report.status = "PASS"
report.result_extended = "There are no EC2 EBS snapshots"
report.status_extended = "There are no EC2 EBS snapshots"
report.region = region
findings.append(report)

View File

@@ -13,7 +13,10 @@ class iam_disable_30_days_credentials(Check):
if response:
for user in response:
report = Check_Report()
report = Check_Report(self.metadata)
report.resource_id = user["UserName"]
report.resource_arn = user["Arn"]
report.region = "us-east-1"
if "PasswordLastUsed" in user and user["PasswordLastUsed"] != "":
try:
time_since_insertion = (
@@ -22,23 +25,21 @@ class iam_disable_30_days_credentials(Check):
)
if time_since_insertion.days > maximum_expiration_days:
report.status = "FAIL"
report.result_extended = f"User {user['UserName']} has not logged into the console in the past 30 days"
report.region = iam_client.region
report.status_extended = f"User {user['UserName']} has not logged into the console in the past 30 days"
else:
report.status = "PASS"
report.result_extended = f"User {user['UserName']} has logged into the console in the past 30 days"
report.region = iam_client.region
report.status_extended = f"User {user['UserName']} has logged into the console in the past 30 days"
except KeyError:
pass
else:
report.status = "PASS"
report.result_extended = f"User {user['UserName']} has not a console password or is unused."
report.region = iam_client.region
report.status_extended = f"User {user['UserName']} has not a console password or is unused."
# Append report
findings.append(report)
else:
report = Check_Report()
report = Check_Report(self.metadata)
report.status = "PASS"
report.result_extended = "There is no IAM users"
report.region = iam_client.region

View File

@@ -13,7 +13,10 @@ class iam_disable_90_days_credentials(Check):
if response:
for user in response:
report = Check_Report()
report = Check_Report(self.metadata)
report.region = "us-east-1"
report.resource_id = user["UserName"]
report.resource_arn = user["Arn"]
if "PasswordLastUsed" in user and user["PasswordLastUsed"] != "":
try:
time_since_insertion = (
@@ -22,25 +25,23 @@ class iam_disable_90_days_credentials(Check):
)
if time_since_insertion.days > maximum_expiration_days:
report.status = "FAIL"
report.result_extended = f"User {user['UserName']} has not logged into the console in the past 90 days"
report.region = iam_client.region
report.status_extended = f"User {user['UserName']} has not logged into the console in the past 90 days"
else:
report.status = "PASS"
report.result_extended = f"User {user['UserName']} has logged into the console in the past 90 days"
report.region = iam_client.region
report.status_extended = f"User {user['UserName']} has logged into the console in the past 90 days"
except KeyError:
pass
else:
report.status = "PASS"
report.result_extended = f"User {user['UserName']} has not a console password or is unused."
report.region = iam_client.region
report.status_extended = f"User {user['UserName']} has not a console password or is unused."
# Append report
findings.append(report)
else:
report = Check_Report()
report = Check_Report(self.metadata)
report.status = "PASS"
report.result_extended = "There is no IAM users"
report.region = iam_client.region
report.status_extended = "There is no IAM users"
report.region = "us-east-1"
return findings