regscale-cli 6.21.0.0__py3-none-any.whl → 6.21.2.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.
Files changed (54) hide show
  1. regscale/_version.py +1 -1
  2. regscale/core/app/application.py +7 -0
  3. regscale/integrations/commercial/__init__.py +9 -10
  4. regscale/integrations/commercial/amazon/common.py +79 -2
  5. regscale/integrations/commercial/aws/cli.py +183 -9
  6. regscale/integrations/commercial/aws/scanner.py +544 -9
  7. regscale/integrations/commercial/cpe.py +18 -1
  8. regscale/integrations/commercial/import_all/import_all_cmd.py +2 -2
  9. regscale/integrations/commercial/microsoft_defender/__init__.py +0 -0
  10. regscale/integrations/commercial/{defender.py → microsoft_defender/defender.py} +38 -612
  11. regscale/integrations/commercial/microsoft_defender/defender_api.py +286 -0
  12. regscale/integrations/commercial/microsoft_defender/defender_constants.py +80 -0
  13. regscale/integrations/commercial/microsoft_defender/defender_scanner.py +168 -0
  14. regscale/integrations/commercial/qualys/__init__.py +24 -86
  15. regscale/integrations/commercial/qualys/containers.py +2 -0
  16. regscale/integrations/commercial/qualys/scanner.py +7 -2
  17. regscale/integrations/commercial/sonarcloud.py +110 -71
  18. regscale/integrations/commercial/tenablev2/jsonl_scanner.py +2 -1
  19. regscale/integrations/commercial/wizv2/async_client.py +10 -3
  20. regscale/integrations/commercial/wizv2/click.py +105 -26
  21. regscale/integrations/commercial/wizv2/constants.py +249 -1
  22. regscale/integrations/commercial/wizv2/data_fetcher.py +401 -0
  23. regscale/integrations/commercial/wizv2/finding_processor.py +295 -0
  24. regscale/integrations/commercial/wizv2/issue.py +2 -2
  25. regscale/integrations/commercial/wizv2/parsers.py +3 -2
  26. regscale/integrations/commercial/wizv2/policy_compliance.py +3057 -0
  27. regscale/integrations/commercial/wizv2/policy_compliance_helpers.py +564 -0
  28. regscale/integrations/commercial/wizv2/scanner.py +19 -25
  29. regscale/integrations/commercial/wizv2/utils.py +258 -85
  30. regscale/integrations/commercial/wizv2/variables.py +4 -3
  31. regscale/integrations/compliance_integration.py +1607 -0
  32. regscale/integrations/public/fedramp/fedramp_five.py +93 -8
  33. regscale/integrations/public/fedramp/markdown_parser.py +7 -1
  34. regscale/integrations/scanner_integration.py +57 -6
  35. regscale/models/__init__.py +1 -1
  36. regscale/models/app_models/__init__.py +1 -0
  37. regscale/models/integration_models/cisa_kev_data.json +103 -4
  38. regscale/models/integration_models/synqly_models/capabilities.json +1 -1
  39. regscale/{integrations/commercial/wizv2/models.py → models/integration_models/wizv2.py} +4 -12
  40. regscale/models/regscale_models/file.py +4 -0
  41. regscale/models/regscale_models/issue.py +151 -8
  42. regscale/models/regscale_models/regscale_model.py +4 -2
  43. regscale/models/regscale_models/security_plan.py +1 -1
  44. regscale/utils/graphql_client.py +3 -1
  45. {regscale_cli-6.21.0.0.dist-info → regscale_cli-6.21.2.0.dist-info}/METADATA +9 -9
  46. {regscale_cli-6.21.0.0.dist-info → regscale_cli-6.21.2.0.dist-info}/RECORD +52 -44
  47. tests/regscale/core/test_version_regscale.py +5 -3
  48. tests/regscale/integrations/test_wiz_policy_compliance_affected_controls.py +154 -0
  49. tests/regscale/test_authorization.py +0 -65
  50. tests/regscale/test_init.py +0 -96
  51. {regscale_cli-6.21.0.0.dist-info → regscale_cli-6.21.2.0.dist-info}/LICENSE +0 -0
  52. {regscale_cli-6.21.0.0.dist-info → regscale_cli-6.21.2.0.dist-info}/WHEEL +0 -0
  53. {regscale_cli-6.21.0.0.dist-info → regscale_cli-6.21.2.0.dist-info}/entry_points.txt +0 -0
  54. {regscale_cli-6.21.0.0.dist-info → regscale_cli-6.21.2.0.dist-info}/top_level.txt +0 -0
@@ -9,8 +9,8 @@ from typing import Optional
9
9
  import click
10
10
 
11
11
  from regscale.integrations.commercial.wizv2.variables import WizVariables
12
- from regscale.models import regscale_id, regscale_module
13
- from regscale.models.app_models.click import regscale_ssp_id
12
+ from regscale.models import regscale_id
13
+ from regscale.models.app_models.click import regscale_ssp_id, regscale_module
14
14
 
15
15
  logger = logging.getLogger("regscale")
16
16
 
@@ -333,12 +333,11 @@ def add_report_evidence(
333
333
  "--wiz_project_id",
334
334
  "-p",
335
335
  prompt="Enter the Wiz project ID",
336
- help="Enter the Wiz Project ID. Options include: projects, \
337
- policies, supplychain, securityplans, components.",
336
+ help="Enter the Wiz Project ID for policy compliance sync.",
338
337
  required=True,
339
338
  )
340
- @regscale_id(help="RegScale will create and update issues as children of this record.")
341
- @regscale_module()
339
+ @regscale_id(help="RegScale will create and update control assessments as children of this record.")
340
+ @regscale_module(required=True, default="securityplans", prompt=False)
342
341
  @click.option( # type: ignore
343
342
  "--client_id",
344
343
  "-i",
@@ -356,20 +355,49 @@ def add_report_evidence(
356
355
  required=False,
357
356
  )
358
357
  @click.option( # type: ignore
359
- "--catalog_id",
360
- "-c",
361
- help="RegScale Catalog ID for the selected framework.",
362
- hide_input=False,
358
+ "--framework_id",
359
+ "-f",
360
+ help="Wiz framework ID or shorthand (e.g., 'nist', 'aws', 'wf-id-4'). Use --list-frameworks to see options. Default: wf-id-4 (NIST SP 800-53 Rev 5)",
361
+ default="wf-id-4",
363
362
  required=False,
364
- default=None,
365
363
  )
366
364
  @click.option( # type: ignore
367
- "--framework",
368
- "-f",
369
- type=click.Choice(["CSF", "NIST800-53R5", "NIST800-53R4"], case_sensitive=False), # type: ignore
370
- help="Choose either one of the Frameworks",
371
- default="NIST800-53R5",
372
- required=True,
365
+ "--list-frameworks",
366
+ "-lf",
367
+ is_flag=True,
368
+ help="List all available framework options and shortcuts",
369
+ default=False,
370
+ )
371
+ @click.option( # type: ignore
372
+ "--create-issues/--no-create-issues",
373
+ "-ci/-ni",
374
+ default=True,
375
+ help="Create issues for failed policy assessments (default: enabled)",
376
+ )
377
+ @click.option( # type: ignore
378
+ "--update-control-status/--no-update-control-status",
379
+ "-ucs/-nucs",
380
+ default=True,
381
+ help="Update control implementation status based on assessment results (default: enabled)",
382
+ )
383
+ @click.option( # type: ignore
384
+ "--create-poams/--no-create-poams",
385
+ "-cp/-ncp",
386
+ default=False,
387
+ help="Mark created issues as POAMs (default: disabled)",
388
+ )
389
+ @click.option( # type: ignore
390
+ "--refresh/--no-refresh",
391
+ "-r/-nr",
392
+ default=False,
393
+ help="Force refresh and ignore cached data (default: use cache if available)",
394
+ )
395
+ @click.option( # type: ignore
396
+ "--cache-duration",
397
+ "-cd",
398
+ type=click.INT,
399
+ default=1440,
400
+ help="Cache duration in minutes - reuse cached data if newer than this (default: 1440 minutes / 1 day)",
373
401
  )
374
402
  def sync_compliance(
375
403
  wiz_project_id,
@@ -377,23 +405,74 @@ def sync_compliance(
377
405
  regscale_module,
378
406
  client_id,
379
407
  client_secret,
380
- catalog_id,
381
- framework,
408
+ framework_id,
409
+ list_frameworks,
410
+ create_issues,
411
+ update_control_status,
412
+ create_poams,
413
+ refresh,
414
+ cache_duration,
382
415
  ):
383
- """Sync compliance posture from Wiz to RegScale"""
384
- from regscale.integrations.commercial.wizv2.utils import _sync_compliance
416
+ """
417
+ Sync policy compliance assessments from Wiz to RegScale.
418
+
419
+ This command fetches policy assessment data from Wiz and creates:
420
+ - Control assessments based on policy compliance results
421
+ - Issues for failed policy assessments (if --create-issues enabled)
422
+ - Updates to control implementation status (if --update-control-status enabled)
423
+ - JSON output file with policy compliance data in artifacts/wiz/ directory
424
+ - Cached framework mapping for improved performance
425
+
426
+ CACHING:
427
+ By default, the command will reuse cached policy data if it's newer than the cache
428
+ duration (default: 60 minutes). Use --refresh to force fresh data from Wiz.
429
+ Use --cache-duration to adjust how long cached data is considered valid.
430
+ """
431
+ from regscale.integrations.commercial.wizv2.policy_compliance import (
432
+ WizPolicyComplianceIntegration,
433
+ list_available_frameworks,
434
+ resolve_framework_id,
435
+ )
385
436
 
437
+ # Handle --list-frameworks flag
438
+ if list_frameworks:
439
+ click.echo(list_available_frameworks())
440
+ return
441
+
442
+ # Use environment variables if not provided
386
443
  if not client_secret:
387
444
  client_secret = WizVariables.wizClientSecret
388
445
  if not client_id:
389
446
  client_id = WizVariables.wizClientId
390
447
 
391
- _sync_compliance(
448
+ # Resolve framework ID using the enhanced framework resolution
449
+ try:
450
+ resolved_framework_id = resolve_framework_id(framework_id.lower())
451
+ if resolved_framework_id != framework_id:
452
+ from regscale.integrations.commercial.wizv2.policy_compliance import FRAMEWORK_MAPPINGS
453
+
454
+ framework_name = FRAMEWORK_MAPPINGS.get(resolved_framework_id, resolved_framework_id)
455
+ click.echo(f"🔍 Resolved '{framework_id}' to '{framework_name}' ({resolved_framework_id})")
456
+ except ValueError as e:
457
+ click.echo(f"❌ {str(e)}")
458
+ click.echo("\nUse --list-frameworks to see all available options.")
459
+ return
460
+
461
+ # Create and run the policy compliance integration
462
+ policy_integration = WizPolicyComplianceIntegration(
463
+ plan_id=regscale_id,
392
464
  wiz_project_id=wiz_project_id,
393
- regscale_id=regscale_id,
394
- regscale_module=regscale_module,
395
465
  client_id=client_id,
396
466
  client_secret=client_secret,
397
- catalog_id=catalog_id,
398
- framework=framework,
467
+ framework_id=resolved_framework_id,
468
+ regscale_module=regscale_module,
469
+ create_poams=create_poams,
470
+ cache_duration_minutes=cache_duration,
471
+ force_refresh=refresh,
472
+ )
473
+
474
+ # Run the policy compliance sync
475
+ policy_integration.sync_policy_compliance(
476
+ create_issues=create_issues,
477
+ update_control_status=update_control_status,
399
478
  )
@@ -3,7 +3,225 @@
3
3
  from enum import Enum
4
4
  from typing import List, Optional
5
5
 
6
- from regscale.models import IssueSeverity
6
+ from regscale.models import IssueSeverity, regscale_models
7
+
8
+ WIZ_POLICY_QUERY = """
9
+ query PolicyAssessmentsTable($filterBy: PolicyAssessmentFilters, $first: Int, $after: String) {
10
+ policyAssessments(filterBy: $filterBy, first: $first, after: $after) {
11
+ nodes {
12
+ id
13
+ policy {
14
+ ... on CloudConfigurationRule {
15
+ id
16
+ shortId
17
+ name
18
+ ruleDescription: description
19
+ severity
20
+ graphId
21
+ remediationInstructions
22
+ risks
23
+ threats
24
+ securitySubCategories {
25
+ ...SecuritySubCategoriesDetails
26
+ }
27
+ }
28
+ ... on Control {
29
+ id
30
+ name
31
+ description
32
+ lastRunAt
33
+ lastRunError
34
+ lastSuccessfulRunAt
35
+ severity
36
+ risks
37
+ threats
38
+ securitySubCategories {
39
+ ...SecuritySubCategoriesDetails
40
+ }
41
+ }
42
+ ... on HostConfigurationRule {
43
+ id
44
+ name
45
+ shortName
46
+ remediationInstructions
47
+ risks
48
+ threats
49
+ securitySubCategories {
50
+ ...SecuritySubCategoriesDetails
51
+ }
52
+ }
53
+ }
54
+ result
55
+ resource {
56
+ id
57
+ name
58
+ type
59
+ region
60
+ tags { key value }
61
+ subscription { id name externalId cloudProvider }
62
+ }
63
+ output {
64
+ ... on Issue { id issueStatus: status }
65
+ ... on ConfigurationFinding { id name cloudConfigurationFindingStatus: status remediation }
66
+ ... on HostConfigurationRuleAssessment { id hostConfigurationRule: rule { id name shortName description remediationInstructions } }
67
+ }
68
+ }
69
+ pageInfo { hasNextPage endCursor }
70
+ totalCount
71
+ }
72
+ }
73
+
74
+ fragment SecuritySubCategoriesDetails on SecuritySubCategory {
75
+ description
76
+ id
77
+ resolutionRecommendation
78
+ title
79
+ externalId
80
+ category { id name framework { id name enabled } }
81
+ }
82
+ """
83
+
84
+ WIZ_FRAMEWORK_QUERY = """
85
+ query SecurityFrameworksTable($first: Int, $after: String, $filterBy: SecurityFrameworkFilters) {
86
+ securityFrameworks(first: $first, after: $after, filterBy: $filterBy) {
87
+ nodes { policyTypes ...SecurityFrameworkFragment }
88
+ pageInfo { hasNextPage endCursor }
89
+ totalCount
90
+ }
91
+ }
92
+
93
+ fragment SecurityFrameworkFragment on SecurityFramework {
94
+ id
95
+ name
96
+ description
97
+ builtin
98
+ enabled
99
+ parentFramework { id name }
100
+ }
101
+ """
102
+
103
+ # Comprehensive framework mappings with shorthand names for easy CLI usage
104
+ FRAMEWORK_MAPPINGS = {
105
+ "wf-id-4": "NIST SP 800-53 Revision 5",
106
+ "wf-id-48": "NIST SP 800-53 Revision 4",
107
+ "wf-id-5": "FedRAMP (Moderate and Low levels)",
108
+ "wf-id-17": "CIS Controls v7.1",
109
+ "wf-id-24": "CIS Controls v8",
110
+ "wf-id-6": "CIS AWS v1.2.0",
111
+ "wf-id-7": "CIS AWS v1.3.0",
112
+ "wf-id-32": "CIS AWS v1.4.0",
113
+ "wf-id-45": "CIS AWS v1.5.0",
114
+ "wf-id-84": "CIS AWS v2.0.0",
115
+ "wf-id-98": "CIS AWS v3.0.0",
116
+ "wf-id-197": "CIS AWS v4.0.0",
117
+ "wf-id-50": "AWS Foundational Security Best Practices v1.0.0",
118
+ "wf-id-124": "AWS Well-Architected Framework (Section 2 - Security)",
119
+ "wf-id-8": "CIS Azure v1.3.0",
120
+ "wf-id-35": "CIS Azure v1.4.0",
121
+ "wf-id-52": "CIS Azure v1.5.0",
122
+ "wf-id-74": "CIS Azure v2.0.0",
123
+ "wf-id-100": "CIS Azure v2.1.0",
124
+ "wf-id-196": "CIS Azure v2.1.0 (Latest)",
125
+ "wf-id-40": "Azure Security Benchmark v3",
126
+ "wf-id-9": "CIS GCP v1.1.0",
127
+ "wf-id-36": "CIS GCP v1.2.0",
128
+ "wf-id-53": "CIS GCP v1.3.0",
129
+ "wf-id-85": "CIS GCP v2.0.0",
130
+ "wf-id-25": "CIS AKS v1.0.0",
131
+ "wf-id-68": "CIS AKS v1.2.0",
132
+ "wf-id-75": "CIS AKS v1.3.0",
133
+ "wf-id-93": "CIS AKS v1.4.0",
134
+ "wf-id-162": "CIS AKS v1.5.0",
135
+ "wf-id-218": "CIS AKS v1.6.0",
136
+ "wf-id-23": "CIS EKS v1.0.1",
137
+ "wf-id-67": "CIS EKS v1.1.0",
138
+ "wf-id-86": "CIS EKS v1.2.0",
139
+ "wf-id-18": "CIS Kubernetes v1.5.1",
140
+ "wf-id-66": "CIS Kubernetes v1.6.1",
141
+ "wf-id-87": "CIS Kubernetes v1.7.0",
142
+ "wf-id-76": "SOC 2 Type I",
143
+ "wf-id-16": "ISO/IEC 27001:2013",
144
+ "wf-id-19": "PCI DSS v3.2.1",
145
+ "wf-id-78": "PCI DSS v4.0",
146
+ "wf-id-79": "GDPR",
147
+ "wf-id-64": "CCPA/CPRA",
148
+ "wf-id-77": "CCF (The Adobe Common Controls Framework)",
149
+ "wf-id-70": "Canadian PBMM (ITSG-33)",
150
+ "wf-id-111": "C5 - Cloud Computing Compliance Criteria Catalogue",
151
+ "wf-id-161": "CAF (Cyber Assessment Framework by NCSC)",
152
+ "wf-id-90": "APRA CPG 234",
153
+ "wf-id-207": "CISA Security Requirements for EO 14117",
154
+ "wf-id-214": "5Rs - Wiz for Data Security",
155
+ "wf-id-225": "Wiz for Risk Assessment",
156
+ }
157
+
158
+ FRAMEWORK_SHORTCUTS = {
159
+ "nist": "wf-id-4",
160
+ "nist53r5": "wf-id-4",
161
+ "nist53r4": "wf-id-48",
162
+ "fedramp": "wf-id-5",
163
+ "cis": "wf-id-24",
164
+ "cisv8": "wf-id-24",
165
+ "cisv7": "wf-id-17",
166
+ "aws": "wf-id-197",
167
+ "azure": "wf-id-196",
168
+ "gcp": "wf-id-85",
169
+ "k8s": "wf-id-87",
170
+ "kubernetes": "wf-id-87",
171
+ "eks": "wf-id-86",
172
+ "aks": "wf-id-218",
173
+ "soc2": "wf-id-76",
174
+ "iso27001": "wf-id-16",
175
+ "pci": "wf-id-78",
176
+ "gdpr": "wf-id-79",
177
+ "ccpa": "wf-id-64",
178
+ "aws-foundational": "wf-id-50",
179
+ "aws-wellarchitected": "wf-id-124",
180
+ "azure-benchmark": "wf-id-40",
181
+ }
182
+
183
+ FRAMEWORK_CATEGORIES = {
184
+ "NIST Frameworks": ["wf-id-4", "wf-id-48", "wf-id-5"],
185
+ "CIS Controls": ["wf-id-17", "wf-id-24"],
186
+ "AWS Security": [
187
+ "wf-id-197",
188
+ "wf-id-50",
189
+ "wf-id-124",
190
+ "wf-id-6",
191
+ "wf-id-7",
192
+ "wf-id-32",
193
+ "wf-id-45",
194
+ "wf-id-84",
195
+ "wf-id-98",
196
+ ],
197
+ "Azure Security": [
198
+ "wf-id-196",
199
+ "wf-id-40",
200
+ "wf-id-8",
201
+ "wf-id-35",
202
+ "wf-id-52",
203
+ "wf-id-74",
204
+ "wf-id-100",
205
+ ],
206
+ "Google Cloud Security": ["wf-id-85", "wf-id-9", "wf-id-36", "wf-id-53"],
207
+ "Kubernetes Security": [
208
+ "wf-id-87",
209
+ "wf-id-86",
210
+ "wf-id-218",
211
+ "wf-id-18",
212
+ "wf-id-23",
213
+ "wf-id-25",
214
+ "wf-id-66",
215
+ "wf-id-67",
216
+ "wf-id-68",
217
+ "wf-id-75",
218
+ "wf-id-93",
219
+ "wf-id-162",
220
+ ],
221
+ "Industry Standards": ["wf-id-76", "wf-id-16", "wf-id-78", "wf-id-19"],
222
+ "Privacy & Data Protection": ["wf-id-79", "wf-id-64", "wf-id-214"],
223
+ "Government/Regulatory": ["wf-id-70", "wf-id-111", "wf-id-161", "wf-id-90", "wf-id-207"],
224
+ }
7
225
 
8
226
  SBOM_FILE_PATH = "artifacts/wiz_sbom.json"
9
227
  INVENTORY_FILE_PATH = "artifacts/wiz_inventory.json"
@@ -181,6 +399,36 @@ RECOMMENDED_WIZ_INVENTORY_TYPES = [
181
399
  "VIRTUAL_NETWORK",
182
400
  ]
183
401
 
402
+ # This is the set of technology deploymentModels and CloudResource types which we
403
+ # map to the asset category Hardware (instead of Software) when the useWizHardwareTypes
404
+ # feature is enabled.
405
+ # So either things which are hardware-like, or which use technologies that, in turn,
406
+ # imply they are hardware-like.
407
+ # Note that using technology deploymentModels can grab things such as virutal machine
408
+ # image files in addition to actual virtual machines. While this doesn't fit with
409
+ # general concepts of "hardware", for the purposes of attestation, it is the correct
410
+ # choice, as we may be certifying a source image that dynamic resources are created from,
411
+ # rather than attempt to document a variable pool of auto-scaled resources.
412
+ DEFAULT_WIZ_HARDWARE_TYPES = [
413
+ # CloudResource types
414
+ "VIRTUAL_MACHINE",
415
+ "VIRTUAL_MACHINE_IMAGE",
416
+ "CONTAINER",
417
+ "CONTAINER_IMAGE",
418
+ "DB_SERVER",
419
+ # technology deploymentModels
420
+ "SERVER_APPLICATION",
421
+ "CLIENT_APPLICATION",
422
+ "VIRTUAL_APPLIANCE",
423
+ ]
424
+
425
+ # This maps CPE part values to Asset categories.
426
+ CPE_PART_TO_CATEGORY_MAPPING = {
427
+ "h": regscale_models.AssetCategory.Hardware, # Hardware
428
+ "a": regscale_models.AssetCategory.Software, # Application
429
+ "o": regscale_models.AssetCategory.Software, # Other? Operating system? (includes OSs and firmware)
430
+ }
431
+
184
432
  INVENTORY_QUERY = """
185
433
  query CloudResourceSearch(
186
434
  $filterBy: CloudResourceFilters