regscale-cli 6.16.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/__init__.py +1 -0
- regscale/airflow/__init__.py +9 -0
- regscale/airflow/azure/__init__.py +9 -0
- regscale/airflow/azure/cli.py +89 -0
- regscale/airflow/azure/upload_dags.py +116 -0
- regscale/airflow/click_dags.py +127 -0
- regscale/airflow/click_mixins.py +82 -0
- regscale/airflow/config.py +25 -0
- regscale/airflow/factories/__init__.py +0 -0
- regscale/airflow/factories/connections.py +58 -0
- regscale/airflow/factories/workflows.py +78 -0
- regscale/airflow/hierarchy.py +88 -0
- regscale/airflow/operators/__init__.py +0 -0
- regscale/airflow/operators/click.py +36 -0
- regscale/airflow/sensors/__init__.py +0 -0
- regscale/airflow/sensors/sql.py +107 -0
- regscale/airflow/sessions/__init__.py +0 -0
- regscale/airflow/sessions/sql/__init__.py +3 -0
- regscale/airflow/sessions/sql/queries.py +64 -0
- regscale/airflow/sessions/sql/sql_server_queries.py +248 -0
- regscale/airflow/tasks/__init__.py +0 -0
- regscale/airflow/tasks/branches.py +22 -0
- regscale/airflow/tasks/cli.py +116 -0
- regscale/airflow/tasks/click.py +73 -0
- regscale/airflow/tasks/debugging.py +9 -0
- regscale/airflow/tasks/groups.py +116 -0
- regscale/airflow/tasks/init.py +60 -0
- regscale/airflow/tasks/states.py +47 -0
- regscale/airflow/tasks/workflows.py +36 -0
- regscale/ansible/__init__.py +9 -0
- regscale/core/__init__.py +0 -0
- regscale/core/app/__init__.py +3 -0
- regscale/core/app/api.py +571 -0
- regscale/core/app/application.py +665 -0
- regscale/core/app/internal/__init__.py +136 -0
- regscale/core/app/internal/admin_actions.py +230 -0
- regscale/core/app/internal/assessments_editor.py +873 -0
- regscale/core/app/internal/catalog.py +316 -0
- regscale/core/app/internal/comparison.py +459 -0
- regscale/core/app/internal/control_editor.py +571 -0
- regscale/core/app/internal/encrypt.py +79 -0
- regscale/core/app/internal/evidence.py +1240 -0
- regscale/core/app/internal/file_uploads.py +151 -0
- regscale/core/app/internal/healthcheck.py +66 -0
- regscale/core/app/internal/login.py +305 -0
- regscale/core/app/internal/migrations.py +240 -0
- regscale/core/app/internal/model_editor.py +1701 -0
- regscale/core/app/internal/poam_editor.py +632 -0
- regscale/core/app/internal/workflow.py +105 -0
- regscale/core/app/logz.py +74 -0
- regscale/core/app/utils/XMLIR.py +258 -0
- regscale/core/app/utils/__init__.py +0 -0
- regscale/core/app/utils/api_handler.py +358 -0
- regscale/core/app/utils/app_utils.py +1110 -0
- regscale/core/app/utils/catalog_utils/__init__.py +0 -0
- regscale/core/app/utils/catalog_utils/common.py +91 -0
- regscale/core/app/utils/catalog_utils/compare_catalog.py +193 -0
- regscale/core/app/utils/catalog_utils/diagnostic_catalog.py +97 -0
- regscale/core/app/utils/catalog_utils/download_catalog.py +103 -0
- regscale/core/app/utils/catalog_utils/update_catalog.py +718 -0
- regscale/core/app/utils/catalog_utils/update_catalog_v2.py +1378 -0
- regscale/core/app/utils/catalog_utils/update_catalog_v3.py +1272 -0
- regscale/core/app/utils/catalog_utils/update_plans.py +334 -0
- regscale/core/app/utils/file_utils.py +238 -0
- regscale/core/app/utils/parser_utils.py +81 -0
- regscale/core/app/utils/pickle_file_handler.py +57 -0
- regscale/core/app/utils/regscale_utils.py +319 -0
- regscale/core/app/utils/report_utils.py +119 -0
- regscale/core/app/utils/variables.py +226 -0
- regscale/core/decorators.py +31 -0
- regscale/core/lazy_group.py +65 -0
- regscale/core/login.py +63 -0
- regscale/core/server/__init__.py +0 -0
- regscale/core/server/flask_api.py +473 -0
- regscale/core/server/helpers.py +373 -0
- regscale/core/server/rest.py +64 -0
- regscale/core/server/static/css/bootstrap.css +6030 -0
- regscale/core/server/static/css/bootstrap.min.css +6 -0
- regscale/core/server/static/css/main.css +176 -0
- regscale/core/server/static/images/regscale-cli.svg +49 -0
- regscale/core/server/static/images/regscale.svg +38 -0
- regscale/core/server/templates/base.html +74 -0
- regscale/core/server/templates/index.html +43 -0
- regscale/core/server/templates/login.html +28 -0
- regscale/core/server/templates/make_base64.html +22 -0
- regscale/core/server/templates/upload_STIG.html +109 -0
- regscale/core/server/templates/upload_STIG_result.html +26 -0
- regscale/core/server/templates/upload_ssp.html +144 -0
- regscale/core/server/templates/upload_ssp_result.html +128 -0
- regscale/core/static/__init__.py +0 -0
- regscale/core/static/regex.py +14 -0
- regscale/core/utils/__init__.py +117 -0
- regscale/core/utils/click_utils.py +13 -0
- regscale/core/utils/date.py +238 -0
- regscale/core/utils/graphql.py +254 -0
- regscale/core/utils/urls.py +23 -0
- regscale/dev/__init__.py +6 -0
- regscale/dev/analysis.py +454 -0
- regscale/dev/cli.py +235 -0
- regscale/dev/code_gen.py +492 -0
- regscale/dev/dirs.py +69 -0
- regscale/dev/docs.py +384 -0
- regscale/dev/monitoring.py +26 -0
- regscale/dev/profiling.py +216 -0
- regscale/exceptions/__init__.py +4 -0
- regscale/exceptions/license_exception.py +7 -0
- regscale/exceptions/validation_exception.py +9 -0
- regscale/integrations/__init__.py +1 -0
- regscale/integrations/commercial/__init__.py +486 -0
- regscale/integrations/commercial/ad.py +433 -0
- regscale/integrations/commercial/amazon/__init__.py +0 -0
- regscale/integrations/commercial/amazon/common.py +106 -0
- regscale/integrations/commercial/aqua/__init__.py +0 -0
- regscale/integrations/commercial/aqua/aqua.py +91 -0
- regscale/integrations/commercial/aws/__init__.py +6 -0
- regscale/integrations/commercial/aws/cli.py +322 -0
- regscale/integrations/commercial/aws/inventory/__init__.py +110 -0
- regscale/integrations/commercial/aws/inventory/base.py +64 -0
- regscale/integrations/commercial/aws/inventory/resources/__init__.py +19 -0
- regscale/integrations/commercial/aws/inventory/resources/compute.py +234 -0
- regscale/integrations/commercial/aws/inventory/resources/containers.py +113 -0
- regscale/integrations/commercial/aws/inventory/resources/database.py +101 -0
- regscale/integrations/commercial/aws/inventory/resources/integration.py +237 -0
- regscale/integrations/commercial/aws/inventory/resources/networking.py +253 -0
- regscale/integrations/commercial/aws/inventory/resources/security.py +240 -0
- regscale/integrations/commercial/aws/inventory/resources/storage.py +91 -0
- regscale/integrations/commercial/aws/scanner.py +823 -0
- regscale/integrations/commercial/azure/__init__.py +0 -0
- regscale/integrations/commercial/azure/common.py +32 -0
- regscale/integrations/commercial/azure/intune.py +488 -0
- regscale/integrations/commercial/azure/scanner.py +49 -0
- regscale/integrations/commercial/burp.py +78 -0
- regscale/integrations/commercial/cpe.py +144 -0
- regscale/integrations/commercial/crowdstrike.py +1117 -0
- regscale/integrations/commercial/defender.py +1511 -0
- regscale/integrations/commercial/dependabot.py +210 -0
- regscale/integrations/commercial/durosuite/__init__.py +0 -0
- regscale/integrations/commercial/durosuite/api.py +1546 -0
- regscale/integrations/commercial/durosuite/process_devices.py +101 -0
- regscale/integrations/commercial/durosuite/scanner.py +637 -0
- regscale/integrations/commercial/durosuite/variables.py +21 -0
- regscale/integrations/commercial/ecr.py +90 -0
- regscale/integrations/commercial/gcp/__init__.py +237 -0
- regscale/integrations/commercial/gcp/auth.py +96 -0
- regscale/integrations/commercial/gcp/control_tests.py +238 -0
- regscale/integrations/commercial/gcp/variables.py +18 -0
- regscale/integrations/commercial/gitlab.py +332 -0
- regscale/integrations/commercial/grype.py +165 -0
- regscale/integrations/commercial/ibm.py +90 -0
- regscale/integrations/commercial/import_all/__init__.py +0 -0
- regscale/integrations/commercial/import_all/import_all_cmd.py +467 -0
- regscale/integrations/commercial/import_all/scan_file_fingerprints.json +27 -0
- regscale/integrations/commercial/jira.py +1046 -0
- regscale/integrations/commercial/mappings/__init__.py +0 -0
- regscale/integrations/commercial/mappings/csf_controls.json +713 -0
- regscale/integrations/commercial/mappings/nist_800_53_r5_controls.json +1516 -0
- regscale/integrations/commercial/nessus/__init__.py +0 -0
- regscale/integrations/commercial/nessus/nessus_utils.py +429 -0
- regscale/integrations/commercial/nessus/scanner.py +416 -0
- regscale/integrations/commercial/nexpose.py +90 -0
- regscale/integrations/commercial/okta.py +798 -0
- regscale/integrations/commercial/opentext/__init__.py +0 -0
- regscale/integrations/commercial/opentext/click.py +99 -0
- regscale/integrations/commercial/opentext/scanner.py +143 -0
- regscale/integrations/commercial/prisma.py +91 -0
- regscale/integrations/commercial/qualys.py +1462 -0
- regscale/integrations/commercial/salesforce.py +980 -0
- regscale/integrations/commercial/sap/__init__.py +0 -0
- regscale/integrations/commercial/sap/click.py +31 -0
- regscale/integrations/commercial/sap/sysdig/__init__.py +0 -0
- regscale/integrations/commercial/sap/sysdig/click.py +57 -0
- regscale/integrations/commercial/sap/sysdig/sysdig_scanner.py +190 -0
- regscale/integrations/commercial/sap/tenable/__init__.py +0 -0
- regscale/integrations/commercial/sap/tenable/click.py +49 -0
- regscale/integrations/commercial/sap/tenable/scanner.py +196 -0
- regscale/integrations/commercial/servicenow.py +1756 -0
- regscale/integrations/commercial/sicura/__init__.py +0 -0
- regscale/integrations/commercial/sicura/api.py +855 -0
- regscale/integrations/commercial/sicura/commands.py +73 -0
- regscale/integrations/commercial/sicura/scanner.py +481 -0
- regscale/integrations/commercial/sicura/variables.py +16 -0
- regscale/integrations/commercial/snyk.py +90 -0
- regscale/integrations/commercial/sonarcloud.py +260 -0
- regscale/integrations/commercial/sqlserver.py +369 -0
- regscale/integrations/commercial/stig_mapper_integration/__init__.py +0 -0
- regscale/integrations/commercial/stig_mapper_integration/click_commands.py +38 -0
- regscale/integrations/commercial/stig_mapper_integration/mapping_engine.py +353 -0
- regscale/integrations/commercial/stigv2/__init__.py +0 -0
- regscale/integrations/commercial/stigv2/ckl_parser.py +349 -0
- regscale/integrations/commercial/stigv2/click_commands.py +95 -0
- regscale/integrations/commercial/stigv2/stig_integration.py +202 -0
- regscale/integrations/commercial/synqly/__init__.py +0 -0
- regscale/integrations/commercial/synqly/assets.py +46 -0
- regscale/integrations/commercial/synqly/ticketing.py +132 -0
- regscale/integrations/commercial/synqly/vulnerabilities.py +223 -0
- regscale/integrations/commercial/synqly_jira.py +840 -0
- regscale/integrations/commercial/tenablev2/__init__.py +0 -0
- regscale/integrations/commercial/tenablev2/authenticate.py +31 -0
- regscale/integrations/commercial/tenablev2/click.py +1584 -0
- regscale/integrations/commercial/tenablev2/scanner.py +504 -0
- regscale/integrations/commercial/tenablev2/stig_parsers.py +140 -0
- regscale/integrations/commercial/tenablev2/utils.py +78 -0
- regscale/integrations/commercial/tenablev2/variables.py +17 -0
- regscale/integrations/commercial/trivy.py +162 -0
- regscale/integrations/commercial/veracode.py +96 -0
- regscale/integrations/commercial/wizv2/WizDataMixin.py +97 -0
- regscale/integrations/commercial/wizv2/__init__.py +0 -0
- regscale/integrations/commercial/wizv2/click.py +429 -0
- regscale/integrations/commercial/wizv2/constants.py +1001 -0
- regscale/integrations/commercial/wizv2/issue.py +361 -0
- regscale/integrations/commercial/wizv2/models.py +112 -0
- regscale/integrations/commercial/wizv2/parsers.py +339 -0
- regscale/integrations/commercial/wizv2/sbom.py +115 -0
- regscale/integrations/commercial/wizv2/scanner.py +416 -0
- regscale/integrations/commercial/wizv2/utils.py +796 -0
- regscale/integrations/commercial/wizv2/variables.py +39 -0
- regscale/integrations/commercial/wizv2/wiz_auth.py +159 -0
- regscale/integrations/commercial/xray.py +91 -0
- regscale/integrations/integration/__init__.py +2 -0
- regscale/integrations/integration/integration.py +26 -0
- regscale/integrations/integration/inventory.py +17 -0
- regscale/integrations/integration/issue.py +100 -0
- regscale/integrations/integration_override.py +149 -0
- regscale/integrations/public/__init__.py +103 -0
- regscale/integrations/public/cisa.py +641 -0
- regscale/integrations/public/criticality_updater.py +70 -0
- regscale/integrations/public/emass.py +411 -0
- regscale/integrations/public/emass_slcm_import.py +697 -0
- regscale/integrations/public/fedramp/__init__.py +0 -0
- regscale/integrations/public/fedramp/appendix_parser.py +548 -0
- regscale/integrations/public/fedramp/click.py +479 -0
- regscale/integrations/public/fedramp/components.py +714 -0
- regscale/integrations/public/fedramp/docx_parser.py +259 -0
- regscale/integrations/public/fedramp/fedramp_cis_crm.py +1124 -0
- regscale/integrations/public/fedramp/fedramp_common.py +3181 -0
- regscale/integrations/public/fedramp/fedramp_docx.py +388 -0
- regscale/integrations/public/fedramp/fedramp_five.py +2343 -0
- regscale/integrations/public/fedramp/fedramp_traversal.py +138 -0
- regscale/integrations/public/fedramp/import_fedramp_r4_ssp.py +279 -0
- regscale/integrations/public/fedramp/import_workbook.py +495 -0
- regscale/integrations/public/fedramp/inventory_items.py +244 -0
- regscale/integrations/public/fedramp/mappings/__init__.py +0 -0
- regscale/integrations/public/fedramp/mappings/fedramp_r4_parts.json +7388 -0
- regscale/integrations/public/fedramp/mappings/fedramp_r5_params.json +8636 -0
- regscale/integrations/public/fedramp/mappings/fedramp_r5_parts.json +9605 -0
- regscale/integrations/public/fedramp/mappings/system_roles.py +34 -0
- regscale/integrations/public/fedramp/mappings/user.py +175 -0
- regscale/integrations/public/fedramp/mappings/values.py +141 -0
- regscale/integrations/public/fedramp/markdown_parser.py +150 -0
- regscale/integrations/public/fedramp/metadata.py +689 -0
- regscale/integrations/public/fedramp/models/__init__.py +59 -0
- regscale/integrations/public/fedramp/models/leveraged_auth_new.py +168 -0
- regscale/integrations/public/fedramp/models/poam_importer.py +522 -0
- regscale/integrations/public/fedramp/parts_mapper.py +107 -0
- regscale/integrations/public/fedramp/poam/__init__.py +0 -0
- regscale/integrations/public/fedramp/poam/scanner.py +851 -0
- regscale/integrations/public/fedramp/properties.py +201 -0
- regscale/integrations/public/fedramp/reporting.py +84 -0
- regscale/integrations/public/fedramp/resources.py +496 -0
- regscale/integrations/public/fedramp/rosetta.py +110 -0
- regscale/integrations/public/fedramp/ssp_logger.py +87 -0
- regscale/integrations/public/fedramp/system_characteristics.py +922 -0
- regscale/integrations/public/fedramp/system_control_implementations.py +582 -0
- regscale/integrations/public/fedramp/system_implementation.py +190 -0
- regscale/integrations/public/fedramp/xml_utils.py +87 -0
- regscale/integrations/public/nist_catalog.py +275 -0
- regscale/integrations/public/oscal.py +1946 -0
- regscale/integrations/public/otx.py +169 -0
- regscale/integrations/scanner_integration.py +2692 -0
- regscale/integrations/variables.py +25 -0
- regscale/models/__init__.py +7 -0
- regscale/models/app_models/__init__.py +5 -0
- regscale/models/app_models/catalog_compare.py +213 -0
- regscale/models/app_models/click.py +252 -0
- regscale/models/app_models/datetime_encoder.py +21 -0
- regscale/models/app_models/import_validater.py +321 -0
- regscale/models/app_models/mapping.py +260 -0
- regscale/models/app_models/pipeline.py +37 -0
- regscale/models/click_models.py +413 -0
- regscale/models/config.py +154 -0
- regscale/models/email_style.css +67 -0
- regscale/models/hierarchy.py +8 -0
- regscale/models/inspect_models.py +79 -0
- regscale/models/integration_models/__init__.py +0 -0
- regscale/models/integration_models/amazon_models/__init__.py +0 -0
- regscale/models/integration_models/amazon_models/inspector.py +262 -0
- regscale/models/integration_models/amazon_models/inspector_scan.py +206 -0
- regscale/models/integration_models/aqua.py +247 -0
- regscale/models/integration_models/azure_alerts.py +255 -0
- regscale/models/integration_models/base64.py +23 -0
- regscale/models/integration_models/burp.py +433 -0
- regscale/models/integration_models/burp_models.py +128 -0
- regscale/models/integration_models/cisa_kev_data.json +19333 -0
- regscale/models/integration_models/defender_data.py +93 -0
- regscale/models/integration_models/defenderimport.py +143 -0
- regscale/models/integration_models/drf.py +443 -0
- regscale/models/integration_models/ecr_models/__init__.py +0 -0
- regscale/models/integration_models/ecr_models/data.py +69 -0
- regscale/models/integration_models/ecr_models/ecr.py +239 -0
- regscale/models/integration_models/flat_file_importer.py +1079 -0
- regscale/models/integration_models/grype_import.py +247 -0
- regscale/models/integration_models/ibm.py +126 -0
- regscale/models/integration_models/implementation_results.py +85 -0
- regscale/models/integration_models/nexpose.py +140 -0
- regscale/models/integration_models/prisma.py +202 -0
- regscale/models/integration_models/qualys.py +720 -0
- regscale/models/integration_models/qualys_scanner.py +160 -0
- regscale/models/integration_models/sbom/__init__.py +0 -0
- regscale/models/integration_models/sbom/cyclone_dx.py +139 -0
- regscale/models/integration_models/send_reminders.py +620 -0
- regscale/models/integration_models/snyk.py +155 -0
- regscale/models/integration_models/synqly_models/__init__.py +0 -0
- regscale/models/integration_models/synqly_models/capabilities.json +1 -0
- regscale/models/integration_models/synqly_models/connector_types.py +22 -0
- regscale/models/integration_models/synqly_models/connectors/__init__.py +7 -0
- regscale/models/integration_models/synqly_models/connectors/assets.py +97 -0
- regscale/models/integration_models/synqly_models/connectors/ticketing.py +583 -0
- regscale/models/integration_models/synqly_models/connectors/vulnerabilities.py +169 -0
- regscale/models/integration_models/synqly_models/ocsf_mapper.py +331 -0
- regscale/models/integration_models/synqly_models/param.py +72 -0
- regscale/models/integration_models/synqly_models/synqly_model.py +733 -0
- regscale/models/integration_models/synqly_models/tenants.py +39 -0
- regscale/models/integration_models/tenable_models/__init__.py +0 -0
- regscale/models/integration_models/tenable_models/integration.py +187 -0
- regscale/models/integration_models/tenable_models/models.py +513 -0
- regscale/models/integration_models/trivy_import.py +231 -0
- regscale/models/integration_models/veracode.py +217 -0
- regscale/models/integration_models/xray.py +135 -0
- regscale/models/locking.py +100 -0
- regscale/models/platform.py +110 -0
- regscale/models/regscale_models/__init__.py +67 -0
- regscale/models/regscale_models/assessment.py +570 -0
- regscale/models/regscale_models/assessment_plan.py +52 -0
- regscale/models/regscale_models/asset.py +567 -0
- regscale/models/regscale_models/asset_mapping.py +190 -0
- regscale/models/regscale_models/case.py +42 -0
- regscale/models/regscale_models/catalog.py +261 -0
- regscale/models/regscale_models/cci.py +46 -0
- regscale/models/regscale_models/change.py +167 -0
- regscale/models/regscale_models/checklist.py +372 -0
- regscale/models/regscale_models/comment.py +49 -0
- regscale/models/regscale_models/compliance_settings.py +112 -0
- regscale/models/regscale_models/component.py +412 -0
- regscale/models/regscale_models/component_mapping.py +65 -0
- regscale/models/regscale_models/control.py +38 -0
- regscale/models/regscale_models/control_implementation.py +1128 -0
- regscale/models/regscale_models/control_objective.py +261 -0
- regscale/models/regscale_models/control_parameter.py +100 -0
- regscale/models/regscale_models/control_test.py +34 -0
- regscale/models/regscale_models/control_test_plan.py +75 -0
- regscale/models/regscale_models/control_test_result.py +52 -0
- regscale/models/regscale_models/custom_field.py +245 -0
- regscale/models/regscale_models/data.py +109 -0
- regscale/models/regscale_models/data_center.py +40 -0
- regscale/models/regscale_models/deviation.py +203 -0
- regscale/models/regscale_models/email.py +97 -0
- regscale/models/regscale_models/evidence.py +47 -0
- regscale/models/regscale_models/evidence_mapping.py +40 -0
- regscale/models/regscale_models/facility.py +59 -0
- regscale/models/regscale_models/file.py +382 -0
- regscale/models/regscale_models/filetag.py +37 -0
- regscale/models/regscale_models/form_field_value.py +94 -0
- regscale/models/regscale_models/group.py +169 -0
- regscale/models/regscale_models/implementation_objective.py +335 -0
- regscale/models/regscale_models/implementation_option.py +275 -0
- regscale/models/regscale_models/implementation_role.py +33 -0
- regscale/models/regscale_models/incident.py +177 -0
- regscale/models/regscale_models/interconnection.py +43 -0
- regscale/models/regscale_models/issue.py +1176 -0
- regscale/models/regscale_models/leveraged_authorization.py +125 -0
- regscale/models/regscale_models/line_of_inquiry.py +52 -0
- regscale/models/regscale_models/link.py +205 -0
- regscale/models/regscale_models/meta_data.py +64 -0
- regscale/models/regscale_models/mixins/__init__.py +0 -0
- regscale/models/regscale_models/mixins/parent_cache.py +124 -0
- regscale/models/regscale_models/module.py +224 -0
- regscale/models/regscale_models/modules.py +191 -0
- regscale/models/regscale_models/objective.py +14 -0
- regscale/models/regscale_models/parameter.py +87 -0
- regscale/models/regscale_models/ports_protocol.py +81 -0
- regscale/models/regscale_models/privacy.py +89 -0
- regscale/models/regscale_models/profile.py +50 -0
- regscale/models/regscale_models/profile_link.py +68 -0
- regscale/models/regscale_models/profile_mapping.py +124 -0
- regscale/models/regscale_models/project.py +63 -0
- regscale/models/regscale_models/property.py +278 -0
- regscale/models/regscale_models/question.py +85 -0
- regscale/models/regscale_models/questionnaire.py +87 -0
- regscale/models/regscale_models/questionnaire_instance.py +177 -0
- regscale/models/regscale_models/rbac.py +132 -0
- regscale/models/regscale_models/reference.py +86 -0
- regscale/models/regscale_models/regscale_model.py +1643 -0
- regscale/models/regscale_models/requirement.py +29 -0
- regscale/models/regscale_models/risk.py +274 -0
- regscale/models/regscale_models/sbom.py +54 -0
- regscale/models/regscale_models/scan_history.py +436 -0
- regscale/models/regscale_models/search.py +53 -0
- regscale/models/regscale_models/security_control.py +132 -0
- regscale/models/regscale_models/security_plan.py +204 -0
- regscale/models/regscale_models/software_inventory.py +159 -0
- regscale/models/regscale_models/stake_holder.py +64 -0
- regscale/models/regscale_models/stig.py +647 -0
- regscale/models/regscale_models/supply_chain.py +152 -0
- regscale/models/regscale_models/system_role.py +188 -0
- regscale/models/regscale_models/system_role_external_assignment.py +40 -0
- regscale/models/regscale_models/tag.py +37 -0
- regscale/models/regscale_models/tag_mapping.py +19 -0
- regscale/models/regscale_models/task.py +133 -0
- regscale/models/regscale_models/threat.py +196 -0
- regscale/models/regscale_models/user.py +175 -0
- regscale/models/regscale_models/user_group.py +55 -0
- regscale/models/regscale_models/vulnerability.py +242 -0
- regscale/models/regscale_models/vulnerability_mapping.py +162 -0
- regscale/models/regscale_models/workflow.py +55 -0
- regscale/models/regscale_models/workflow_action.py +34 -0
- regscale/models/regscale_models/workflow_instance.py +269 -0
- regscale/models/regscale_models/workflow_instance_step.py +114 -0
- regscale/models/regscale_models/workflow_template.py +58 -0
- regscale/models/regscale_models/workflow_template_step.py +45 -0
- regscale/regscale.py +815 -0
- regscale/utils/__init__.py +7 -0
- regscale/utils/b64conversion.py +14 -0
- regscale/utils/click_utils.py +118 -0
- regscale/utils/decorators.py +48 -0
- regscale/utils/dict_utils.py +59 -0
- regscale/utils/files.py +79 -0
- regscale/utils/fxns.py +30 -0
- regscale/utils/graphql_client.py +113 -0
- regscale/utils/lists.py +16 -0
- regscale/utils/numbers.py +12 -0
- regscale/utils/shell.py +148 -0
- regscale/utils/string.py +121 -0
- regscale/utils/synqly_utils.py +165 -0
- regscale/utils/threading/__init__.py +8 -0
- regscale/utils/threading/threadhandler.py +131 -0
- regscale/utils/threading/threadsafe_counter.py +47 -0
- regscale/utils/threading/threadsafe_dict.py +242 -0
- regscale/utils/threading/threadsafe_list.py +83 -0
- regscale/utils/version.py +104 -0
- regscale/validation/__init__.py +0 -0
- regscale/validation/address.py +37 -0
- regscale/validation/record.py +48 -0
- regscale/visualization/__init__.py +5 -0
- regscale/visualization/click.py +34 -0
- regscale_cli-6.16.0.0.dist-info/LICENSE +21 -0
- regscale_cli-6.16.0.0.dist-info/METADATA +659 -0
- regscale_cli-6.16.0.0.dist-info/RECORD +481 -0
- regscale_cli-6.16.0.0.dist-info/WHEEL +5 -0
- regscale_cli-6.16.0.0.dist-info/entry_points.txt +6 -0
- regscale_cli-6.16.0.0.dist-info/top_level.txt +2 -0
- tests/fixtures/__init__.py +2 -0
- tests/fixtures/api.py +87 -0
- tests/fixtures/models.py +91 -0
- tests/fixtures/test_fixture.py +144 -0
- tests/mocks/__init__.py +0 -0
- tests/mocks/objects.py +3 -0
- tests/mocks/response.py +32 -0
- tests/mocks/xml.py +13 -0
- tests/regscale/__init__.py +0 -0
- tests/regscale/core/__init__.py +0 -0
- tests/regscale/core/test_api.py +232 -0
- tests/regscale/core/test_app.py +406 -0
- tests/regscale/core/test_login.py +37 -0
- tests/regscale/core/test_logz.py +66 -0
- tests/regscale/core/test_sbom_generator.py +87 -0
- tests/regscale/core/test_validation_utils.py +163 -0
- tests/regscale/core/test_version.py +78 -0
- tests/regscale/models/__init__.py +0 -0
- tests/regscale/models/test_asset.py +71 -0
- tests/regscale/models/test_config.py +26 -0
- tests/regscale/models/test_control_implementation.py +27 -0
- tests/regscale/models/test_import.py +97 -0
- tests/regscale/models/test_issue.py +36 -0
- tests/regscale/models/test_mapping.py +52 -0
- tests/regscale/models/test_platform.py +31 -0
- tests/regscale/models/test_regscale_model.py +346 -0
- tests/regscale/models/test_report.py +32 -0
- tests/regscale/models/test_tenable_integrations.py +118 -0
- tests/regscale/models/test_user_model.py +121 -0
- tests/regscale/test_about.py +19 -0
- tests/regscale/test_authorization.py +65 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Model for a RegScale Security Checklist"""
|
|
4
|
+
import warnings
|
|
5
|
+
from enum import Enum
|
|
6
|
+
from json import JSONDecodeError
|
|
7
|
+
from typing import Any, List, Optional, Union
|
|
8
|
+
from urllib.parse import urljoin
|
|
9
|
+
|
|
10
|
+
from pydantic import ConfigDict, Field
|
|
11
|
+
|
|
12
|
+
from regscale.core.app.api import Api
|
|
13
|
+
from regscale.core.app.application import Application
|
|
14
|
+
from regscale.core.app.utils.app_utils import get_current_datetime
|
|
15
|
+
from regscale.models.regscale_models.regscale_model import RegScaleModel
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ChecklistTool(str, Enum):
|
|
19
|
+
Ansible = "Ansible"
|
|
20
|
+
Chef = "Chef"
|
|
21
|
+
CISBenchmarks = "CIS Benchmarks"
|
|
22
|
+
MITRESAF = "MITRE SAF"
|
|
23
|
+
Puppet = "Puppet"
|
|
24
|
+
SCAP = "SCAP"
|
|
25
|
+
SIEM = "SIEM"
|
|
26
|
+
STIGs = "STIGs"
|
|
27
|
+
VulnerabilityScanner = "Vulnerability Scanner"
|
|
28
|
+
Other = "Other"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ChecklistStatus(str, Enum):
|
|
32
|
+
FAIL = "Fail"
|
|
33
|
+
PASS = "Pass"
|
|
34
|
+
NOT_APPLICABLE = "Not Applicable"
|
|
35
|
+
NOT_REVIEWED = "Not Reviewed"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Checklist(RegScaleModel):
|
|
39
|
+
"""RegScale Checklist
|
|
40
|
+
|
|
41
|
+
:return: RegScale Checklist
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
_module_slug = "securitychecklist"
|
|
45
|
+
_module_string = "securitychecklists"
|
|
46
|
+
# Should we include baseline, ruleId, check, and results in unique fields?
|
|
47
|
+
_unique_fields = [
|
|
48
|
+
[
|
|
49
|
+
"assetId",
|
|
50
|
+
"tool",
|
|
51
|
+
"vulnerabilityId",
|
|
52
|
+
],
|
|
53
|
+
]
|
|
54
|
+
_parent_id_field = "assetId"
|
|
55
|
+
# Required
|
|
56
|
+
id: int = 0
|
|
57
|
+
status: Union[ChecklistStatus, str]
|
|
58
|
+
assetId: int
|
|
59
|
+
tool: Union[ChecklistTool, str]
|
|
60
|
+
baseline: str
|
|
61
|
+
vulnerabilityId: str
|
|
62
|
+
results: str
|
|
63
|
+
check: str
|
|
64
|
+
version: Optional[str] = None
|
|
65
|
+
uuid: Optional[str] = None
|
|
66
|
+
ruleId: Optional[str] = None
|
|
67
|
+
cci: Optional[str] = None
|
|
68
|
+
comments: Optional[str] = None
|
|
69
|
+
createdById: Optional[str] = None
|
|
70
|
+
lastUpdatedById: Optional[str] = None
|
|
71
|
+
datePerformed: Optional[str] = None
|
|
72
|
+
isPublic: bool = True
|
|
73
|
+
dateCreated: Optional[str] = Field(default_factory=get_current_datetime)
|
|
74
|
+
dateLastUpdated: Optional[str] = Field(default_factory=get_current_datetime)
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def _get_additional_endpoints() -> ConfigDict:
|
|
78
|
+
"""
|
|
79
|
+
Override RegScaleModel and get additional endpoints for the Checklist model.
|
|
80
|
+
|
|
81
|
+
:return: A dictionary of additional endpoints
|
|
82
|
+
:rtype: ConfigDict
|
|
83
|
+
"""
|
|
84
|
+
return ConfigDict( # type: ignore
|
|
85
|
+
get_all_by_parent="/api/{model_slug}/getAllByParent/{intParentID}",
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def __hash__(self) -> hash:
|
|
89
|
+
"""
|
|
90
|
+
Enable object to be hashable
|
|
91
|
+
|
|
92
|
+
:return: Hashed Checklist
|
|
93
|
+
:rtype: hash
|
|
94
|
+
"""
|
|
95
|
+
return hash(
|
|
96
|
+
(
|
|
97
|
+
self.tool,
|
|
98
|
+
self.vulnerabilityId,
|
|
99
|
+
self.ruleId,
|
|
100
|
+
self.baseline,
|
|
101
|
+
self.check,
|
|
102
|
+
self.results,
|
|
103
|
+
self.comments,
|
|
104
|
+
self.assetId,
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
def __eq__(self, other: object) -> bool:
|
|
109
|
+
"""
|
|
110
|
+
Compare Checklists
|
|
111
|
+
|
|
112
|
+
:param object other: Checklist to compare against
|
|
113
|
+
:return: True if equal, False if not
|
|
114
|
+
:rtype: bool
|
|
115
|
+
"""
|
|
116
|
+
return (
|
|
117
|
+
# Unique values
|
|
118
|
+
# Tool, VulnerabilityId, RuleId, Baseline, [Check], Results, Comments, Status, AssetId,
|
|
119
|
+
# TenantsId, CCI, Version
|
|
120
|
+
self.tool == other.tool
|
|
121
|
+
and self.vulnerabilityId == other.vulnerabilityId
|
|
122
|
+
and self.ruleId == other.ruleId
|
|
123
|
+
and self.baseline == other.baseline
|
|
124
|
+
and self.check == other.check
|
|
125
|
+
and self.results == other.results
|
|
126
|
+
and self.comments == other.comments
|
|
127
|
+
and self.assetId == other.assetId
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
def __delitem__(self, key: Any) -> None:
|
|
131
|
+
"""
|
|
132
|
+
Delete an item from the Checklist
|
|
133
|
+
|
|
134
|
+
:param Any key: Key to delete
|
|
135
|
+
:rtype: None
|
|
136
|
+
"""
|
|
137
|
+
del self[key]
|
|
138
|
+
|
|
139
|
+
@staticmethod
|
|
140
|
+
def insert_or_update_checklist(
|
|
141
|
+
app: Application,
|
|
142
|
+
new_checklist: "Checklist",
|
|
143
|
+
existing_checklists: list[Any],
|
|
144
|
+
) -> Optional[int]:
|
|
145
|
+
"""
|
|
146
|
+
DEPRECATED: This method is deprecated and will be removed in a future version.
|
|
147
|
+
Use the create_or_update method instead.
|
|
148
|
+
|
|
149
|
+
Insert or update a checklist
|
|
150
|
+
|
|
151
|
+
:param Application app: RegScale Application instance
|
|
152
|
+
:param Checklist new_checklist: New checklist to insert or update
|
|
153
|
+
:param list[Any] existing_checklists: Existing checklists to compare against
|
|
154
|
+
:return: int of the checklist id or None
|
|
155
|
+
:rtype: Optional[int]
|
|
156
|
+
"""
|
|
157
|
+
warnings.warn(
|
|
158
|
+
"insert_or_update_checklist is deprecated and will be removed in a future version. "
|
|
159
|
+
"Use create_or_update method instead.",
|
|
160
|
+
DeprecationWarning,
|
|
161
|
+
)
|
|
162
|
+
delete_keys = [
|
|
163
|
+
"asset",
|
|
164
|
+
"uuid",
|
|
165
|
+
"lastUpdatedById",
|
|
166
|
+
"dateLastUpdated",
|
|
167
|
+
"createdById",
|
|
168
|
+
"dateCreated",
|
|
169
|
+
]
|
|
170
|
+
for dat in existing_checklists:
|
|
171
|
+
for key in delete_keys:
|
|
172
|
+
if key in dat:
|
|
173
|
+
del dat[key]
|
|
174
|
+
api = Api()
|
|
175
|
+
if matching_checklists := [
|
|
176
|
+
Checklist(**chk) for chk in existing_checklists if Checklist(**chk) == new_checklist
|
|
177
|
+
]:
|
|
178
|
+
app.logger.info("Updating checklist %s...", new_checklist.baseline)
|
|
179
|
+
new_checklist.id = matching_checklists[0].id
|
|
180
|
+
res = api.put(
|
|
181
|
+
url=urljoin(app.config["domain"], f"/api/securitychecklist/{new_checklist.id}"),
|
|
182
|
+
json=new_checklist.dict(),
|
|
183
|
+
)
|
|
184
|
+
else:
|
|
185
|
+
app.logger.info("Inserting checklist %s", new_checklist.baseline)
|
|
186
|
+
res = api.post(
|
|
187
|
+
url=urljoin(app.config["domain"], "/api/securitychecklist"),
|
|
188
|
+
json=new_checklist.dict(),
|
|
189
|
+
)
|
|
190
|
+
if res.status_code != 200:
|
|
191
|
+
app.logger.warning("Unable to insert or update checklist %s", new_checklist.baseline)
|
|
192
|
+
return None
|
|
193
|
+
return res.json()["id"]
|
|
194
|
+
|
|
195
|
+
@staticmethod
|
|
196
|
+
def batch_insert_or_update(
|
|
197
|
+
api: Api, checklists: list["Checklist"], method: Optional[str] = "insert"
|
|
198
|
+
) -> Optional[list["Checklist"]]:
|
|
199
|
+
"""
|
|
200
|
+
Insert a batch of checklists
|
|
201
|
+
|
|
202
|
+
:param Api api: RegScale API instance
|
|
203
|
+
:param list[Checklist] checklists: List of checklists to insert
|
|
204
|
+
:param Optional[str] method: Method to use (insert or update), defaults to insert
|
|
205
|
+
:return: List of checklists inserted
|
|
206
|
+
:rtype: Optional[list[Checklist]]
|
|
207
|
+
"""
|
|
208
|
+
if method == "insert":
|
|
209
|
+
endpoint = "batchCreate"
|
|
210
|
+
api.logger.info("Creating %i checklist(s) in RegScale...", len(checklists))
|
|
211
|
+
elif method == "update":
|
|
212
|
+
endpoint = "batchUpdate"
|
|
213
|
+
api.logger.info("Updating %i checklist(s) in RegScale...", len(checklists))
|
|
214
|
+
else:
|
|
215
|
+
api.logger.error("Invalid method %s, please use insert or update.", method)
|
|
216
|
+
return None
|
|
217
|
+
response = api.post(
|
|
218
|
+
url=urljoin(api.app.config["domain"], f"/api/securityChecklist/{endpoint}"),
|
|
219
|
+
json=[check.dict() for check in checklists],
|
|
220
|
+
)
|
|
221
|
+
if response.ok:
|
|
222
|
+
try:
|
|
223
|
+
return [Checklist(**check) for check in response.json()]
|
|
224
|
+
except TypeError as err:
|
|
225
|
+
api.logger.error("Unable to convert checklist(s): %s", err)
|
|
226
|
+
return None
|
|
227
|
+
except JSONDecodeError:
|
|
228
|
+
api.logger.error("Unable to %s checklist(s) in batch: %s", method, response.text)
|
|
229
|
+
return None
|
|
230
|
+
else:
|
|
231
|
+
api.logger.error(
|
|
232
|
+
"Unable to %s checklist(s) in batch: %i: %s %s",
|
|
233
|
+
method,
|
|
234
|
+
response.status_code,
|
|
235
|
+
response.reason,
|
|
236
|
+
response.text,
|
|
237
|
+
)
|
|
238
|
+
response.raise_for_status()
|
|
239
|
+
return None
|
|
240
|
+
|
|
241
|
+
@staticmethod
|
|
242
|
+
def analyze_and_batch_process(
|
|
243
|
+
app: Application,
|
|
244
|
+
new_checklists: Optional[list[dict]] = None,
|
|
245
|
+
existing_checklists: Optional[list["Checklist"]] = None,
|
|
246
|
+
) -> dict:
|
|
247
|
+
"""
|
|
248
|
+
Function to insert or update a checklist using batches via API
|
|
249
|
+
|
|
250
|
+
:param Application app: RegScale CLI Application instance
|
|
251
|
+
:param Optional[list[dict]] new_checklists: List of new checklists to insert or update
|
|
252
|
+
:param Optional[list[Checklist]] existing_checklists: List of existing checklists to compare against
|
|
253
|
+
:return: Dictionary with list of checklists inserted and/or updated
|
|
254
|
+
example: {'inserted': [], 'updated': [Checklist()...]}
|
|
255
|
+
:rtype: dict
|
|
256
|
+
"""
|
|
257
|
+
if not new_checklists:
|
|
258
|
+
new_checklists = []
|
|
259
|
+
|
|
260
|
+
api = Api()
|
|
261
|
+
results = {"inserted": [], "updated": []} # type: dict
|
|
262
|
+
# if no existing checklists, insert all new checklists and return results
|
|
263
|
+
if existing_checklists is None:
|
|
264
|
+
results["inserted"] = Checklist.batch_insert_or_update(api, new_checklists, "insert")
|
|
265
|
+
return results
|
|
266
|
+
# see if any of the new checklists already exist
|
|
267
|
+
update_checks = []
|
|
268
|
+
create_checks = []
|
|
269
|
+
for new_checklist in new_checklists:
|
|
270
|
+
if matching_checklists := [
|
|
271
|
+
check for check in existing_checklists if check.vulnerabilityId == new_checklist.vulnerabilityId
|
|
272
|
+
]:
|
|
273
|
+
new_checklist.id = matching_checklists[0].id
|
|
274
|
+
update_checks.append(new_checklist)
|
|
275
|
+
else:
|
|
276
|
+
create_checks.append(new_checklist)
|
|
277
|
+
if update_checks:
|
|
278
|
+
results["updated"] = Checklist.batch_insert_or_update(api, update_checks, "update")
|
|
279
|
+
if create_checks:
|
|
280
|
+
results["inserted"] = Checklist.batch_insert_or_update(api, create_checks, "insert")
|
|
281
|
+
return results
|
|
282
|
+
|
|
283
|
+
@classmethod
|
|
284
|
+
def get_checklists_by_asset(cls, api: Api, asset_id: int) -> List["Checklist"]: # noqa
|
|
285
|
+
"""
|
|
286
|
+
Return all checklists for a given RegScale parent id and parent module
|
|
287
|
+
|
|
288
|
+
:param Api api: RegScale CLI API instance
|
|
289
|
+
:param int asset_id: RegScale Asset ID
|
|
290
|
+
:return: List of checklists for the given asset_id
|
|
291
|
+
:rtype: List[Checklist]
|
|
292
|
+
"""
|
|
293
|
+
api.logger.info("Fetching all checklists for RegScale asset #%i...", asset_id)
|
|
294
|
+
response = api.get(
|
|
295
|
+
url=urljoin(
|
|
296
|
+
api.config.get("domain"),
|
|
297
|
+
f"/api/securityChecklist/getAllByParent/{asset_id}",
|
|
298
|
+
)
|
|
299
|
+
)
|
|
300
|
+
try:
|
|
301
|
+
if checklists := [Checklist(**check) for check in response.json()]:
|
|
302
|
+
api.logger.info(
|
|
303
|
+
"Found %i checklist(s) for asset #%i in RegScale.",
|
|
304
|
+
len(checklists),
|
|
305
|
+
asset_id,
|
|
306
|
+
)
|
|
307
|
+
return checklists
|
|
308
|
+
except TypeError as err:
|
|
309
|
+
api.logger.error("Unable to convert checklist(s): %s", err)
|
|
310
|
+
except JSONDecodeError:
|
|
311
|
+
api.logger.error(
|
|
312
|
+
"Unable to retrieve any checklists for asset #%i.\n%i: %s-%s",
|
|
313
|
+
asset_id,
|
|
314
|
+
response.status_code,
|
|
315
|
+
response.reason,
|
|
316
|
+
response.text,
|
|
317
|
+
)
|
|
318
|
+
return []
|
|
319
|
+
|
|
320
|
+
@staticmethod
|
|
321
|
+
def get_checklists(parent_id: int, parent_module: str = "components") -> List[dict]:
|
|
322
|
+
"""
|
|
323
|
+
Return all checklists for a given RegScale parent id and parent module
|
|
324
|
+
|
|
325
|
+
:param int parent_id: RegScale parent id
|
|
326
|
+
:param str parent_module: RegScale parent module, defaults to components
|
|
327
|
+
:return: List of checklists for the given parent id and module
|
|
328
|
+
:rtype: List[dict]
|
|
329
|
+
"""
|
|
330
|
+
app = Application()
|
|
331
|
+
api = Api()
|
|
332
|
+
app.logger.debug("Fetching all checklists for %s %s", parent_module, parent_id)
|
|
333
|
+
checklists = []
|
|
334
|
+
query = """
|
|
335
|
+
query {
|
|
336
|
+
securityChecklists(skip: 0, take: 50,where:{asset: {parentId: {eq: parent_id_placeholder}, parentModule: {eq: "parent_module_placeholder"}}}) {
|
|
337
|
+
items {
|
|
338
|
+
id
|
|
339
|
+
asset {
|
|
340
|
+
id
|
|
341
|
+
name
|
|
342
|
+
parentId
|
|
343
|
+
parentModule
|
|
344
|
+
}
|
|
345
|
+
status
|
|
346
|
+
tool
|
|
347
|
+
datePerformed
|
|
348
|
+
vulnerabilityId
|
|
349
|
+
ruleId
|
|
350
|
+
cci
|
|
351
|
+
check
|
|
352
|
+
results
|
|
353
|
+
baseline
|
|
354
|
+
comments
|
|
355
|
+
}
|
|
356
|
+
totalCount
|
|
357
|
+
pageInfo {
|
|
358
|
+
hasNextPage
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
""".replace(
|
|
363
|
+
"parent_id_placeholder", str(parent_id)
|
|
364
|
+
).replace(
|
|
365
|
+
"parent_module_placeholder", parent_module
|
|
366
|
+
)
|
|
367
|
+
data = api.graph(query)
|
|
368
|
+
if "securityChecklists" in data and "items" in data["securityChecklists"]:
|
|
369
|
+
for item in data["securityChecklists"]["items"]:
|
|
370
|
+
item["assetId"] = item["asset"]["id"]
|
|
371
|
+
checklists.append(item)
|
|
372
|
+
return checklists
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""This module contains the Comment model class."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from pydantic import Field, ConfigDict
|
|
6
|
+
|
|
7
|
+
from regscale.core.app.utils.app_utils import get_current_datetime
|
|
8
|
+
from .regscale_model import RegScaleModel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Comment(RegScaleModel):
|
|
12
|
+
"""
|
|
13
|
+
Comment model class
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
_module_slug = "comments"
|
|
17
|
+
_unique_fields = [
|
|
18
|
+
["comment", "parentID", "parentModule"],
|
|
19
|
+
]
|
|
20
|
+
_parent_id_field = "parentID"
|
|
21
|
+
|
|
22
|
+
id: int = 0
|
|
23
|
+
comment: str
|
|
24
|
+
commentDate: Optional[str] = None
|
|
25
|
+
parentID: int = 0
|
|
26
|
+
parentModule: Optional[str] = None
|
|
27
|
+
userId: str = Field(default_factory=RegScaleModel.get_user_id)
|
|
28
|
+
tenantsId: int = 1
|
|
29
|
+
createdById: str = Field(default_factory=RegScaleModel.get_user_id)
|
|
30
|
+
dateCreated: str = Field(default_factory=get_current_datetime)
|
|
31
|
+
dateLastUpdated: str = Field(default_factory=get_current_datetime)
|
|
32
|
+
isPublic: bool = True
|
|
33
|
+
lastUpdatedById: str = Field(default_factory=RegScaleModel.get_user_id)
|
|
34
|
+
partId: Optional[int] = None
|
|
35
|
+
partType: Optional[str] = None
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def _get_additional_endpoints() -> ConfigDict:
|
|
39
|
+
"""
|
|
40
|
+
Get additional endpoints for the Comments model.
|
|
41
|
+
|
|
42
|
+
:return: A dictionary of additional endpoints
|
|
43
|
+
:rtype: ConfigDict
|
|
44
|
+
"""
|
|
45
|
+
return ConfigDict( # type: ignore
|
|
46
|
+
get_all_by_part="/api/comments/getAllByPart/{intParentID}/{strModule}/{strType}/{strPart}",
|
|
47
|
+
batch_create="/api/{model_slug}/batchCreate",
|
|
48
|
+
batch_update="/api/{model_slug}/batchUpdate",
|
|
49
|
+
)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""This module contains the Compliance Settings model class."""
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
|
|
5
|
+
from pydantic import ConfigDict
|
|
6
|
+
|
|
7
|
+
from regscale.models.regscale_models.regscale_model import RegScaleModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ComplianceSettings(RegScaleModel):
|
|
11
|
+
"""
|
|
12
|
+
Compliance Settings model class
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
_module_slug = "settings"
|
|
16
|
+
_module_slug_id_url = "/api/compliance/{model_slug}/{id}"
|
|
17
|
+
_unique_fields = [
|
|
18
|
+
["title"],
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
id: int
|
|
22
|
+
title: str
|
|
23
|
+
hasParts: bool = True
|
|
24
|
+
wayfinderOptionId: Optional[int] = None
|
|
25
|
+
profileIds: Optional[List] = None
|
|
26
|
+
complianceSettingsFieldGroups: Optional[List] = None
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def get_by_current_tenant(cls) -> List["ComplianceSettings"]:
|
|
30
|
+
"""
|
|
31
|
+
Get a list of compliance settings by current tenant.
|
|
32
|
+
|
|
33
|
+
:return: A list of compliance settings
|
|
34
|
+
:rtype: List[ComplianceSettings]
|
|
35
|
+
"""
|
|
36
|
+
response = cls._get_api_handler().get(
|
|
37
|
+
endpoint=cls.get_endpoint("get_by_current_tenant").format(model_slug=cls._module_slug)
|
|
38
|
+
)
|
|
39
|
+
compliance_settings = []
|
|
40
|
+
if response and response.ok:
|
|
41
|
+
for setting in response.json():
|
|
42
|
+
compliance_settings.append(ComplianceSettings(**setting))
|
|
43
|
+
return compliance_settings
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def _get_additional_endpoints() -> ConfigDict:
|
|
47
|
+
"""
|
|
48
|
+
Get additional endpoints for the ComplianceSettings model.
|
|
49
|
+
|
|
50
|
+
:return: A dictionary of additional endpoints
|
|
51
|
+
:rtype: ConfigDict
|
|
52
|
+
"""
|
|
53
|
+
return ConfigDict( # type: ignore
|
|
54
|
+
get_by_current_tenant="/api/compliance/{model_slug}", # type: ignore
|
|
55
|
+
get_by_compliance_id="/api/compliance/{model_slug}/{id}/", # type: ignore
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def _get_endpoints(cls) -> ConfigDict:
|
|
60
|
+
"""
|
|
61
|
+
Get the endpoints for the API.
|
|
62
|
+
|
|
63
|
+
:return: A dictionary of endpoints
|
|
64
|
+
:rtype: ConfigDict
|
|
65
|
+
"""
|
|
66
|
+
endpoints = ConfigDict( # type: ignore
|
|
67
|
+
get=cls._module_slug_id_url, # type: ignore
|
|
68
|
+
insert="/api/compliance/{model_slug}/", # type: ignore
|
|
69
|
+
update=cls._module_slug_id_url, # type: ignore
|
|
70
|
+
delete=cls._module_slug_id_url, # type: ignore
|
|
71
|
+
)
|
|
72
|
+
endpoints.update(cls._get_additional_endpoints())
|
|
73
|
+
return endpoints
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def get_labels(cls, setting_id: int, setting_field: str) -> List[str]:
|
|
77
|
+
"""
|
|
78
|
+
Get the labels for the ComplianceSettings model.
|
|
79
|
+
|
|
80
|
+
:param int setting_id: The ID of the compliance setting
|
|
81
|
+
:param str setting_field: The field of the compliance setting
|
|
82
|
+
:return: A list of labels
|
|
83
|
+
:rtype: List[str]
|
|
84
|
+
"""
|
|
85
|
+
compliance_setting = None
|
|
86
|
+
response = cls._get_api_handler().get(
|
|
87
|
+
endpoint=cls.get_endpoint("get_by_compliance_id").format(model_slug=cls._module_slug, id=setting_id)
|
|
88
|
+
)
|
|
89
|
+
labels = []
|
|
90
|
+
if response and response.ok:
|
|
91
|
+
compliance_setting = cls(**response.json())
|
|
92
|
+
else:
|
|
93
|
+
return labels
|
|
94
|
+
if not compliance_setting:
|
|
95
|
+
return labels
|
|
96
|
+
if compliance_setting.complianceSettingsFieldGroups:
|
|
97
|
+
for group in compliance_setting.complianceSettingsFieldGroups:
|
|
98
|
+
if group["formFieldId"] == setting_field:
|
|
99
|
+
for item in group["complianceSettingsList"]:
|
|
100
|
+
labels.append(item["statusName"])
|
|
101
|
+
|
|
102
|
+
return labels
|
|
103
|
+
|
|
104
|
+
def get_field_labels(self, setting_field: str) -> List[str]:
|
|
105
|
+
"""
|
|
106
|
+
Get the labels for the specified field from this compliance setting.
|
|
107
|
+
|
|
108
|
+
:param str setting_field: The field of the compliance setting
|
|
109
|
+
:return: A list of labels
|
|
110
|
+
:rtype: List[str]
|
|
111
|
+
"""
|
|
112
|
+
return self.__class__.get_labels(self.id, setting_field)
|