regscale-cli 6.27.2.0__py3-none-any.whl → 6.28.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of regscale-cli might be problematic. Click here for more details.
- regscale/_version.py +1 -1
- regscale/core/app/application.py +1 -0
- regscale/core/app/internal/control_editor.py +73 -21
- regscale/core/app/internal/login.py +4 -1
- regscale/core/app/internal/model_editor.py +219 -64
- regscale/core/app/utils/app_utils.py +11 -2
- regscale/core/login.py +21 -4
- regscale/core/utils/date.py +77 -1
- regscale/dev/cli.py +26 -0
- regscale/dev/version.py +72 -0
- regscale/integrations/commercial/__init__.py +15 -1
- regscale/integrations/commercial/amazon/amazon/__init__.py +0 -0
- regscale/integrations/commercial/amazon/amazon/common.py +204 -0
- regscale/integrations/commercial/amazon/common.py +48 -58
- regscale/integrations/commercial/aws/audit_manager_compliance.py +2671 -0
- regscale/integrations/commercial/aws/cli.py +3093 -55
- regscale/integrations/commercial/aws/cloudtrail_control_mappings.py +333 -0
- regscale/integrations/commercial/aws/cloudtrail_evidence.py +501 -0
- regscale/integrations/commercial/aws/cloudwatch_control_mappings.py +357 -0
- regscale/integrations/commercial/aws/cloudwatch_evidence.py +490 -0
- regscale/integrations/commercial/aws/config_compliance.py +914 -0
- regscale/integrations/commercial/aws/conformance_pack_mappings.py +198 -0
- regscale/integrations/commercial/aws/evidence_generator.py +283 -0
- regscale/integrations/commercial/aws/guardduty_control_mappings.py +340 -0
- regscale/integrations/commercial/aws/guardduty_evidence.py +1053 -0
- regscale/integrations/commercial/aws/iam_control_mappings.py +368 -0
- regscale/integrations/commercial/aws/iam_evidence.py +574 -0
- regscale/integrations/commercial/aws/inventory/__init__.py +223 -22
- regscale/integrations/commercial/aws/inventory/base.py +107 -5
- regscale/integrations/commercial/aws/inventory/resources/audit_manager.py +513 -0
- regscale/integrations/commercial/aws/inventory/resources/cloudtrail.py +315 -0
- regscale/integrations/commercial/aws/inventory/resources/cloudtrail_logs_metadata.py +476 -0
- regscale/integrations/commercial/aws/inventory/resources/cloudwatch.py +191 -0
- regscale/integrations/commercial/aws/inventory/resources/compute.py +66 -9
- regscale/integrations/commercial/aws/inventory/resources/config.py +464 -0
- regscale/integrations/commercial/aws/inventory/resources/containers.py +74 -9
- regscale/integrations/commercial/aws/inventory/resources/database.py +106 -31
- regscale/integrations/commercial/aws/inventory/resources/guardduty.py +286 -0
- regscale/integrations/commercial/aws/inventory/resources/iam.py +470 -0
- regscale/integrations/commercial/aws/inventory/resources/inspector.py +476 -0
- regscale/integrations/commercial/aws/inventory/resources/integration.py +175 -61
- regscale/integrations/commercial/aws/inventory/resources/kms.py +447 -0
- regscale/integrations/commercial/aws/inventory/resources/networking.py +103 -67
- regscale/integrations/commercial/aws/inventory/resources/s3.py +394 -0
- regscale/integrations/commercial/aws/inventory/resources/security.py +268 -72
- regscale/integrations/commercial/aws/inventory/resources/securityhub.py +473 -0
- regscale/integrations/commercial/aws/inventory/resources/storage.py +53 -29
- regscale/integrations/commercial/aws/inventory/resources/systems_manager.py +657 -0
- regscale/integrations/commercial/aws/inventory/resources/vpc.py +655 -0
- regscale/integrations/commercial/aws/kms_control_mappings.py +288 -0
- regscale/integrations/commercial/aws/kms_evidence.py +879 -0
- regscale/integrations/commercial/aws/ocsf/__init__.py +7 -0
- regscale/integrations/commercial/aws/ocsf/constants.py +115 -0
- regscale/integrations/commercial/aws/ocsf/mapper.py +435 -0
- regscale/integrations/commercial/aws/org_control_mappings.py +286 -0
- regscale/integrations/commercial/aws/org_evidence.py +666 -0
- regscale/integrations/commercial/aws/s3_control_mappings.py +356 -0
- regscale/integrations/commercial/aws/s3_evidence.py +632 -0
- regscale/integrations/commercial/aws/scanner.py +853 -205
- regscale/integrations/commercial/aws/security_hub.py +319 -0
- regscale/integrations/commercial/aws/session_manager.py +282 -0
- regscale/integrations/commercial/aws/ssm_control_mappings.py +291 -0
- regscale/integrations/commercial/aws/ssm_evidence.py +492 -0
- regscale/integrations/commercial/synqly/query_builder.py +4 -1
- regscale/integrations/compliance_integration.py +308 -38
- regscale/integrations/control_matcher.py +78 -23
- regscale/integrations/due_date_handler.py +3 -0
- regscale/integrations/public/csam/csam.py +572 -763
- regscale/integrations/public/csam/csam_agency_defined.py +179 -0
- regscale/integrations/public/csam/csam_common.py +154 -0
- regscale/integrations/public/csam/csam_controls.py +432 -0
- regscale/integrations/public/csam/csam_poam.py +124 -0
- regscale/integrations/public/fedramp/click.py +17 -4
- regscale/integrations/public/fedramp/fedramp_cis_crm.py +271 -62
- regscale/integrations/public/fedramp/poam/scanner.py +74 -7
- regscale/integrations/scanner_integration.py +415 -85
- regscale/models/integration_models/cisa_kev_data.json +80 -20
- regscale/models/integration_models/synqly_models/capabilities.json +1 -1
- regscale/models/integration_models/synqly_models/connectors/vulnerabilities.py +44 -3
- regscale/models/integration_models/synqly_models/ocsf_mapper.py +41 -12
- regscale/models/platform.py +3 -0
- regscale/models/regscale_models/__init__.py +5 -0
- regscale/models/regscale_models/assessment.py +2 -1
- regscale/models/regscale_models/component.py +1 -1
- regscale/models/regscale_models/control_implementation.py +55 -24
- regscale/models/regscale_models/control_objective.py +74 -5
- regscale/models/regscale_models/file.py +2 -0
- regscale/models/regscale_models/issue.py +2 -5
- regscale/models/regscale_models/organization.py +3 -0
- regscale/models/regscale_models/regscale_model.py +17 -5
- regscale/models/regscale_models/security_plan.py +1 -0
- regscale/regscale.py +11 -1
- {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/METADATA +1 -1
- {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/RECORD +140 -57
- tests/regscale/core/test_login.py +171 -4
- tests/regscale/integrations/commercial/aws/__init__.py +0 -0
- tests/regscale/integrations/commercial/aws/test_audit_manager_compliance.py +1304 -0
- tests/regscale/integrations/commercial/aws/test_audit_manager_evidence_aggregation.py +341 -0
- tests/regscale/integrations/commercial/aws/test_aws_audit_manager_collector.py +1155 -0
- tests/regscale/integrations/commercial/aws/test_aws_cloudtrail_collector.py +534 -0
- tests/regscale/integrations/commercial/aws/test_aws_config_collector.py +400 -0
- tests/regscale/integrations/commercial/aws/test_aws_guardduty_collector.py +315 -0
- tests/regscale/integrations/commercial/aws/test_aws_iam_collector.py +458 -0
- tests/regscale/integrations/commercial/aws/test_aws_inspector_collector.py +353 -0
- tests/regscale/integrations/commercial/aws/test_aws_inventory_integration.py +530 -0
- tests/regscale/integrations/commercial/aws/test_aws_kms_collector.py +919 -0
- tests/regscale/integrations/commercial/aws/test_aws_s3_collector.py +722 -0
- tests/regscale/integrations/commercial/aws/test_aws_scanner_integration.py +722 -0
- tests/regscale/integrations/commercial/aws/test_aws_securityhub_collector.py +792 -0
- tests/regscale/integrations/commercial/aws/test_aws_systems_manager_collector.py +918 -0
- tests/regscale/integrations/commercial/aws/test_aws_vpc_collector.py +996 -0
- tests/regscale/integrations/commercial/aws/test_cli_evidence.py +431 -0
- tests/regscale/integrations/commercial/aws/test_cloudtrail_control_mappings.py +452 -0
- tests/regscale/integrations/commercial/aws/test_cloudtrail_evidence.py +788 -0
- tests/regscale/integrations/commercial/aws/test_config_compliance.py +298 -0
- tests/regscale/integrations/commercial/aws/test_conformance_pack_mappings.py +200 -0
- tests/regscale/integrations/commercial/aws/test_evidence_generator.py +386 -0
- tests/regscale/integrations/commercial/aws/test_guardduty_control_mappings.py +564 -0
- tests/regscale/integrations/commercial/aws/test_guardduty_evidence.py +1041 -0
- tests/regscale/integrations/commercial/aws/test_iam_control_mappings.py +718 -0
- tests/regscale/integrations/commercial/aws/test_iam_evidence.py +1375 -0
- tests/regscale/integrations/commercial/aws/test_kms_control_mappings.py +656 -0
- tests/regscale/integrations/commercial/aws/test_kms_evidence.py +1163 -0
- tests/regscale/integrations/commercial/aws/test_ocsf_mapper.py +370 -0
- tests/regscale/integrations/commercial/aws/test_org_control_mappings.py +546 -0
- tests/regscale/integrations/commercial/aws/test_org_evidence.py +1240 -0
- tests/regscale/integrations/commercial/aws/test_s3_control_mappings.py +672 -0
- tests/regscale/integrations/commercial/aws/test_s3_evidence.py +987 -0
- tests/regscale/integrations/commercial/aws/test_scanner_evidence.py +373 -0
- tests/regscale/integrations/commercial/aws/test_security_hub_config_filtering.py +539 -0
- tests/regscale/integrations/commercial/aws/test_session_manager.py +516 -0
- tests/regscale/integrations/commercial/aws/test_ssm_control_mappings.py +588 -0
- tests/regscale/integrations/commercial/aws/test_ssm_evidence.py +735 -0
- tests/regscale/integrations/commercial/test_aws.py +55 -56
- tests/regscale/integrations/test_control_matcher.py +24 -0
- tests/regscale/models/test_control_implementation.py +118 -3
- {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/LICENSE +0 -0
- {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/WHEEL +0 -0
- {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/entry_points.txt +0 -0
- {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/top_level.txt +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
"""RegScale AWS Integrations"""
|
|
4
4
|
import re
|
|
5
|
+
import logging
|
|
5
6
|
from datetime import datetime, timedelta
|
|
6
7
|
from typing import Any, Optional, Tuple
|
|
7
8
|
|
|
@@ -11,7 +12,7 @@ from dateutil import parser
|
|
|
11
12
|
|
|
12
13
|
from regscale.core.app.utils.app_utils import create_logger
|
|
13
14
|
|
|
14
|
-
logger =
|
|
15
|
+
logger = logging.getLogger("regscale")
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def check_finding_severity(comment: Optional[str]) -> str:
|
|
@@ -22,17 +23,17 @@ def check_finding_severity(comment: Optional[str]) -> str:
|
|
|
22
23
|
:rtype: str
|
|
23
24
|
"""
|
|
24
25
|
result = ""
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if comment:
|
|
27
|
+
match = re.search(r"(?<=Finding Severity: ).*", comment)
|
|
28
|
+
if match:
|
|
29
|
+
result = match.group()
|
|
29
30
|
return result
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
def get_due_date(earliest_date_performed:
|
|
33
|
+
def get_due_date(earliest_date_performed: str, days: int) -> datetime:
|
|
33
34
|
"""Returns the due date for an issue
|
|
34
35
|
|
|
35
|
-
:param
|
|
36
|
+
:param str earliest_date_performed: Earliest date performed (string format)
|
|
36
37
|
:param int days: Days to add to the earliest date performed
|
|
37
38
|
:return: Due date
|
|
38
39
|
:rtype: datetime
|
|
@@ -42,7 +43,7 @@ def get_due_date(earliest_date_performed: datetime, days: int) -> datetime:
|
|
|
42
43
|
due_date = datetime.strptime(earliest_date_performed, fmt) + timedelta(days=days)
|
|
43
44
|
except ValueError:
|
|
44
45
|
# Try to determine the date format from a string
|
|
45
|
-
due_date = parser.parse(earliest_date_performed) + timedelta(days)
|
|
46
|
+
due_date = parser.parse(earliest_date_performed) + timedelta(days=days)
|
|
46
47
|
return due_date
|
|
47
48
|
|
|
48
49
|
|
|
@@ -94,6 +95,31 @@ def get_comments(finding: dict) -> str:
|
|
|
94
95
|
return "No remediation recommendation available"
|
|
95
96
|
|
|
96
97
|
|
|
98
|
+
def _fetch_with_error_handling(
|
|
99
|
+
aws_client: BaseClient, method_name: str, result_key: str, resource_type: str = "items"
|
|
100
|
+
) -> list:
|
|
101
|
+
"""Generic fetch method with error handling for AWS Security Hub
|
|
102
|
+
|
|
103
|
+
:param BaseClient aws_client: AWS Security Hub Client
|
|
104
|
+
:param str method_name: Name of the method to call on the client
|
|
105
|
+
:param str result_key: Key to extract from the response
|
|
106
|
+
:param str resource_type: Type of resource being fetched (for logging)
|
|
107
|
+
:return: List of items from AWS
|
|
108
|
+
:rtype: list
|
|
109
|
+
"""
|
|
110
|
+
items = []
|
|
111
|
+
try:
|
|
112
|
+
method = getattr(aws_client, method_name)
|
|
113
|
+
response = method()
|
|
114
|
+
items = response.get(result_key, [])
|
|
115
|
+
logger.info("Fetched %d %s from Security Hub", len(items), resource_type)
|
|
116
|
+
except ClientError as cex:
|
|
117
|
+
logger.error("Unexpected error when fetching %s from AWS: %s", resource_type, cex)
|
|
118
|
+
except AttributeError as aex:
|
|
119
|
+
logger.error("Method %s not found on client: %s", method_name, aex)
|
|
120
|
+
return items
|
|
121
|
+
|
|
122
|
+
|
|
97
123
|
def fetch_aws_findings(aws_client: BaseClient) -> list:
|
|
98
124
|
"""Fetch AWS Findings with optimized rate limiting and pagination
|
|
99
125
|
|
|
@@ -101,70 +127,41 @@ def fetch_aws_findings(aws_client: BaseClient) -> list:
|
|
|
101
127
|
:return: AWS Findings
|
|
102
128
|
:rtype: list
|
|
103
129
|
"""
|
|
104
|
-
findings = []
|
|
105
130
|
try:
|
|
106
131
|
# Use optimized SecurityHubPuller for better performance
|
|
107
132
|
from regscale.integrations.commercial.aws.security_hub import SecurityHubPuller
|
|
108
133
|
|
|
109
|
-
# Extract
|
|
110
|
-
|
|
111
|
-
region = session.meta.region_name
|
|
134
|
+
# Extract region from the client's meta information
|
|
135
|
+
region = aws_client.meta.region_name
|
|
112
136
|
|
|
113
|
-
# Create SecurityHubPuller with same
|
|
137
|
+
# Create SecurityHubPuller with same region and credentials
|
|
114
138
|
puller = SecurityHubPuller(region_name=region)
|
|
115
|
-
|
|
116
|
-
# Use existing client instead of creating new one to maintain credentials
|
|
117
139
|
puller.client = aws_client
|
|
118
140
|
|
|
119
141
|
# Fetch all findings with optimized pagination and rate limiting
|
|
120
142
|
logger.info("Using optimized SecurityHubPuller for findings retrieval...")
|
|
121
143
|
findings = puller.get_all_findings_with_retries()
|
|
122
144
|
|
|
123
|
-
logger.info(
|
|
145
|
+
logger.info("Successfully fetched %d findings with rate limiting", len(findings))
|
|
146
|
+
return findings
|
|
124
147
|
|
|
125
|
-
except ImportError:
|
|
126
|
-
# Fallback to original method if SecurityHubPuller not available
|
|
127
|
-
logger.warning("SecurityHubPuller not available, falling back to basic client")
|
|
128
|
-
|
|
129
|
-
except ClientError as cex:
|
|
130
|
-
logger.error("Unexpected error: %s", cex)
|
|
148
|
+
except (ImportError, AttributeError) as e:
|
|
149
|
+
# Fallback to original method if SecurityHubPuller not available or region not accessible
|
|
150
|
+
logger.warning("SecurityHubPuller not available (%s), falling back to basic client", type(e).__name__)
|
|
151
|
+
return _fetch_with_error_handling(aws_client, "get_findings", "Findings", "findings")
|
|
131
152
|
except Exception as e:
|
|
132
|
-
logger.error("Error using SecurityHubPuller, falling back to basic client
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return findings
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
def fallback_fetch_aws_findings(aws_client: BaseClient) -> list:
|
|
139
|
-
"""Fallback method to fetch AWS Findings without pagination
|
|
140
|
-
|
|
141
|
-
:param BaseClient aws_client: AWS Security Hub Client
|
|
142
|
-
:return: AWS Findings
|
|
143
|
-
:rtype: list
|
|
144
|
-
"""
|
|
145
|
-
findings = []
|
|
146
|
-
try:
|
|
147
|
-
response = aws_client.get_findings()
|
|
148
|
-
findings = response.get("Findings", [])
|
|
149
|
-
except ClientError as cex:
|
|
150
|
-
create_logger().error("Unexpected error when fetching resources from AWS: %s", cex)
|
|
151
|
-
return findings
|
|
153
|
+
logger.error("Error using SecurityHubPuller (%s), falling back to basic client", e)
|
|
154
|
+
return _fetch_with_error_handling(aws_client, "get_findings", "Findings", "findings")
|
|
152
155
|
|
|
153
156
|
|
|
154
157
|
def fetch_aws_findings_v2(aws_client: BaseClient) -> list:
|
|
155
|
-
"""Fetch AWS Findings
|
|
158
|
+
"""Fetch AWS Findings using v2 API
|
|
156
159
|
|
|
157
160
|
:param BaseClient aws_client: AWS Security Hub Client
|
|
158
161
|
:return: AWS Findings
|
|
159
162
|
:rtype: list
|
|
160
163
|
"""
|
|
161
|
-
|
|
162
|
-
try:
|
|
163
|
-
response = aws_client.get_findings_v2()
|
|
164
|
-
findings = response.get("Findings", [])
|
|
165
|
-
except ClientError as cex:
|
|
166
|
-
create_logger().error("Unexpected error when fetching resources from AWS: %s", cex)
|
|
167
|
-
return findings
|
|
164
|
+
return _fetch_with_error_handling(aws_client, "get_findings_v2", "Findings", "findings")
|
|
168
165
|
|
|
169
166
|
|
|
170
167
|
def fetch_aws_resources(aws_client: BaseClient) -> list:
|
|
@@ -174,11 +171,4 @@ def fetch_aws_resources(aws_client: BaseClient) -> list:
|
|
|
174
171
|
:return: AWS Resources
|
|
175
172
|
:rtype: list
|
|
176
173
|
"""
|
|
177
|
-
|
|
178
|
-
try:
|
|
179
|
-
response = aws_client.get_resources_v2()
|
|
180
|
-
resources = response.get("Resources", [])
|
|
181
|
-
logger.info(f"Fetched {len(resources)} resources from Security Hub")
|
|
182
|
-
except ClientError as cex:
|
|
183
|
-
create_logger().error("Unexpected error when fetching resources from AWS: %s", cex)
|
|
184
|
-
return resources
|
|
174
|
+
return _fetch_with_error_handling(aws_client, "get_resources_v2", "Resources", "resources")
|