regscale-cli 6.21.2.0__py3-none-any.whl → 6.28.2.1__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.
- regscale/_version.py +1 -1
- regscale/airflow/hierarchy.py +2 -2
- regscale/core/app/api.py +5 -2
- regscale/core/app/application.py +36 -6
- regscale/core/app/internal/control_editor.py +73 -21
- regscale/core/app/internal/evidence.py +727 -204
- regscale/core/app/internal/login.py +4 -2
- regscale/core/app/internal/model_editor.py +219 -64
- regscale/core/app/utils/app_utils.py +86 -12
- regscale/core/app/utils/catalog_utils/common.py +1 -1
- regscale/core/login.py +21 -4
- regscale/core/utils/async_graphql_client.py +363 -0
- regscale/core/utils/date.py +77 -1
- regscale/dev/cli.py +26 -0
- regscale/dev/code_gen.py +109 -24
- regscale/dev/version.py +72 -0
- regscale/integrations/commercial/__init__.py +30 -2
- regscale/integrations/commercial/aws/audit_manager_compliance.py +3908 -0
- regscale/integrations/commercial/aws/cli.py +3107 -54
- 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/{amazon → aws}/common.py +71 -19
- regscale/integrations/commercial/aws/config_compliance.py +914 -0
- regscale/integrations/commercial/aws/conformance_pack_mappings.py +198 -0
- regscale/integrations/commercial/aws/control_compliance_analyzer.py +439 -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 +338 -22
- regscale/integrations/commercial/aws/inventory/base.py +107 -5
- regscale/integrations/commercial/aws/inventory/resources/analytics.py +390 -0
- regscale/integrations/commercial/aws/inventory/resources/applications.py +234 -0
- 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 +328 -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 +481 -31
- regscale/integrations/commercial/aws/inventory/resources/developer_tools.py +253 -0
- 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/machine_learning.py +358 -0
- regscale/integrations/commercial/aws/inventory/resources/networking.py +390 -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 +288 -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 +1072 -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/jira.py +489 -153
- regscale/integrations/commercial/microsoft_defender/defender.py +326 -5
- regscale/integrations/commercial/microsoft_defender/defender_api.py +348 -14
- regscale/integrations/commercial/microsoft_defender/defender_constants.py +157 -0
- regscale/integrations/commercial/qualys/__init__.py +167 -68
- regscale/integrations/commercial/qualys/scanner.py +305 -39
- regscale/integrations/commercial/sarif/sairf_importer.py +432 -0
- regscale/integrations/commercial/sarif/sarif_converter.py +67 -0
- regscale/integrations/commercial/sicura/api.py +79 -42
- regscale/integrations/commercial/sicura/commands.py +8 -2
- regscale/integrations/commercial/sicura/scanner.py +83 -44
- regscale/integrations/commercial/stigv2/ckl_parser.py +5 -5
- regscale/integrations/commercial/synqly/assets.py +133 -16
- regscale/integrations/commercial/synqly/edr.py +2 -8
- regscale/integrations/commercial/synqly/query_builder.py +536 -0
- regscale/integrations/commercial/synqly/ticketing.py +27 -0
- regscale/integrations/commercial/synqly/vulnerabilities.py +165 -28
- regscale/integrations/commercial/tenablev2/cis_parsers.py +453 -0
- regscale/integrations/commercial/tenablev2/cis_scanner.py +447 -0
- regscale/integrations/commercial/tenablev2/commands.py +146 -5
- regscale/integrations/commercial/tenablev2/scanner.py +1 -3
- regscale/integrations/commercial/tenablev2/stig_parsers.py +113 -57
- regscale/integrations/commercial/wizv2/WizDataMixin.py +1 -1
- regscale/integrations/commercial/wizv2/click.py +191 -76
- regscale/integrations/commercial/wizv2/compliance/__init__.py +15 -0
- regscale/integrations/commercial/wizv2/{policy_compliance_helpers.py → compliance/helpers.py} +78 -60
- regscale/integrations/commercial/wizv2/compliance_report.py +1592 -0
- regscale/integrations/commercial/wizv2/core/__init__.py +133 -0
- regscale/integrations/commercial/wizv2/{async_client.py → core/client.py} +7 -3
- regscale/integrations/commercial/wizv2/{constants.py → core/constants.py} +92 -89
- regscale/integrations/commercial/wizv2/core/file_operations.py +237 -0
- regscale/integrations/commercial/wizv2/fetchers/__init__.py +11 -0
- regscale/integrations/commercial/wizv2/{data_fetcher.py → fetchers/policy_assessment.py} +66 -9
- regscale/integrations/commercial/wizv2/file_cleanup.py +104 -0
- regscale/integrations/commercial/wizv2/issue.py +776 -28
- regscale/integrations/commercial/wizv2/models/__init__.py +0 -0
- regscale/integrations/commercial/wizv2/parsers/__init__.py +34 -0
- regscale/integrations/commercial/wizv2/{parsers.py → parsers/main.py} +1 -1
- regscale/integrations/commercial/wizv2/processors/__init__.py +11 -0
- regscale/integrations/commercial/wizv2/{finding_processor.py → processors/finding.py} +1 -1
- regscale/integrations/commercial/wizv2/reports.py +243 -0
- regscale/integrations/commercial/wizv2/sbom.py +1 -1
- regscale/integrations/commercial/wizv2/scanner.py +1031 -441
- regscale/integrations/commercial/wizv2/utils/__init__.py +48 -0
- regscale/integrations/commercial/wizv2/{utils.py → utils/main.py} +116 -61
- regscale/integrations/commercial/wizv2/variables.py +89 -3
- regscale/integrations/compliance_integration.py +1036 -151
- regscale/integrations/control_matcher.py +432 -0
- regscale/integrations/due_date_handler.py +333 -0
- regscale/integrations/milestone_manager.py +291 -0
- regscale/integrations/public/__init__.py +14 -0
- regscale/integrations/public/cci_importer.py +834 -0
- regscale/integrations/public/csam/__init__.py +0 -0
- regscale/integrations/public/csam/csam.py +938 -0
- 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 +77 -6
- regscale/integrations/public/fedramp/docx_parser.py +10 -1
- regscale/integrations/public/fedramp/fedramp_cis_crm.py +675 -289
- regscale/integrations/public/fedramp/fedramp_five.py +1 -1
- regscale/integrations/public/fedramp/poam/scanner.py +75 -7
- regscale/integrations/public/fedramp/poam_export_v5.py +888 -0
- regscale/integrations/scanner_integration.py +1961 -430
- regscale/models/integration_models/CCI_List.xml +1 -0
- regscale/models/integration_models/aqua.py +2 -2
- regscale/models/integration_models/cisa_kev_data.json +805 -11
- regscale/models/integration_models/flat_file_importer/__init__.py +5 -8
- regscale/models/integration_models/nexpose.py +36 -10
- regscale/models/integration_models/qualys.py +3 -4
- regscale/models/integration_models/synqly_models/capabilities.json +1 -1
- regscale/models/integration_models/synqly_models/connectors/vulnerabilities.py +87 -18
- regscale/models/integration_models/synqly_models/filter_parser.py +332 -0
- regscale/models/integration_models/synqly_models/ocsf_mapper.py +124 -25
- regscale/models/integration_models/synqly_models/synqly_model.py +89 -16
- regscale/models/locking.py +12 -8
- regscale/models/platform.py +4 -2
- regscale/models/regscale_models/__init__.py +7 -0
- regscale/models/regscale_models/assessment.py +2 -1
- regscale/models/regscale_models/catalog.py +1 -1
- regscale/models/regscale_models/compliance_settings.py +251 -1
- regscale/models/regscale_models/component.py +1 -0
- regscale/models/regscale_models/control_implementation.py +236 -41
- regscale/models/regscale_models/control_objective.py +74 -5
- regscale/models/regscale_models/file.py +2 -0
- regscale/models/regscale_models/form_field_value.py +5 -3
- regscale/models/regscale_models/inheritance.py +44 -0
- regscale/models/regscale_models/issue.py +301 -102
- regscale/models/regscale_models/milestone.py +33 -14
- regscale/models/regscale_models/organization.py +3 -0
- regscale/models/regscale_models/regscale_model.py +310 -73
- regscale/models/regscale_models/security_plan.py +4 -2
- regscale/models/regscale_models/vulnerability.py +3 -3
- regscale/regscale.py +25 -4
- regscale/templates/__init__.py +0 -0
- regscale/utils/threading/threadhandler.py +20 -15
- regscale/validation/record.py +23 -1
- {regscale_cli-6.21.2.0.dist-info → regscale_cli-6.28.2.1.dist-info}/METADATA +17 -33
- {regscale_cli-6.21.2.0.dist-info → regscale_cli-6.28.2.1.dist-info}/RECORD +310 -111
- tests/core/__init__.py +0 -0
- tests/core/utils/__init__.py +0 -0
- tests/core/utils/test_async_graphql_client.py +472 -0
- tests/fixtures/test_fixture.py +13 -8
- tests/regscale/core/test_login.py +171 -4
- tests/regscale/integrations/commercial/__init__.py +0 -0
- 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_analytics_collector.py +260 -0
- tests/regscale/integrations/commercial/aws/test_aws_applications_collector.py +242 -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_developer_tools_collector.py +203 -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_machine_learning_collector.py +237 -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_control_compliance_analyzer.py +375 -0
- tests/regscale/integrations/commercial/aws/test_datetime_parsing.py +223 -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/conftest.py +28 -0
- tests/regscale/integrations/commercial/microsoft_defender/__init__.py +1 -0
- tests/regscale/integrations/commercial/microsoft_defender/test_defender.py +1517 -0
- tests/regscale/integrations/commercial/microsoft_defender/test_defender_api.py +1748 -0
- tests/regscale/integrations/commercial/microsoft_defender/test_defender_constants.py +327 -0
- tests/regscale/integrations/commercial/microsoft_defender/test_defender_scanner.py +487 -0
- tests/regscale/integrations/commercial/test_aws.py +3742 -0
- tests/regscale/integrations/commercial/test_burp.py +48 -0
- tests/regscale/integrations/commercial/test_crowdstrike.py +49 -0
- tests/regscale/integrations/commercial/test_dependabot.py +341 -0
- tests/regscale/integrations/commercial/test_gcp.py +1543 -0
- tests/regscale/integrations/commercial/test_gitlab.py +549 -0
- tests/regscale/integrations/commercial/test_ip_mac_address_length.py +84 -0
- tests/regscale/integrations/commercial/test_jira.py +2204 -0
- tests/regscale/integrations/commercial/test_npm_audit.py +42 -0
- tests/regscale/integrations/commercial/test_okta.py +1228 -0
- tests/regscale/integrations/commercial/test_sarif_converter.py +251 -0
- tests/regscale/integrations/commercial/test_sicura.py +349 -0
- tests/regscale/integrations/commercial/test_snow.py +423 -0
- tests/regscale/integrations/commercial/test_sonarcloud.py +394 -0
- tests/regscale/integrations/commercial/test_sqlserver.py +186 -0
- tests/regscale/integrations/commercial/test_stig.py +33 -0
- tests/regscale/integrations/commercial/test_stig_mapper.py +153 -0
- tests/regscale/integrations/commercial/test_stigv2.py +406 -0
- tests/regscale/integrations/commercial/test_wiz.py +1365 -0
- tests/regscale/integrations/commercial/test_wiz_inventory.py +256 -0
- tests/regscale/integrations/commercial/wizv2/__init__.py +339 -0
- tests/regscale/integrations/commercial/wizv2/compliance/__init__.py +1 -0
- tests/regscale/integrations/commercial/wizv2/compliance/test_helpers.py +903 -0
- tests/regscale/integrations/commercial/wizv2/core/__init__.py +1 -0
- tests/regscale/integrations/commercial/wizv2/core/test_auth.py +701 -0
- tests/regscale/integrations/commercial/wizv2/core/test_client.py +1037 -0
- tests/regscale/integrations/commercial/wizv2/core/test_file_operations.py +989 -0
- tests/regscale/integrations/commercial/wizv2/fetchers/__init__.py +1 -0
- tests/regscale/integrations/commercial/wizv2/fetchers/test_policy_assessment.py +805 -0
- tests/regscale/integrations/commercial/wizv2/parsers/__init__.py +1 -0
- tests/regscale/integrations/commercial/wizv2/parsers/test_main.py +1153 -0
- tests/regscale/integrations/commercial/wizv2/processors/__init__.py +1 -0
- tests/regscale/integrations/commercial/wizv2/processors/test_finding.py +671 -0
- tests/regscale/integrations/commercial/wizv2/test_WizDataMixin.py +537 -0
- tests/regscale/integrations/commercial/wizv2/test_click_comprehensive.py +851 -0
- tests/regscale/integrations/commercial/wizv2/test_compliance_report_comprehensive.py +910 -0
- tests/regscale/integrations/commercial/wizv2/test_compliance_report_normalization.py +138 -0
- tests/regscale/integrations/commercial/wizv2/test_file_cleanup.py +283 -0
- tests/regscale/integrations/commercial/wizv2/test_file_operations.py +260 -0
- tests/regscale/integrations/commercial/wizv2/test_issue.py +343 -0
- tests/regscale/integrations/commercial/wizv2/test_issue_comprehensive.py +1203 -0
- tests/regscale/integrations/commercial/wizv2/test_reports.py +497 -0
- tests/regscale/integrations/commercial/wizv2/test_sbom.py +643 -0
- tests/regscale/integrations/commercial/wizv2/test_scanner_comprehensive.py +805 -0
- tests/regscale/integrations/commercial/wizv2/test_wiz_click_client_id.py +165 -0
- tests/regscale/integrations/commercial/wizv2/test_wiz_compliance_report.py +1394 -0
- tests/regscale/integrations/commercial/wizv2/test_wiz_compliance_unit.py +341 -0
- tests/regscale/integrations/commercial/wizv2/test_wiz_control_normalization.py +138 -0
- tests/regscale/integrations/commercial/wizv2/test_wiz_findings_comprehensive.py +364 -0
- tests/regscale/integrations/commercial/wizv2/test_wiz_inventory_comprehensive.py +644 -0
- tests/regscale/integrations/commercial/wizv2/test_wiz_status_mapping.py +149 -0
- tests/regscale/integrations/commercial/wizv2/test_wizv2.py +1218 -0
- tests/regscale/integrations/commercial/wizv2/test_wizv2_utils.py +519 -0
- tests/regscale/integrations/commercial/wizv2/utils/__init__.py +1 -0
- tests/regscale/integrations/commercial/wizv2/utils/test_main.py +1523 -0
- tests/regscale/integrations/public/__init__.py +0 -0
- tests/regscale/integrations/public/fedramp/__init__.py +1 -0
- tests/regscale/integrations/public/fedramp/test_gen_asset_list.py +150 -0
- tests/regscale/integrations/public/fedramp/test_poam_export_v5.py +1293 -0
- tests/regscale/integrations/public/test_alienvault.py +220 -0
- tests/regscale/integrations/public/test_cci.py +1053 -0
- tests/regscale/integrations/public/test_cisa.py +1021 -0
- tests/regscale/integrations/public/test_emass.py +518 -0
- tests/regscale/integrations/public/test_fedramp.py +1152 -0
- tests/regscale/integrations/public/test_fedramp_cis_crm.py +3661 -0
- tests/regscale/integrations/public/test_file_uploads.py +506 -0
- tests/regscale/integrations/public/test_oscal.py +453 -0
- tests/regscale/integrations/test_compliance_status_mapping.py +406 -0
- tests/regscale/integrations/test_control_matcher.py +1421 -0
- tests/regscale/integrations/test_control_matching.py +155 -0
- tests/regscale/integrations/test_milestone_manager.py +408 -0
- tests/regscale/models/test_control_implementation.py +118 -3
- tests/regscale/models/test_form_field_value_integration.py +304 -0
- tests/regscale/models/test_issue.py +378 -1
- tests/regscale/models/test_module_integration.py +582 -0
- tests/regscale/models/test_tenable_integrations.py +811 -105
- regscale/integrations/commercial/wizv2/policy_compliance.py +0 -3057
- regscale/integrations/public/fedramp/mappings/fedramp_r4_parts.json +0 -7388
- regscale/integrations/public/fedramp/mappings/fedramp_r5_parts.json +0 -9605
- regscale/integrations/public/fedramp/parts_mapper.py +0 -107
- /regscale/integrations/commercial/{amazon → sarif}/__init__.py +0 -0
- /regscale/integrations/commercial/wizv2/{wiz_auth.py → core/auth.py} +0 -0
- {regscale_cli-6.21.2.0.dist-info → regscale_cli-6.28.2.1.dist-info}/LICENSE +0 -0
- {regscale_cli-6.21.2.0.dist-info → regscale_cli-6.28.2.1.dist-info}/WHEEL +0 -0
- {regscale_cli-6.21.2.0.dist-info → regscale_cli-6.28.2.1.dist-info}/entry_points.txt +0 -0
- {regscale_cli-6.21.2.0.dist-info → regscale_cli-6.28.2.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from os.path import join
|
|
3
|
+
from unittest.mock import patch
|
|
4
|
+
|
|
5
|
+
from regscale.integrations.commercial.stig_mapper_integration.mapping_engine import StigMappingEngine
|
|
6
|
+
from regscale.models.regscale_models import Component, Asset
|
|
7
|
+
from tests.fixtures.test_fixture import CLITestFixture
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestStigMappingEngine(unittest.TestCase):
|
|
11
|
+
test_fixture = CLITestFixture()
|
|
12
|
+
SSP_ID = 123
|
|
13
|
+
|
|
14
|
+
def setUp(self):
|
|
15
|
+
"""
|
|
16
|
+
Setup the test case with a mapping engine and rules.
|
|
17
|
+
"""
|
|
18
|
+
test_file_path = join(
|
|
19
|
+
self.test_fixture.get_tests_dir("tests").absolute(), "test_data/test_stig_mapper_rules.json"
|
|
20
|
+
)
|
|
21
|
+
self.engine = StigMappingEngine(json_file=test_file_path)
|
|
22
|
+
self.engine.rules = [
|
|
23
|
+
{
|
|
24
|
+
"stig": "Windows 2012 Configuration STIG",
|
|
25
|
+
"comparators": [
|
|
26
|
+
{
|
|
27
|
+
"comparator": "startswith",
|
|
28
|
+
"value": "Windows 2012",
|
|
29
|
+
"property": "name",
|
|
30
|
+
"logical_operator": "and",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"comparator": "notcontains",
|
|
34
|
+
"value": "Account Access Group",
|
|
35
|
+
"property": "name",
|
|
36
|
+
"logical_operator": "and",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"stig": "Network Security STIG",
|
|
42
|
+
"comparators": [
|
|
43
|
+
{"comparator": "startswith", "value": "Kubernetes", "property": "name", "logical_operator": "and"},
|
|
44
|
+
{"comparator": "endswith", "value": "Security", "property": "name", "logical_operator": "or"},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
def test_find_matching_stigs_with_and_operator(self):
|
|
50
|
+
asset = Asset(name="Windows 2012 Server", assetType="", status="", assetCategory="")
|
|
51
|
+
comparators = [
|
|
52
|
+
{"comparator": "contains", "value": "Windows 2012", "property": "name", "logical_operator": "and"},
|
|
53
|
+
{"comparator": "notin", "value": "Account Access Group", "property": "name", "logical_operator": "and"},
|
|
54
|
+
]
|
|
55
|
+
result = self.engine.asset_matches_comparators(asset, comparators)
|
|
56
|
+
self.assertTrue(result, "Expected the asset to match 'Windows 2012' with 'and' logical operator.")
|
|
57
|
+
|
|
58
|
+
def test_find_matching_stigs_with_or_operator(self):
|
|
59
|
+
asset = Asset(name="Kubernetes Security System", assetType="", status="", assetCategory="")
|
|
60
|
+
comparators = [
|
|
61
|
+
{"comparator": "startswith", "value": "Kubernetes", "property": "name", "logical_operator": "and"},
|
|
62
|
+
{"comparator": "endswith", "value": "Security", "property": "name", "logical_operator": "or"},
|
|
63
|
+
]
|
|
64
|
+
result = self.engine.asset_matches_comparators(asset, comparators)
|
|
65
|
+
self.assertTrue(result, "Expected the asset to match 'Kubernetes' with 'or' logical operator.")
|
|
66
|
+
|
|
67
|
+
def test_find_matching_stigs_failure(self):
|
|
68
|
+
asset = Asset(name="Ubuntu Server", assetType="", status="", assetCategory="")
|
|
69
|
+
comparators = [{"comparator": "contains", "value": "Windows", "property": "name", "logical_operator": "and"}]
|
|
70
|
+
result = self.engine.asset_matches_comparators(asset, comparators)
|
|
71
|
+
self.assertFalse(result, "Expected the asset not to match 'Windows'.")
|
|
72
|
+
|
|
73
|
+
@patch("regscale.models.regscale_models.Component.get_all_by_parent")
|
|
74
|
+
@patch("regscale.models.regscale_models.ComponentMapping.get_all_by_parent")
|
|
75
|
+
def test_match_asset_to_stigs(self, mock_component_mapping, mock_components):
|
|
76
|
+
# Mock the components and component mappings
|
|
77
|
+
mock_component_mapping.return_value = []
|
|
78
|
+
mock_components.return_value = [
|
|
79
|
+
Component(title="Windows 2012 Configuration STIG", description="", componentType=""),
|
|
80
|
+
Component(title="Network Security STIG", description="", componentType=""),
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
asset = Asset(name="Windows 2012 Server", assetType="", status="", assetCategory="")
|
|
84
|
+
|
|
85
|
+
# Run the match_asset_to_stigs method
|
|
86
|
+
result = self.engine.find_matching_stigs([asset.dict()], self.engine.rules)
|
|
87
|
+
|
|
88
|
+
# Validate that the correct STIG is matched
|
|
89
|
+
self.assertEqual(1, len(result), "Expected 1 matching STIG")
|
|
90
|
+
self.assertEqual(
|
|
91
|
+
result[0], "Windows 2012 Configuration STIG", "Expected to match 'Windows 2012 Configuration STIG'"
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
@patch("regscale.models.regscale_models.Component.get_all_by_parent")
|
|
95
|
+
@patch("regscale.models.regscale_models.ComponentMapping.get_all_by_parent")
|
|
96
|
+
@patch("regscale.integrations.commercial.stig_mapper.mapping_engine.StigMappingEngine.get_component_dict")
|
|
97
|
+
def test_match_asset_to_stigs_no_match(self, mock_get_component_dict, mock_component_mapping, mock_components):
|
|
98
|
+
# Set up the component cache directly as a side effect
|
|
99
|
+
mock_get_component_dict.return_value = {
|
|
100
|
+
"Windows 2012 Configuration STIG": Component(
|
|
101
|
+
title="Windows 2012 Configuration STIG", description="", componentType=""
|
|
102
|
+
),
|
|
103
|
+
"Network Security STIG": Component(title="Network Security STIG", description="", componentType=""),
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Mock the components and component mappings
|
|
107
|
+
mock_component_mapping.return_value = []
|
|
108
|
+
mock_components.return_value = [
|
|
109
|
+
Component(title="Windows 2012 Configuration STIG", description="", componentType=""),
|
|
110
|
+
Component(title="Network Security STIG", description="", componentType=""),
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
asset = Asset(name="Ubuntu Server", assetType="", status="", assetCategory="")
|
|
114
|
+
|
|
115
|
+
# Run the match_asset_to_stigs method
|
|
116
|
+
result = self.engine.match_asset_to_stigs(asset=asset, ssp_id=self.SSP_ID)
|
|
117
|
+
|
|
118
|
+
# Validate that no STIGs are matched
|
|
119
|
+
self.assertEqual(0, len(result), "Expected no matching STIGs")
|
|
120
|
+
|
|
121
|
+
def test_find_matching_stigs_for_software_inventory(self):
|
|
122
|
+
software_inventory = [
|
|
123
|
+
{"name": "Windows 2012 Server", "version": "6.3", "vendor": "Microsoft"},
|
|
124
|
+
{"name": "Account Access Group Tool", "version": "1.0", "vendor": "Generic"},
|
|
125
|
+
{"name": "Kubernetes Security System", "version": "1.20", "vendor": "OpenSource"},
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
comparators = [
|
|
129
|
+
{"comparator": "startswith", "value": "Windows 2012", "property": "name", "logical_operator": "and"},
|
|
130
|
+
{"comparator": "contains", "value": "Account Access Group", "property": "name", "logical_operator": "and"},
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
result = self.engine.find_matching_stigs(
|
|
134
|
+
software_inventory, [{"stig": "Test STIG", "comparators": comparators}]
|
|
135
|
+
)
|
|
136
|
+
self.assertGreater(
|
|
137
|
+
len(result), 0, "Expected at least one software inventory item to match the 'Windows 2012' criteria."
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
def test_find_matching_stigs_for_software_inventory_no_match(self):
|
|
141
|
+
software_inventory = [
|
|
142
|
+
{"name": "Ubuntu Server", "version": "20.04", "vendor": "Canonical"},
|
|
143
|
+
{"name": "Account Access Group Tool", "version": "1.0", "vendor": "Generic"},
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
comparators = [
|
|
147
|
+
{"comparator": "startswith", "value": "Windows", "property": "name", "logical_operator": "and"},
|
|
148
|
+
]
|
|
149
|
+
|
|
150
|
+
result = self.engine.find_matching_stigs(
|
|
151
|
+
software_inventory, [{"stig": "Test STIG", "comparators": comparators}]
|
|
152
|
+
)
|
|
153
|
+
self.assertEqual(len(result), 0, "Expected no software inventory items to match the 'Windows' criteria.")
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import zipfile
|
|
3
|
+
from unittest.mock import patch, MagicMock
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from regscale.core.utils.date import date_str, days_from_today
|
|
8
|
+
from regscale.integrations.commercial.stigv2.ckl_parser import (
|
|
9
|
+
parse_checklist,
|
|
10
|
+
Checklist,
|
|
11
|
+
Asset,
|
|
12
|
+
STIG,
|
|
13
|
+
STIGInfo,
|
|
14
|
+
Vuln,
|
|
15
|
+
get_components_from_checklist,
|
|
16
|
+
get_all_components_from_checklists,
|
|
17
|
+
)
|
|
18
|
+
from regscale.integrations.commercial.stigv2.stig_integration import StigIntegration
|
|
19
|
+
|
|
20
|
+
sample_asset = Asset(
|
|
21
|
+
role="None",
|
|
22
|
+
asset_type="Computing",
|
|
23
|
+
host_name="FacierComplainingnessDisulphuret",
|
|
24
|
+
host_ip="",
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class TestStigIntegration:
|
|
29
|
+
@pytest.fixture(autouse=True)
|
|
30
|
+
def setup_and_teardown(self, test_data_dir, test_tmp_dir):
|
|
31
|
+
# Setup
|
|
32
|
+
self.chaos_stig_dir = test_tmp_dir / "stig" / "ChaosStigs"
|
|
33
|
+
os.makedirs(self.chaos_stig_dir, exist_ok=True)
|
|
34
|
+
chaos_stig_zip_file = test_data_dir / "stig" / "ChaosStigs.zip"
|
|
35
|
+
with zipfile.ZipFile(chaos_stig_zip_file, "r") as zip_ref:
|
|
36
|
+
for zip_info in zip_ref.infolist():
|
|
37
|
+
if not zip_info.is_dir():
|
|
38
|
+
zip_info.filename = os.path.basename(zip_info.filename)
|
|
39
|
+
zip_ref.extract(zip_info, self.chaos_stig_dir)
|
|
40
|
+
|
|
41
|
+
self.cisco_stig_file = self.chaos_stig_dir / (
|
|
42
|
+
"Perimeter Router Security Technical Implementation "
|
|
43
|
+
"Guide Cisco V8R32 - FacierComplainingnessDisulphuret.ckl"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def test_parse_checklist(self):
|
|
47
|
+
checklists = []
|
|
48
|
+
|
|
49
|
+
for file in os.listdir(self.chaos_stig_dir):
|
|
50
|
+
if file.endswith(".ckl"):
|
|
51
|
+
checklists.append(parse_checklist(self.chaos_stig_dir / file))
|
|
52
|
+
assert len(checklists) == 1500, "There should 1500 checklists processed."
|
|
53
|
+
|
|
54
|
+
cisco_checklist = parse_checklist(self.cisco_stig_file)
|
|
55
|
+
assert len(cisco_checklist.stigs[0].vulns) == 145, "There should be 145 fields in the vuln."
|
|
56
|
+
cisco_checklist.stigs[0].vulns = [cisco_checklist.stigs[0].vulns[0]]
|
|
57
|
+
assert cisco_checklist == Checklist(
|
|
58
|
+
assets=[
|
|
59
|
+
Asset(
|
|
60
|
+
role="None",
|
|
61
|
+
asset_type="Computing",
|
|
62
|
+
host_name="FacierComplainingnessDisulphuret",
|
|
63
|
+
host_ip="101.116.163.60",
|
|
64
|
+
host_mac="96:47:ba:29:58:bd",
|
|
65
|
+
host_fqdn="faciercomplainingnessdisulphuret.cosmos.navy.mil",
|
|
66
|
+
tech_area=None,
|
|
67
|
+
target_key="510",
|
|
68
|
+
web_or_database=False,
|
|
69
|
+
web_db_site=None,
|
|
70
|
+
web_db_instance=None,
|
|
71
|
+
)
|
|
72
|
+
],
|
|
73
|
+
stigs=[
|
|
74
|
+
STIG(
|
|
75
|
+
baseline="Perimeter Router Security Technical Implementation Guide Cisco V8R32",
|
|
76
|
+
stig_info=STIGInfo(
|
|
77
|
+
version="8",
|
|
78
|
+
classification="UNCLASSIFIED",
|
|
79
|
+
customname=None,
|
|
80
|
+
stigid="Network_-_Perimeter_Router_Cisco",
|
|
81
|
+
description="Perimeter Router Security Technical Implementation Guide – Cisco",
|
|
82
|
+
filename="U_Network_Perimeter_Router_Cisco_STIG_V8R32_Manual-xccdf.xml",
|
|
83
|
+
releaseinfo="Release: 32 Benchmark Date: 25 Jan 2019",
|
|
84
|
+
title="Perimeter Router Security Technical Implementation Guide Cisco",
|
|
85
|
+
uuid="459468bf-6c90-49ff-8389-28df0ff0e556",
|
|
86
|
+
notice="terms-of-use",
|
|
87
|
+
source=None,
|
|
88
|
+
),
|
|
89
|
+
vulns=[
|
|
90
|
+
Vuln(
|
|
91
|
+
vuln_num="V-3000",
|
|
92
|
+
severity="low",
|
|
93
|
+
group_title="Interface ACL deny statements are not logged.",
|
|
94
|
+
rule_id="SV-15474r3_rule",
|
|
95
|
+
rule_ver="NET1020",
|
|
96
|
+
rule_title="The network device must log all access control lists (ACL) deny statements.",
|
|
97
|
+
check_content="Review the network device interface ACLs to verify all deny statements are "
|
|
98
|
+
"logged.\n\nCisco IOS example:\ninterface FastEthernet 0/0 \ndescription external"
|
|
99
|
+
" interface peering with ISP or non-DoD network\nip address 199.36.92.1 255.255"
|
|
100
|
+
".255.252\nip access-group 100 in\n…\naccess-list 100 deny icmp any any fragments"
|
|
101
|
+
" log\naccess-list 100 deny ip 169.254.0.0 0.0.255.255 any log\naccess-list 100 "
|
|
102
|
+
"deny ip 10.0.0.0 0.255.255.255 any log\naccess-list 100 deny ip 172.16.0.0 "
|
|
103
|
+
"0.15.255.255 any log\naccess-list 100 deny ip 192.168.0.0 0.0.255.255 any "
|
|
104
|
+
"log\naccess-list 100 permit icmp any host 199.36.92.1 echo-reply\naccess-list "
|
|
105
|
+
"100 permit icmp any host 199.36.90.10 echo-reply\naccess-list 100 deny icmp "
|
|
106
|
+
"any any log\naccess-list 100 deny ip any any log",
|
|
107
|
+
fix_text="Configure interface ACLs to log all deny statements.",
|
|
108
|
+
check_content_ref="M",
|
|
109
|
+
weight="10.0",
|
|
110
|
+
stigref="Perimeter Router Security Technical Implementation Guide Cisco :: Version 8, Release:"
|
|
111
|
+
" 32 Benchmark Date: 25 Jan 2019",
|
|
112
|
+
targetkey="510",
|
|
113
|
+
stig_uuid="459468bf-6c90-49ff-8389-28df0ff0e556",
|
|
114
|
+
vuln_discuss="Auditing and logging are key components of any security architecture. It is "
|
|
115
|
+
"essential for security personnel to know what is being done, attempted to be "
|
|
116
|
+
"done, and by whom in order to compile an accurate risk assessment. Auditing "
|
|
117
|
+
"the actions on network devices provides a means to recreate an attack, or "
|
|
118
|
+
"identify a configuration mistake on the device.",
|
|
119
|
+
ia_controls="ECAT-1, ECAT-2, ECSC-1",
|
|
120
|
+
class_=None,
|
|
121
|
+
cci_ref=[],
|
|
122
|
+
false_positives=None,
|
|
123
|
+
false_negatives=None,
|
|
124
|
+
documentable="false",
|
|
125
|
+
mitigations=None,
|
|
126
|
+
potential_impact=None,
|
|
127
|
+
third_party_tools=None,
|
|
128
|
+
mitigation_control=None,
|
|
129
|
+
responsibility="Information Assurance Officer",
|
|
130
|
+
security_override_guidance=None,
|
|
131
|
+
legacy_id=None,
|
|
132
|
+
status="NotAFinding",
|
|
133
|
+
finding_details="The network device does log all access control lists (ACL) deny statements.",
|
|
134
|
+
comments="The network device does log all access control lists (ACL) deny statements.",
|
|
135
|
+
severity_override="",
|
|
136
|
+
severity_justification="",
|
|
137
|
+
)
|
|
138
|
+
],
|
|
139
|
+
)
|
|
140
|
+
],
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
@pytest.mark.parametrize(
|
|
144
|
+
"checklist_titles, expected_components",
|
|
145
|
+
[
|
|
146
|
+
(
|
|
147
|
+
Checklist(
|
|
148
|
+
assets=[sample_asset],
|
|
149
|
+
stigs=[
|
|
150
|
+
STIG(
|
|
151
|
+
baseline="Perimeter Router Security Technical Implementation Guide Cisco",
|
|
152
|
+
stig_info=STIGInfo(
|
|
153
|
+
title="Perimeter Router Security Technical Implementation Guide Cisco",
|
|
154
|
+
version="8",
|
|
155
|
+
classification="UNCLASSIFIED",
|
|
156
|
+
stigid="Network_-_Perimeter_Router_Cisco",
|
|
157
|
+
filename="U_Network_Perimeter_Router_Cisco_STIG_V8R32_Manual-xccdf.xml",
|
|
158
|
+
releaseinfo="Release: 32 Benchmark Date: 25 Jan 2019",
|
|
159
|
+
uuid="459468bf-6c90-49ff-8389-28df0ff0e556",
|
|
160
|
+
notice="terms-of-use",
|
|
161
|
+
),
|
|
162
|
+
)
|
|
163
|
+
],
|
|
164
|
+
),
|
|
165
|
+
[
|
|
166
|
+
{
|
|
167
|
+
"Network_-_Perimeter_Router_Cisco": "Perimeter Router Security Technical Implementation Guide Cisco"
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
),
|
|
171
|
+
(
|
|
172
|
+
Checklist(
|
|
173
|
+
assets=[sample_asset],
|
|
174
|
+
stigs=[
|
|
175
|
+
STIG(
|
|
176
|
+
baseline="Data Center Security Technical Implementation Guide",
|
|
177
|
+
stig_info=STIGInfo(
|
|
178
|
+
title="Data Center Security Technical Implementation Guide",
|
|
179
|
+
version="2",
|
|
180
|
+
classification="UNCLASSIFIED",
|
|
181
|
+
stigid="Data_Center_Cisco",
|
|
182
|
+
filename="U_Data_Center_Cisco_STIG_V2R1_Manual-xccdf.xml",
|
|
183
|
+
releaseinfo="Release: 1 Benchmark Date: 15 Feb 2021",
|
|
184
|
+
uuid="a1b2c3d4-5678-90ab-cdef-1234567890ab",
|
|
185
|
+
notice="terms-of-use",
|
|
186
|
+
),
|
|
187
|
+
),
|
|
188
|
+
STIG(
|
|
189
|
+
baseline="Wireless Network (STIG)",
|
|
190
|
+
stig_info=STIGInfo(
|
|
191
|
+
title="Wireless Network (STIG)",
|
|
192
|
+
version="3",
|
|
193
|
+
classification="UNCLASSIFIED",
|
|
194
|
+
stigid="Wireless_Network",
|
|
195
|
+
filename="U_Wireless_Network_STIG_V3R1_Manual-xccdf.xml",
|
|
196
|
+
releaseinfo="Release: 1 Benchmark Date: 05 May 2022",
|
|
197
|
+
uuid="09876543-21ab-cdef-ghij-klmnopqrstuv",
|
|
198
|
+
notice="terms-of-use",
|
|
199
|
+
),
|
|
200
|
+
),
|
|
201
|
+
],
|
|
202
|
+
),
|
|
203
|
+
[
|
|
204
|
+
{"Data_Center_Cisco": "Data Center Security Technical Implementation Guide"},
|
|
205
|
+
{"Wireless_Network": "Wireless Network (STIG)"},
|
|
206
|
+
],
|
|
207
|
+
),
|
|
208
|
+
(
|
|
209
|
+
Checklist(
|
|
210
|
+
assets=[sample_asset],
|
|
211
|
+
stigs=[
|
|
212
|
+
STIG(
|
|
213
|
+
baseline="Non-STIG Title Without Expected Phrases",
|
|
214
|
+
stig_info=STIGInfo(
|
|
215
|
+
title="Non-STIG Title Without Expected Phrases",
|
|
216
|
+
version="N/A",
|
|
217
|
+
classification="UNCLASSIFIED",
|
|
218
|
+
stigid="Non-STIG",
|
|
219
|
+
filename="N/A",
|
|
220
|
+
releaseinfo="N/A",
|
|
221
|
+
uuid="N/A",
|
|
222
|
+
notice="N/A",
|
|
223
|
+
),
|
|
224
|
+
)
|
|
225
|
+
],
|
|
226
|
+
),
|
|
227
|
+
[{"Non-STIG": "Non-STIG Title Without Expected Phrases"}],
|
|
228
|
+
),
|
|
229
|
+
],
|
|
230
|
+
)
|
|
231
|
+
def test_get_components_from_checklist(self, checklist_titles, expected_components):
|
|
232
|
+
assert list(get_components_from_checklist(checklist_titles)) == expected_components
|
|
233
|
+
|
|
234
|
+
@pytest.mark.parametrize(
|
|
235
|
+
"checklists, expected_unique_components",
|
|
236
|
+
[
|
|
237
|
+
(
|
|
238
|
+
[
|
|
239
|
+
Checklist(
|
|
240
|
+
asset=sample_asset,
|
|
241
|
+
stigs=[
|
|
242
|
+
STIG(
|
|
243
|
+
baseline="Perimeter Router Security Technical Implementation Guide Cisco",
|
|
244
|
+
stig_info=STIGInfo(
|
|
245
|
+
title="Perimeter Router Security Technical Implementation Guide Cisco",
|
|
246
|
+
version="8",
|
|
247
|
+
classification="UNCLASSIFIED",
|
|
248
|
+
stigid="Network_-_Perimeter_Router_Cisco",
|
|
249
|
+
filename="U_Network_Perimeter_Router_Cisco_STIG_V8R32_Manual-xccdf.xml",
|
|
250
|
+
releaseinfo="Release: 32 Benchmark Date: 25 Jan 2019",
|
|
251
|
+
uuid="459468bf-6c90-49ff-8389-28df0ff0e556",
|
|
252
|
+
notice="terms-of-use",
|
|
253
|
+
),
|
|
254
|
+
)
|
|
255
|
+
],
|
|
256
|
+
),
|
|
257
|
+
Checklist(
|
|
258
|
+
asset=sample_asset,
|
|
259
|
+
stigs=[
|
|
260
|
+
STIG(
|
|
261
|
+
baseline="Perimeter Router Security Technical Implementation Guide Cisco",
|
|
262
|
+
stig_info=STIGInfo(
|
|
263
|
+
title="Perimeter Router Security Technical Implementation Guide Cisco",
|
|
264
|
+
version="8",
|
|
265
|
+
classification="UNCLASSIFIED",
|
|
266
|
+
stigid="Network_-_Perimeter_Router_Cisco",
|
|
267
|
+
filename="U_Network_Perimeter_Router_Cisco_STIG_V8R32_Manual-xccdf.xml",
|
|
268
|
+
releaseinfo="Release: 32 Benchmark Date: 25 Jan 2019",
|
|
269
|
+
uuid="459468bf-6c90-49ff-8389-28df0ff0e556",
|
|
270
|
+
notice="terms-of-use",
|
|
271
|
+
),
|
|
272
|
+
)
|
|
273
|
+
],
|
|
274
|
+
),
|
|
275
|
+
],
|
|
276
|
+
{"Network_-_Perimeter_Router_Cisco": "Perimeter Router Security Technical Implementation Guide Cisco"},
|
|
277
|
+
),
|
|
278
|
+
(
|
|
279
|
+
[
|
|
280
|
+
Checklist(
|
|
281
|
+
asset=sample_asset,
|
|
282
|
+
stigs=[
|
|
283
|
+
STIG(
|
|
284
|
+
baseline="Data Center Security Technical Implementation Guide",
|
|
285
|
+
stig_info=STIGInfo(
|
|
286
|
+
title="Data Center Security Technical Implementation Guide",
|
|
287
|
+
version="2",
|
|
288
|
+
classification="UNCLASSIFIED",
|
|
289
|
+
stigid="Data_Center_Cisco",
|
|
290
|
+
filename="U_Data_Center_Cisco_STIG_V2R1_Manual-xccdf.xml",
|
|
291
|
+
releaseinfo="Release: 1 Benchmark Date: 15 Feb 2021",
|
|
292
|
+
uuid="a1b2c3d4-5678-90ab-cdef-1234567890ab",
|
|
293
|
+
notice="terms-of-use",
|
|
294
|
+
),
|
|
295
|
+
)
|
|
296
|
+
],
|
|
297
|
+
),
|
|
298
|
+
Checklist(
|
|
299
|
+
asset=sample_asset,
|
|
300
|
+
stigs=[
|
|
301
|
+
STIG(
|
|
302
|
+
baseline="Wireless Network (STIG)",
|
|
303
|
+
stig_info=STIGInfo(
|
|
304
|
+
title="Wireless Network (STIG)",
|
|
305
|
+
version="3",
|
|
306
|
+
classification="UNCLASSIFIED",
|
|
307
|
+
stigid="Wireless_Network",
|
|
308
|
+
filename="U_Wireless_Network_STIG_V3R1_Manual-xccdf.xml",
|
|
309
|
+
releaseinfo="Release: 1 Benchmark Date: 05 May 2022",
|
|
310
|
+
uuid="09876543-21ab-cdef-ghij-klmnopqrstuv",
|
|
311
|
+
notice="terms-of-use",
|
|
312
|
+
),
|
|
313
|
+
)
|
|
314
|
+
],
|
|
315
|
+
),
|
|
316
|
+
Checklist(
|
|
317
|
+
asset=sample_asset,
|
|
318
|
+
stigs=[
|
|
319
|
+
STIG(
|
|
320
|
+
baseline="Data Center Security Technical Implementation Guide",
|
|
321
|
+
stig_info=STIGInfo(
|
|
322
|
+
title="Wireless Network (STIG)",
|
|
323
|
+
version="3",
|
|
324
|
+
classification="UNCLASSIFIED",
|
|
325
|
+
stigid="Wireless_Network",
|
|
326
|
+
filename="U_Wireless_Network_STIG_V3R1_Manual-xccdf.xml",
|
|
327
|
+
releaseinfo="Release: 1 Benchmark Date: 05 May 2022",
|
|
328
|
+
uuid="09876543-21ab-cdef-ghij-klmnopqrstuv",
|
|
329
|
+
notice="terms-of-use",
|
|
330
|
+
),
|
|
331
|
+
)
|
|
332
|
+
],
|
|
333
|
+
),
|
|
334
|
+
],
|
|
335
|
+
{
|
|
336
|
+
"Data_Center_Cisco": "Data Center Security Technical Implementation Guide",
|
|
337
|
+
"Wireless_Network": "Wireless Network (STIG)",
|
|
338
|
+
},
|
|
339
|
+
),
|
|
340
|
+
],
|
|
341
|
+
)
|
|
342
|
+
def test_get_all_components_from_checklists(self, checklists, expected_unique_components):
|
|
343
|
+
assert get_all_components_from_checklists(checklists) == expected_unique_components
|
|
344
|
+
|
|
345
|
+
@patch("regscale.integrations.commercial.stigv2.find_stig_files")
|
|
346
|
+
def test_fetch_findings(self, mock_find_stig_files, test_tmp_dir):
|
|
347
|
+
mock_find_stig_files.return_value = [self.cisco_stig_file]
|
|
348
|
+
|
|
349
|
+
stig_integration = StigIntegration(plan_id=1)
|
|
350
|
+
findings = list(stig_integration.fetch_findings(self.chaos_stig_dir))
|
|
351
|
+
|
|
352
|
+
assert len(findings) == 145
|
|
353
|
+
mock_find_stig_files.assert_called_once_with(self.chaos_stig_dir)
|
|
354
|
+
|
|
355
|
+
def test_process_vulnerabilities(self):
|
|
356
|
+
stig_integration = StigIntegration(plan_id=1)
|
|
357
|
+
mock_checklist = MagicMock()
|
|
358
|
+
mock_checklist.assets = [MagicMock(host_fqdn="example.com")]
|
|
359
|
+
mock_vuln = MagicMock()
|
|
360
|
+
mock_vuln.cci_ref = [] # Set cci_ref to an empty list to ensure a finding with the default CCI is created
|
|
361
|
+
mock_stig = MagicMock()
|
|
362
|
+
|
|
363
|
+
findings = list(stig_integration.process_vulnerabilities(mock_checklist, mock_vuln, mock_stig))
|
|
364
|
+
|
|
365
|
+
assert len(findings) == 1, "Should yield one finding per vulnerability."
|
|
366
|
+
assert findings[0].asset_identifier == "example.com", "Asset identifier should match the host_fqdn."
|
|
367
|
+
|
|
368
|
+
def test_create_integration_finding(self):
|
|
369
|
+
stig_integration = StigIntegration(plan_id=1)
|
|
370
|
+
mock_vuln = MagicMock(
|
|
371
|
+
rule_title="Test Rule",
|
|
372
|
+
group_title="Test Group",
|
|
373
|
+
severity="low",
|
|
374
|
+
check_content="Check Content",
|
|
375
|
+
vuln_discuss="Vulnerability Discussion",
|
|
376
|
+
fix_text="Fix Text",
|
|
377
|
+
status="NotAFinding",
|
|
378
|
+
vuln_num="V-12345",
|
|
379
|
+
cci_ref="CCI-123",
|
|
380
|
+
rule_id="Rule-123",
|
|
381
|
+
rule_ver="999",
|
|
382
|
+
comments="Test Comment",
|
|
383
|
+
stigref="STIG Reference",
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
mock_stig = MagicMock(
|
|
387
|
+
stig_info=STIGInfo(
|
|
388
|
+
releaseinfo="Release Info",
|
|
389
|
+
classification="UNCLASSIFIED",
|
|
390
|
+
title="Test Title",
|
|
391
|
+
stigid="Test STIG",
|
|
392
|
+
version="1",
|
|
393
|
+
filename="Test File",
|
|
394
|
+
uuid="Test UUID",
|
|
395
|
+
notice="Test Notice",
|
|
396
|
+
)
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
finding = next(stig_integration.create_integration_finding("example.com", mock_vuln, mock_stig))
|
|
400
|
+
|
|
401
|
+
assert finding.title == "Test Rule 999 Release Info V-12345", "Title should match the rule title."
|
|
402
|
+
assert finding.severity == stig_integration.finding_severity_map["low"], "Severity should be mapped correctly."
|
|
403
|
+
assert (
|
|
404
|
+
finding.status == stig_integration.finding_status_map["NotAFinding"]
|
|
405
|
+
), "Status should be mapped correctly."
|
|
406
|
+
assert finding.due_date == date_str(days_from_today(364)), "Due date should be 394 days from today."
|