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.

Files changed (140) hide show
  1. regscale/_version.py +1 -1
  2. regscale/core/app/application.py +1 -0
  3. regscale/core/app/internal/control_editor.py +73 -21
  4. regscale/core/app/internal/login.py +4 -1
  5. regscale/core/app/internal/model_editor.py +219 -64
  6. regscale/core/app/utils/app_utils.py +11 -2
  7. regscale/core/login.py +21 -4
  8. regscale/core/utils/date.py +77 -1
  9. regscale/dev/cli.py +26 -0
  10. regscale/dev/version.py +72 -0
  11. regscale/integrations/commercial/__init__.py +15 -1
  12. regscale/integrations/commercial/amazon/amazon/__init__.py +0 -0
  13. regscale/integrations/commercial/amazon/amazon/common.py +204 -0
  14. regscale/integrations/commercial/amazon/common.py +48 -58
  15. regscale/integrations/commercial/aws/audit_manager_compliance.py +2671 -0
  16. regscale/integrations/commercial/aws/cli.py +3093 -55
  17. regscale/integrations/commercial/aws/cloudtrail_control_mappings.py +333 -0
  18. regscale/integrations/commercial/aws/cloudtrail_evidence.py +501 -0
  19. regscale/integrations/commercial/aws/cloudwatch_control_mappings.py +357 -0
  20. regscale/integrations/commercial/aws/cloudwatch_evidence.py +490 -0
  21. regscale/integrations/commercial/aws/config_compliance.py +914 -0
  22. regscale/integrations/commercial/aws/conformance_pack_mappings.py +198 -0
  23. regscale/integrations/commercial/aws/evidence_generator.py +283 -0
  24. regscale/integrations/commercial/aws/guardduty_control_mappings.py +340 -0
  25. regscale/integrations/commercial/aws/guardduty_evidence.py +1053 -0
  26. regscale/integrations/commercial/aws/iam_control_mappings.py +368 -0
  27. regscale/integrations/commercial/aws/iam_evidence.py +574 -0
  28. regscale/integrations/commercial/aws/inventory/__init__.py +223 -22
  29. regscale/integrations/commercial/aws/inventory/base.py +107 -5
  30. regscale/integrations/commercial/aws/inventory/resources/audit_manager.py +513 -0
  31. regscale/integrations/commercial/aws/inventory/resources/cloudtrail.py +315 -0
  32. regscale/integrations/commercial/aws/inventory/resources/cloudtrail_logs_metadata.py +476 -0
  33. regscale/integrations/commercial/aws/inventory/resources/cloudwatch.py +191 -0
  34. regscale/integrations/commercial/aws/inventory/resources/compute.py +66 -9
  35. regscale/integrations/commercial/aws/inventory/resources/config.py +464 -0
  36. regscale/integrations/commercial/aws/inventory/resources/containers.py +74 -9
  37. regscale/integrations/commercial/aws/inventory/resources/database.py +106 -31
  38. regscale/integrations/commercial/aws/inventory/resources/guardduty.py +286 -0
  39. regscale/integrations/commercial/aws/inventory/resources/iam.py +470 -0
  40. regscale/integrations/commercial/aws/inventory/resources/inspector.py +476 -0
  41. regscale/integrations/commercial/aws/inventory/resources/integration.py +175 -61
  42. regscale/integrations/commercial/aws/inventory/resources/kms.py +447 -0
  43. regscale/integrations/commercial/aws/inventory/resources/networking.py +103 -67
  44. regscale/integrations/commercial/aws/inventory/resources/s3.py +394 -0
  45. regscale/integrations/commercial/aws/inventory/resources/security.py +268 -72
  46. regscale/integrations/commercial/aws/inventory/resources/securityhub.py +473 -0
  47. regscale/integrations/commercial/aws/inventory/resources/storage.py +53 -29
  48. regscale/integrations/commercial/aws/inventory/resources/systems_manager.py +657 -0
  49. regscale/integrations/commercial/aws/inventory/resources/vpc.py +655 -0
  50. regscale/integrations/commercial/aws/kms_control_mappings.py +288 -0
  51. regscale/integrations/commercial/aws/kms_evidence.py +879 -0
  52. regscale/integrations/commercial/aws/ocsf/__init__.py +7 -0
  53. regscale/integrations/commercial/aws/ocsf/constants.py +115 -0
  54. regscale/integrations/commercial/aws/ocsf/mapper.py +435 -0
  55. regscale/integrations/commercial/aws/org_control_mappings.py +286 -0
  56. regscale/integrations/commercial/aws/org_evidence.py +666 -0
  57. regscale/integrations/commercial/aws/s3_control_mappings.py +356 -0
  58. regscale/integrations/commercial/aws/s3_evidence.py +632 -0
  59. regscale/integrations/commercial/aws/scanner.py +853 -205
  60. regscale/integrations/commercial/aws/security_hub.py +319 -0
  61. regscale/integrations/commercial/aws/session_manager.py +282 -0
  62. regscale/integrations/commercial/aws/ssm_control_mappings.py +291 -0
  63. regscale/integrations/commercial/aws/ssm_evidence.py +492 -0
  64. regscale/integrations/commercial/synqly/query_builder.py +4 -1
  65. regscale/integrations/compliance_integration.py +308 -38
  66. regscale/integrations/control_matcher.py +78 -23
  67. regscale/integrations/due_date_handler.py +3 -0
  68. regscale/integrations/public/csam/csam.py +572 -763
  69. regscale/integrations/public/csam/csam_agency_defined.py +179 -0
  70. regscale/integrations/public/csam/csam_common.py +154 -0
  71. regscale/integrations/public/csam/csam_controls.py +432 -0
  72. regscale/integrations/public/csam/csam_poam.py +124 -0
  73. regscale/integrations/public/fedramp/click.py +17 -4
  74. regscale/integrations/public/fedramp/fedramp_cis_crm.py +271 -62
  75. regscale/integrations/public/fedramp/poam/scanner.py +74 -7
  76. regscale/integrations/scanner_integration.py +415 -85
  77. regscale/models/integration_models/cisa_kev_data.json +80 -20
  78. regscale/models/integration_models/synqly_models/capabilities.json +1 -1
  79. regscale/models/integration_models/synqly_models/connectors/vulnerabilities.py +44 -3
  80. regscale/models/integration_models/synqly_models/ocsf_mapper.py +41 -12
  81. regscale/models/platform.py +3 -0
  82. regscale/models/regscale_models/__init__.py +5 -0
  83. regscale/models/regscale_models/assessment.py +2 -1
  84. regscale/models/regscale_models/component.py +1 -1
  85. regscale/models/regscale_models/control_implementation.py +55 -24
  86. regscale/models/regscale_models/control_objective.py +74 -5
  87. regscale/models/regscale_models/file.py +2 -0
  88. regscale/models/regscale_models/issue.py +2 -5
  89. regscale/models/regscale_models/organization.py +3 -0
  90. regscale/models/regscale_models/regscale_model.py +17 -5
  91. regscale/models/regscale_models/security_plan.py +1 -0
  92. regscale/regscale.py +11 -1
  93. {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/METADATA +1 -1
  94. {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/RECORD +140 -57
  95. tests/regscale/core/test_login.py +171 -4
  96. tests/regscale/integrations/commercial/aws/__init__.py +0 -0
  97. tests/regscale/integrations/commercial/aws/test_audit_manager_compliance.py +1304 -0
  98. tests/regscale/integrations/commercial/aws/test_audit_manager_evidence_aggregation.py +341 -0
  99. tests/regscale/integrations/commercial/aws/test_aws_audit_manager_collector.py +1155 -0
  100. tests/regscale/integrations/commercial/aws/test_aws_cloudtrail_collector.py +534 -0
  101. tests/regscale/integrations/commercial/aws/test_aws_config_collector.py +400 -0
  102. tests/regscale/integrations/commercial/aws/test_aws_guardduty_collector.py +315 -0
  103. tests/regscale/integrations/commercial/aws/test_aws_iam_collector.py +458 -0
  104. tests/regscale/integrations/commercial/aws/test_aws_inspector_collector.py +353 -0
  105. tests/regscale/integrations/commercial/aws/test_aws_inventory_integration.py +530 -0
  106. tests/regscale/integrations/commercial/aws/test_aws_kms_collector.py +919 -0
  107. tests/regscale/integrations/commercial/aws/test_aws_s3_collector.py +722 -0
  108. tests/regscale/integrations/commercial/aws/test_aws_scanner_integration.py +722 -0
  109. tests/regscale/integrations/commercial/aws/test_aws_securityhub_collector.py +792 -0
  110. tests/regscale/integrations/commercial/aws/test_aws_systems_manager_collector.py +918 -0
  111. tests/regscale/integrations/commercial/aws/test_aws_vpc_collector.py +996 -0
  112. tests/regscale/integrations/commercial/aws/test_cli_evidence.py +431 -0
  113. tests/regscale/integrations/commercial/aws/test_cloudtrail_control_mappings.py +452 -0
  114. tests/regscale/integrations/commercial/aws/test_cloudtrail_evidence.py +788 -0
  115. tests/regscale/integrations/commercial/aws/test_config_compliance.py +298 -0
  116. tests/regscale/integrations/commercial/aws/test_conformance_pack_mappings.py +200 -0
  117. tests/regscale/integrations/commercial/aws/test_evidence_generator.py +386 -0
  118. tests/regscale/integrations/commercial/aws/test_guardduty_control_mappings.py +564 -0
  119. tests/regscale/integrations/commercial/aws/test_guardduty_evidence.py +1041 -0
  120. tests/regscale/integrations/commercial/aws/test_iam_control_mappings.py +718 -0
  121. tests/regscale/integrations/commercial/aws/test_iam_evidence.py +1375 -0
  122. tests/regscale/integrations/commercial/aws/test_kms_control_mappings.py +656 -0
  123. tests/regscale/integrations/commercial/aws/test_kms_evidence.py +1163 -0
  124. tests/regscale/integrations/commercial/aws/test_ocsf_mapper.py +370 -0
  125. tests/regscale/integrations/commercial/aws/test_org_control_mappings.py +546 -0
  126. tests/regscale/integrations/commercial/aws/test_org_evidence.py +1240 -0
  127. tests/regscale/integrations/commercial/aws/test_s3_control_mappings.py +672 -0
  128. tests/regscale/integrations/commercial/aws/test_s3_evidence.py +987 -0
  129. tests/regscale/integrations/commercial/aws/test_scanner_evidence.py +373 -0
  130. tests/regscale/integrations/commercial/aws/test_security_hub_config_filtering.py +539 -0
  131. tests/regscale/integrations/commercial/aws/test_session_manager.py +516 -0
  132. tests/regscale/integrations/commercial/aws/test_ssm_control_mappings.py +588 -0
  133. tests/regscale/integrations/commercial/aws/test_ssm_evidence.py +735 -0
  134. tests/regscale/integrations/commercial/test_aws.py +55 -56
  135. tests/regscale/integrations/test_control_matcher.py +24 -0
  136. tests/regscale/models/test_control_implementation.py +118 -3
  137. {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/LICENSE +0 -0
  138. {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/WHEEL +0 -0
  139. {regscale_cli-6.27.2.0.dist-info → regscale_cli-6.28.0.0.dist-info}/entry_points.txt +0 -0
  140. {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 = create_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
- match = re.search(r"(?<=Finding Severity: ).*", comment)
26
- if match:
27
- severity = match.group()
28
- result = severity # Output: "High"
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: datetime, days: int) -> datetime:
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 datetime earliest_date_performed: Earliest date performed
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 credentials from the client to create SecurityHubPuller
110
- session = aws_client._client_config.__dict__.get("_user_provided_options", {})
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 credentials as the client
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(f"Successfully fetched {len(findings)} findings with rate limiting")
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
- findings = fallback_fetch_aws_findings(aws_client)
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: %s", e)
133
- findings = fallback_fetch_aws_findings(aws_client)
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
- findings = []
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
- resources = []
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")