Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add kisa_isms_p_2023_aws, kisa_isms_p_2023_korean_aws complianc… #31

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/pip_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spaceone-core
spaceone-api
prowler==4.3.3
prowler==4.4
natsort
5 changes: 5 additions & 0 deletions src/plugin/conf/collector_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
"FedRamp-Moderate-Revision-4": "fedramp_moderate_revision_4_aws",
"FedRAMP-Low-Revision-4": "fedramp_low_revision_4_aws",
"ISO27001-2013": "iso27001_2013_aws",
"KISA-ISMS-P-2023": "kisa_isms_p_2023_aws",
"KISA-ISMS-P-2023-korean": "kisa_isms_p_2023_korean_aws"
},
"google_cloud": {
"CIS-2.0": "cis_2.0_gcp",
Expand Down Expand Up @@ -106,6 +108,7 @@
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-southeast-5",
"ca-central-1",
"ca-west-1",
"cn-north-1",
Expand Down Expand Up @@ -153,6 +156,7 @@
"ConfigService": "config",
"DirectoryService": "directoryservice",
"Data Lifecycle Manager": "dlm",
"Database Migration Service": "dms",
"DocumentDB": "documentdb",
"DRS": "drs",
"DynamoDB": "dynamodb",
Expand Down Expand Up @@ -219,6 +223,7 @@
"AKS (Azure Kubernetes Service)": "aks",
"App": "app",
"AppInsights": "appinsights",
"ContainerRegistry": "containerregistry",
"CosmosDB": "cosmosdb",
"Defender": "defender",
"Entra": "entra",
Expand Down
21 changes: 10 additions & 11 deletions src/plugin/manager/prowler_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from typing import Generator, List

from natsort import natsorted
from prowler.lib.check.check import bulk_load_compliance_frameworks, bulk_load_checks_metadata
from prowler.lib.check.compliance_models import Compliance
from prowler.lib.check.models import CheckMetadata
from spaceone.inventory.plugin.collector.lib import make_cloud_service, make_error_response

from plugin.error.custom import *
Expand Down Expand Up @@ -166,7 +167,7 @@ def _convert_results(self, compliance_results):
total_check_count += 1
if check["status"] == "FAIL":
fail_check_count += 1
elif check["status"] == "INFO":
elif check["status"] == "INFO" or check["status"] == "MANUAL":
info_check_count += 1
else:
pass_check_count += 1
Expand Down Expand Up @@ -302,7 +303,7 @@ def _update_check_status_and_stats(check: dict, status: str, score: int) -> dict
check["status"] = "FAIL"
check["stats"]["score"]["fail"] += score
check["stats"]["findings"]["fail"] += 1
elif status == "INFO":
elif status == "INFO" or status == "MANUAL":
if check["status"] != "FAIL":
check["status"] = "INFO"
check["stats"]["findings"]["info"] += 1
Expand All @@ -322,7 +323,7 @@ def _update_compliance_status_and_stats(
compliance_result_data["status"] = "FAIL"
compliance_result_data["stats"]["score"]["fail"] += score
compliance_result_data["stats"]["findings"]["fail"] += 1
elif status == "INFO":
elif status == "INFO" or status == "MANUAL":
if compliance_result_data["status"] != "FAIL":
compliance_result_data["status"] = "INFO"

Expand All @@ -346,12 +347,12 @@ def _make_base_compliance_result(
self, compliance_id: str, requirement_id: str, requirement_seq: int, check_id: str, severity: str,
check_result: dict
) -> dict:
requirement_name, automation, requirement_unsupported = next(
((requirement['Description'], requirement['Automation'], requirement['Unsupported'])
requirement_name, automation = next(
((requirement['Description'], requirement['Automation'])
for requirement in self.requirement_info[self.cloud_service_type]['Requirements']
if requirement['Requirement_Seq'] == requirement_seq
),
(None, None, None)
(None, None)
)
account = compliance_id.split(":")[2]

Expand All @@ -365,7 +366,7 @@ def _make_base_compliance_result(
"requirement_seq": requirement_seq,
"automation": automation,
"description": check_result["finding_info"]["desc"] if check_id else "",
"status": "UNSUPPORTED" if requirement_unsupported else ("PASS" if check_id else "UNKNOWN"),
"status": "UNSUPPORTED" if not automation else ("PASS" if check_id else "UNKNOWN"),
"severity": severity if check_id else "",
"service": check_result["resources"][0]["group"]["name"] if check_id else "",
"checks": {},
Expand Down Expand Up @@ -434,7 +435,7 @@ def _check_compliance_framework(self):
def _load_requirement_info(self):
frameworks = {}
compliance_framework = COMPLIANCE_FRAMEWORKS[self.provider][self.cloud_service_type]
compliance_frameworks = bulk_load_compliance_frameworks(
compliance_frameworks = Compliance.get_bulk(
self.provider if self.provider != "google_cloud" else "gcp"
)
sorted_requirements = natsorted(compliance_frameworks[compliance_framework].Requirements,
Expand All @@ -447,8 +448,6 @@ def _load_requirement_info(self):
requirement_checks = requirement_json.get('Checks', [])
requirement_json['Requirement_Seq'] = i + 1
requirement_json['Automation'] = bool(requirement_checks)
requirement_json['Unsupported'] = not requirement_checks or (
bool(self.checklist) and not bool(set(self.checklist) & set(requirement_checks)))
frameworks[self.cloud_service_type]['Requirements'].append(requirement_json)

self.requirement_info = frameworks
3 changes: 3 additions & 0 deletions src/plugin/metadata/prowler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ search:
- PASS: "PASS"
- FAIL: "FAIL"
- INFO: "INFO"
- MANUAL: "MANUAL"
- UNSUPPORTED: "UNSUPPORTED"
- UNKNOWN: "UNKNOWN"
- Compliance Score: data.stats.score.percent
Expand Down Expand Up @@ -42,6 +43,8 @@ table:
type: badge
- INFO: peacock.500
type: badge
- MANUAL: peacock.500
type: badge
- PASS: indigo.500
type: badge
- UNSUPPORTED: peacock.500
Expand Down
3 changes: 2 additions & 1 deletion src/plugin/metrics/Prowler/Compliance/compliance_count.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ query_options:
filter:
- key: cloud_service_group
value: Prowler
operator: eq
unit: Count
namespace_id: ns-prowler-compliance
version: '1.0'
version: '1.1'
2 changes: 1 addition & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
install_requires=[
"spaceone-api",
"spaceone-core",
"prowler==4.3.3",
"prowler==4.4",
"natsort"
],
package_data={"plugin": ["metadata/*.yaml", "metrics/**/**/*.yaml"]},
Expand Down
Loading