gitlabcis 1.3.2__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.
- gitlabcis/__init__.py +12 -0
- gitlabcis/__main__.py +7 -0
- gitlabcis/benchmarks/__init__.py +8 -0
- gitlabcis/benchmarks/artifacts_4/__init__.py +4 -0
- gitlabcis/benchmarks/artifacts_4/access_to_artifacts_4_2.py +139 -0
- gitlabcis/benchmarks/artifacts_4/origin_traceability_4_4.py +11 -0
- gitlabcis/benchmarks/artifacts_4/package_registries_4_3.py +105 -0
- gitlabcis/benchmarks/artifacts_4/verification_4_1.py +83 -0
- gitlabcis/benchmarks/build_pipelines_2/__init__.py +4 -0
- gitlabcis/benchmarks/build_pipelines_2/build_environment_2_1.py +268 -0
- gitlabcis/benchmarks/build_pipelines_2/build_worker_2_2.py +129 -0
- gitlabcis/benchmarks/build_pipelines_2/pipeline_instructions_2_3.py +444 -0
- gitlabcis/benchmarks/build_pipelines_2/pipeline_integrity_2_4.py +146 -0
- gitlabcis/benchmarks/dependencies_3/__init__.py +2 -0
- gitlabcis/benchmarks/dependencies_3/third_party_packages_3_1.py +171 -0
- gitlabcis/benchmarks/dependencies_3/validate_packages_3_2.py +182 -0
- gitlabcis/benchmarks/deployment_5/__init__.py +2 -0
- gitlabcis/benchmarks/deployment_5/deployment_configuration_5_1.py +165 -0
- gitlabcis/benchmarks/deployment_5/deployment_environment_5_2.py +66 -0
- gitlabcis/benchmarks/source_code_1/__init__.py +6 -0
- gitlabcis/benchmarks/source_code_1/code_changes_1_1.py +665 -0
- gitlabcis/benchmarks/source_code_1/code_risks_1_5.py +506 -0
- gitlabcis/benchmarks/source_code_1/contribution_access_1_3.py +334 -0
- gitlabcis/benchmarks/source_code_1/repository_management_1_2.py +168 -0
- gitlabcis/benchmarks/source_code_1/third_party_1_4.py +139 -0
- gitlabcis/cli/__init__.py +0 -0
- gitlabcis/cli/log.py +30 -0
- gitlabcis/cli/main.py +541 -0
- gitlabcis/cli/output.py +151 -0
- gitlabcis/recommendations/artifacts_4/access_to_artifacts_4_2/external_auth_server.yml +51 -0
- gitlabcis/recommendations/artifacts_4/access_to_artifacts_4_2/limit_artifact_uploaders.yml +57 -0
- gitlabcis/recommendations/artifacts_4/access_to_artifacts_4_2/limit_certifying_artifacts.yml +53 -0
- gitlabcis/recommendations/artifacts_4/access_to_artifacts_4_2/minimum_package_registry_admins.yml +54 -0
- gitlabcis/recommendations/artifacts_4/access_to_artifacts_4_2/readme.md +14 -0
- gitlabcis/recommendations/artifacts_4/access_to_artifacts_4_2/require_mfa_to_package_registry.yml +52 -0
- gitlabcis/recommendations/artifacts_4/access_to_artifacts_4_2/restrict_anonymous_access.yml +67 -0
- gitlabcis/recommendations/artifacts_4/origin_traceability_4_4/artifact_origin_info.yml +56 -0
- gitlabcis/recommendations/artifacts_4/origin_traceability_4_4/readme.md +7 -0
- gitlabcis/recommendations/artifacts_4/package_registries_4_3/all_artifact_versions_signed.yml +70 -0
- gitlabcis/recommendations/artifacts_4/package_registries_4_3/audit_package_registry_config.yml +46 -0
- gitlabcis/recommendations/artifacts_4/package_registries_4_3/readme.md +12 -0
- gitlabcis/recommendations/artifacts_4/package_registries_4_3/secure_repo_webhooks.yml +50 -0
- gitlabcis/recommendations/artifacts_4/package_registries_4_3/validate_signed_artifacts_on_upload.yml +72 -0
- gitlabcis/recommendations/artifacts_4/readme.md +12 -0
- gitlabcis/recommendations/artifacts_4/verification_4_1/encrypt_artifacts_before_distribution.yml +47 -0
- gitlabcis/recommendations/artifacts_4/verification_4_1/only_authorized_platforms_can_decrypt_artifacts.yml +59 -0
- gitlabcis/recommendations/artifacts_4/verification_4_1/readme.md +11 -0
- gitlabcis/recommendations/artifacts_4/verification_4_1/sign_artifacts_in_build_pipeline.yml +40 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/authenticate_build_access.yml +55 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/build_automation.yml +54 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/build_env_admins.yml +55 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/build_logging.yml +49 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/disable_build_tools_default_passwords.yml +54 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/immutable_pipeline_infrastructure.yml +60 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/limit_build_access.yml +64 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/limit_build_secrets_scope.yml +56 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/readme.md +19 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/secure_build_env_webhooks.yml +43 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/single_responsibility_pipeline.yml +58 -0
- gitlabcis/recommendations/build_pipelines_2/build_environment_2_1/vuln_scanning.yml +64 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/build_worker_vuln_scanning.yml +58 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/monitor_worker_resource_consumption.yml +59 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/pass_worker_envs_and_commands.yml +48 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/readme.md +16 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/restrict_worker_connectivity.yml +61 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/segregate_worker_duties.yml +78 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/single_use_workers.yml +47 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/store_worker_config.yml +62 -0
- gitlabcis/recommendations/build_pipelines_2/build_worker_2_2/worker_runtime_security.yml +37 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/build_stage_io.yml +49 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/build_steps_as_code.yml +42 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/limit_pipeline_triggers.yml +76 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/pipeline_misconfiguration_scanning.yml +48 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/pipeline_secret_scanning.yml +56 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/pipeline_vuln_scanning.yml +44 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/readme.md +16 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/secure_pipeline_output.yml +52 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_instructions_2_3/track_pipeline_files.yml +48 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_integrity_2_4/create_reproducible_artifacts.yml +52 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_integrity_2_4/lock_dependencies.yml +59 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_integrity_2_4/pipeline_produces_sbom.yml +81 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_integrity_2_4/pipeline_signs_sbom.yml +38 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_integrity_2_4/readme.md +14 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_integrity_2_4/sign_artifacts.yml +35 -0
- gitlabcis/recommendations/build_pipelines_2/pipeline_integrity_2_4/validate_dependencies.yml +63 -0
- gitlabcis/recommendations/build_pipelines_2/readme.md +12 -0
- gitlabcis/recommendations/dependencies_3/readme.md +10 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/define_package_managers.yml +84 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/dependency_sbom.yml +84 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/monitor_dependencies.yml +61 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/packages_over_60_days_old.yml +95 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/pin_dependency_version.yml +48 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/readme.md +14 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/third_party_sbom_required.yml +70 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/verify_artifacts.yml +45 -0
- gitlabcis/recommendations/dependencies_3/third_party_packages_3_1/verify_signed_metadata.yml +41 -0
- gitlabcis/recommendations/dependencies_3/validate_packages_3_2/org_wide_dependency_policy.yml +47 -0
- gitlabcis/recommendations/dependencies_3/validate_packages_3_2/package_license_scanning.yml +47 -0
- gitlabcis/recommendations/dependencies_3/validate_packages_3_2/package_ownership_change.yml +42 -0
- gitlabcis/recommendations/dependencies_3/validate_packages_3_2/package_vuln_scanning.yml +62 -0
- gitlabcis/recommendations/dependencies_3/validate_packages_3_2/readme.md +10 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/audit_deployment_config.yml +46 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/limit_deployment_config_access.yml +51 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/pin_deployment_config_manifests.yml +59 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/readme.md +13 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/scan_iac.yml +72 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/secret_scan_deployment_config.yml +45 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/separate_deployment_config.yml +50 -0
- gitlabcis/recommendations/deployment_5/deployment_configuration_5_1/verify_deployment_config.yml +49 -0
- gitlabcis/recommendations/deployment_5/deployment_environment_5_2/automate_deployment.yml +47 -0
- gitlabcis/recommendations/deployment_5/deployment_environment_5_2/disable_default_passwords.yml +63 -0
- gitlabcis/recommendations/deployment_5/deployment_environment_5_2/limit_prod_access.yml +45 -0
- gitlabcis/recommendations/deployment_5/deployment_environment_5_2/readme.md +12 -0
- gitlabcis/recommendations/deployment_5/deployment_environment_5_2/reproducible_deployment.yml +50 -0
- gitlabcis/recommendations/deployment_5/readme.md +10 -0
- gitlabcis/recommendations/readme.md +24 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/audit_branch_protections.yml +56 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/auto_risk_scan_merges.yml +62 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/branch_protections_for_admins.yml +60 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/branches_updated_before_merging.yml +56 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/checks_pass_before_merging.yml +57 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/code_approval_dismissals.yml +62 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/code_approvals.yml +65 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/code_changes_require_code_owners.yml +68 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/code_dismissal_restrictions.yml +69 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/code_owners.yml +61 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/code_tracing.yml +52 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/comments_resolved_before_merging.yml +59 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/commits_must_be_signed_before_merging.yml +63 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/default_branch_protected.yml +85 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/deny_branch_deletions.yml +76 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/ensure_force_push_is_denied.yml +59 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/linear_history_required.yml +56 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/merging_restrictions.yml +65 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/readme.md +26 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/stale_branch_reviews.yml +72 -0
- gitlabcis/recommendations/source_code_1/code_changes_1_1/version_control.yml +45 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/dast_api_scanning.yml +50 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/dast_web_scanning.yml +51 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/dependency_scanning.yml +84 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/enable_secret_detection.yml +45 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/license_scanning.yml +47 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/readme.md +14 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/secure_iac_instructions.yml +81 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/secure_pipeline_instructions.yml +62 -0
- gitlabcis/recommendations/source_code_1/code_risks_1_5/vulnerability_scanning.yml +48 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/domain_verification.yml +65 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/ensure_2_admins_per_repo.yml +56 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/limit_top_level_group_creation.yml +61 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/limit_user_registration_domain.yml +58 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/minimum_number_of_admins.yml +56 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/org_provided_ssh_certs.yml +70 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/readme.md +21 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/require_mfa_at_org_level.yml +89 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/require_mfa_for_contributors.yml +76 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/restrict_ip_addresses.yml +84 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/review_and_remove_inactive_users.yml +62 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/scm_notification_restriction.yml +46 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/strict_permissions_for_repo.yml +62 -0
- gitlabcis/recommendations/source_code_1/contribution_access_1_3/track_code_anomalies.yml +43 -0
- gitlabcis/recommendations/source_code_1/readme.md +13 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/limit_issue_deletions.yml +57 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/limit_repo_creations.yml +64 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/limit_repo_deletions.yml +57 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/public_repos_have_security_file.yml +59 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/readme.md +15 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/review_and_archive_stale_repos.yml +65 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/track_forks.yml +74 -0
- gitlabcis/recommendations/source_code_1/repository_management_1_2/track_project_visibility_status.yml +74 -0
- gitlabcis/recommendations/source_code_1/third_party_1_4/README.md +12 -0
- gitlabcis/recommendations/source_code_1/third_party_1_4/admin_approval_for_app_installs.yml +83 -0
- gitlabcis/recommendations/source_code_1/third_party_1_4/least_privilge_app_permissions.yml +103 -0
- gitlabcis/recommendations/source_code_1/third_party_1_4/secure_webhooks.yml +73 -0
- gitlabcis/recommendations/source_code_1/third_party_1_4/stale_app_reviews.yml +66 -0
- gitlabcis/recommendations/template.yml +30 -0
- gitlabcis/tests/__init__.py +0 -0
- gitlabcis/tests/input/__init__.py +0 -0
- gitlabcis/tests/input/conftest.py +29 -0
- gitlabcis/tests/input/no_input_test.py +82 -0
- gitlabcis/tests/input/switch_test.py +19 -0
- gitlabcis/tests/input/version_test.py +7 -0
- gitlabcis/tests/unit/__init__.py +0 -0
- gitlabcis/tests/unit/benchmarks/artifacts_4/access_to_artifacts_4_2_test.py +131 -0
- gitlabcis/tests/unit/benchmarks/artifacts_4/origin_traceability_4_4_test.py +15 -0
- gitlabcis/tests/unit/benchmarks/artifacts_4/package_registries_4_3_test.py +102 -0
- gitlabcis/tests/unit/benchmarks/artifacts_4/verification_4_1_test.py +78 -0
- gitlabcis/tests/unit/benchmarks/build_pipelines_2/build_environment_2_1_test.py +239 -0
- gitlabcis/tests/unit/benchmarks/build_pipelines_2/build_worker_2_2_test.py +105 -0
- gitlabcis/tests/unit/benchmarks/build_pipelines_2/pipeline_instructions_2_3_test.py +340 -0
- gitlabcis/tests/unit/benchmarks/build_pipelines_2/pipeline_integrity_2_4_test.py +115 -0
- gitlabcis/tests/unit/benchmarks/conftest.py +47 -0
- gitlabcis/tests/unit/benchmarks/dependencies_3/third_party_packages_3_1_test.py +135 -0
- gitlabcis/tests/unit/benchmarks/dependencies_3/validate_packages_3_2_test.py +171 -0
- gitlabcis/tests/unit/benchmarks/deployment_5/deployment_configuration_5_1_test.py +140 -0
- gitlabcis/tests/unit/benchmarks/deployment_5/deployment_environment_5_2_test.py +60 -0
- gitlabcis/tests/unit/benchmarks/function_test.py +24 -0
- gitlabcis/tests/unit/benchmarks/source_code_1/code_changes_1_1_test.py +565 -0
- gitlabcis/tests/unit/benchmarks/source_code_1/code_risks_1_5_test.py +419 -0
- gitlabcis/tests/unit/benchmarks/source_code_1/contribution_access_1_3_test.py +265 -0
- gitlabcis/tests/unit/benchmarks/source_code_1/repository_management_1_2_test.py +142 -0
- gitlabcis/tests/unit/benchmarks/source_code_1/third_party_1_4_test.py +119 -0
- gitlabcis/tests/unit/conftest.py +94 -0
- gitlabcis/tests/unit/log/log_test.py +23 -0
- gitlabcis/tests/unit/utils/argfilters_test.py +9 -0
- gitlabcis/tests/unit/utils/ci_test.py +156 -0
- gitlabcis/tests/unit/utils/output_test.py +95 -0
- gitlabcis/tests/unit/utils/utils_general_test.py +149 -0
- gitlabcis/tests/unit/utils/version_test.py +11 -0
- gitlabcis/tests/unit/yaml/bad_file_test.py +15 -0
- gitlabcis/tests/unit/yaml/recommendation_test.py +123 -0
- gitlabcis/utils/__init__.py +146 -0
- gitlabcis/utils/ci.py +132 -0
- gitlabcis-1.3.2.dist-info/LICENSE +21 -0
- gitlabcis-1.3.2.dist-info/METADATA +241 -0
- gitlabcis-1.3.2.dist-info/RECORD +218 -0
- gitlabcis-1.3.2.dist-info/WHEEL +5 -0
- gitlabcis-1.3.2.dist-info/entry_points.txt +2 -0
- gitlabcis-1.3.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def single_use_workers(glEntity, glObject, **kwargs):
|
|
5
|
+
"""
|
|
6
|
+
id: 2.2.1
|
|
7
|
+
title: Ensure build workers are single-used
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
11
|
+
return {None: 'This check requires validation'}
|
|
12
|
+
|
|
13
|
+
# -------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def pass_worker_envs_and_commands(glEntity, glObject, **kwargs):
|
|
17
|
+
"""
|
|
18
|
+
id: 2.2.2
|
|
19
|
+
title: Ensure build worker environments and commands are
|
|
20
|
+
passed and not pulled
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
24
|
+
return {None: 'This check requires validation'}
|
|
25
|
+
|
|
26
|
+
# -------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def segregate_worker_duties(glEntity, glObject, **kwargs):
|
|
30
|
+
"""
|
|
31
|
+
id: 2.2.3
|
|
32
|
+
title: Ensure the duties of each build worker are segregated
|
|
33
|
+
"""
|
|
34
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
35
|
+
GitlabHttpError, GitlabListError)
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
project_runners = glEntity.runners.list(get_all=True)
|
|
39
|
+
assigned_runners = [
|
|
40
|
+
runner for runner in project_runners
|
|
41
|
+
if not runner.is_shared
|
|
42
|
+
]
|
|
43
|
+
if not assigned_runners:
|
|
44
|
+
return {False: 'No project_assigned_runners available'}
|
|
45
|
+
else:
|
|
46
|
+
return {True: 'project_assigned_runners available'}
|
|
47
|
+
|
|
48
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
49
|
+
GitlabListError) as e:
|
|
50
|
+
if e.response_code in [401, 403]:
|
|
51
|
+
return {None: 'Insufficient permissions'}
|
|
52
|
+
|
|
53
|
+
# -------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def restrict_worker_connectivity(glEntity, glObject, **kwargs):
|
|
57
|
+
"""
|
|
58
|
+
id: 2.2.4
|
|
59
|
+
title: Ensure build workers have minimal network connectivity
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
63
|
+
return {None: 'This check requires validation'}
|
|
64
|
+
|
|
65
|
+
# -------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def worker_runtime_security(glEntity, glObject, **kwargs):
|
|
69
|
+
"""
|
|
70
|
+
id: 2.2.5
|
|
71
|
+
title: Ensure run-time security is enforced for build workers
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
75
|
+
return {None: 'This check requires validation'}
|
|
76
|
+
|
|
77
|
+
# -------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def build_worker_vuln_scanning(glEntity, glObject, **kwargs):
|
|
81
|
+
"""
|
|
82
|
+
id: 2.2.6
|
|
83
|
+
title: Ensure build workers are automatically scanned for
|
|
84
|
+
vulnerabilities
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
88
|
+
return {None: 'This check requires validation'}
|
|
89
|
+
|
|
90
|
+
# -------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def store_worker_config(glEntity, glObject, **kwargs):
|
|
94
|
+
"""
|
|
95
|
+
id: 2.2.7
|
|
96
|
+
title: Ensure build workers' deployment configuration is stored in
|
|
97
|
+
a version control platform
|
|
98
|
+
"""
|
|
99
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
100
|
+
GitlabHttpError)
|
|
101
|
+
|
|
102
|
+
from gitlabcis.utils import ci
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
gitlab_ci_yml = ci.getConfig(glEntity, glObject, **kwargs)
|
|
106
|
+
|
|
107
|
+
ciFile, reason = gitlab_ci_yml.popitem()
|
|
108
|
+
|
|
109
|
+
if ciFile in [None, False]:
|
|
110
|
+
return {ciFile: reason}
|
|
111
|
+
else:
|
|
112
|
+
return {True: 'Build workers deployment configuration '
|
|
113
|
+
'is stored in a version control platform'}
|
|
114
|
+
|
|
115
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
116
|
+
if e.response_code in [401, 403]:
|
|
117
|
+
return {None: 'Insufficient permissions'}
|
|
118
|
+
|
|
119
|
+
# -------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def monitor_worker_resource_consumption(glEntity, glObject, **kwargs):
|
|
123
|
+
"""
|
|
124
|
+
id: 2.2.8
|
|
125
|
+
title: Ensure resource consumption of build workers is monitored
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
129
|
+
return {None: 'This check requires validation'}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def build_steps_as_code(glEntity, glObject, **kwargs):
|
|
5
|
+
"""
|
|
6
|
+
id: 2.3.1
|
|
7
|
+
title: Ensure all build steps are defined as code
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
11
|
+
GitlabHttpError)
|
|
12
|
+
|
|
13
|
+
from gitlabcis.utils import ci
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
gitlab_ci_yml = ci.getConfig(glEntity, glObject, **kwargs)
|
|
17
|
+
|
|
18
|
+
ciFile, reason = gitlab_ci_yml.popitem()
|
|
19
|
+
|
|
20
|
+
if ciFile in [None, False]:
|
|
21
|
+
return {ciFile: reason}
|
|
22
|
+
else:
|
|
23
|
+
return {True: 'Build steps are defined as code'}
|
|
24
|
+
|
|
25
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
26
|
+
if e.response_code in [401, 403]:
|
|
27
|
+
return {None: 'Insufficient permissions'}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# -------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def build_stage_io(glEntity, glObject, **kwargs):
|
|
34
|
+
"""
|
|
35
|
+
id: 2.3.2
|
|
36
|
+
title: Ensure steps have clearly defined build stage input and
|
|
37
|
+
output
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
import base64
|
|
41
|
+
|
|
42
|
+
import yaml
|
|
43
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
44
|
+
GitlabHttpError)
|
|
45
|
+
|
|
46
|
+
from gitlabcis.utils import ci
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
gitlab_ci_yml = ci.getConfig(glEntity, glObject, **kwargs)
|
|
50
|
+
|
|
51
|
+
ciFile, reason = gitlab_ci_yml.popitem()
|
|
52
|
+
|
|
53
|
+
if ciFile in [None, False]:
|
|
54
|
+
return {ciFile: reason}
|
|
55
|
+
|
|
56
|
+
gl_ci_yml_content = ciFile.content
|
|
57
|
+
gl_ci_yml_decode = base64.b64decode(gl_ci_yml_content).decode('utf-8')
|
|
58
|
+
gitlab_ci_yml_dict = yaml.safe_load(gl_ci_yml_decode)
|
|
59
|
+
if not gitlab_ci_yml_dict:
|
|
60
|
+
return {False: 'gitlab_ci_yml file is empty'}
|
|
61
|
+
else:
|
|
62
|
+
if ('stages' in gitlab_ci_yml_dict
|
|
63
|
+
and 'build' in gitlab_ci_yml_dict['stages']):
|
|
64
|
+
build_jobs = [
|
|
65
|
+
job_name for job_name, job in gitlab_ci_yml_dict.items()
|
|
66
|
+
if isinstance(job, dict) and job.get('stage') == 'build'
|
|
67
|
+
]
|
|
68
|
+
if not build_jobs:
|
|
69
|
+
return {True: 'No build stage detected'
|
|
70
|
+
' in gitlab_ci_yml'}
|
|
71
|
+
for job_name in build_jobs:
|
|
72
|
+
job = gitlab_ci_yml_dict[job_name]
|
|
73
|
+
if 'script' in job:
|
|
74
|
+
if 'artifacts' in job:
|
|
75
|
+
continue
|
|
76
|
+
else:
|
|
77
|
+
return {False: 'No output found for a '
|
|
78
|
+
'job in the build stage'}
|
|
79
|
+
else:
|
|
80
|
+
return {False: 'No script found for '
|
|
81
|
+
'a job in the build stage'}
|
|
82
|
+
else:
|
|
83
|
+
return {False: 'No build stages detected in gitlab_ci_yml'}
|
|
84
|
+
return {True: 'input and output has defined '
|
|
85
|
+
'for each build stage.'}
|
|
86
|
+
|
|
87
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
88
|
+
if e.response_code in [401, 403]:
|
|
89
|
+
return {None: 'Insufficient permissions'}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# -------------------------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def secure_pipeline_output(glEntity, glObject, **kwargs):
|
|
96
|
+
"""
|
|
97
|
+
id: 2.3.3
|
|
98
|
+
title: Ensure output is written to a separate, secured storage
|
|
99
|
+
repository
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
103
|
+
return {None: 'This check requires validation'}
|
|
104
|
+
|
|
105
|
+
# -------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def track_pipeline_files(glEntity, glObject, **kwargs):
|
|
109
|
+
"""
|
|
110
|
+
id: 2.3.4
|
|
111
|
+
title: Ensure changes to pipeline files are tracked and reviewed
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
115
|
+
GitlabHttpError)
|
|
116
|
+
|
|
117
|
+
from gitlabcis.utils import ci
|
|
118
|
+
|
|
119
|
+
try:
|
|
120
|
+
gitlab_ci_yml = ci.getConfig(glEntity, glObject, **kwargs)
|
|
121
|
+
|
|
122
|
+
ciFile, reason = gitlab_ci_yml.popitem()
|
|
123
|
+
|
|
124
|
+
if ciFile in [None, False]:
|
|
125
|
+
return {ciFile: reason}
|
|
126
|
+
else:
|
|
127
|
+
return {True: 'changes to pipeline files are '
|
|
128
|
+
'being tracked and reviewed'}
|
|
129
|
+
|
|
130
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
131
|
+
if e.response_code in [401, 403]:
|
|
132
|
+
return {None: 'Insufficient permissions'}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# -------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def limit_pipeline_triggers(glEntity, glObject, **kwargs):
|
|
139
|
+
"""
|
|
140
|
+
id: 2.3.5
|
|
141
|
+
title: Ensure access to build process triggering is minimized
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
145
|
+
GitlabHttpError, GitlabListError)
|
|
146
|
+
|
|
147
|
+
try:
|
|
148
|
+
protected_environments = glEntity.protected_environments.list()
|
|
149
|
+
if not protected_environments:
|
|
150
|
+
return {False: 'No protected environment detected'}
|
|
151
|
+
return {None: 'This check requires validation'}
|
|
152
|
+
|
|
153
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
154
|
+
GitlabListError) as e:
|
|
155
|
+
if e.response_code in [401, 403]:
|
|
156
|
+
return {None: 'Insufficient permissions'}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# -------------------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def pipeline_misconfiguration_scanning(glEntity, glObject, **kwargs):
|
|
163
|
+
"""
|
|
164
|
+
id: 2.3.6
|
|
165
|
+
title: Ensure pipelines are automatically scanned for
|
|
166
|
+
misconfigurations
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
import yaml
|
|
170
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
171
|
+
GitlabHttpError)
|
|
172
|
+
from gql import Client, gql
|
|
173
|
+
from gql.transport.exceptions import (TransportAlreadyConnected,
|
|
174
|
+
TransportServerError)
|
|
175
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
176
|
+
from graphql import GraphQLError
|
|
177
|
+
|
|
178
|
+
try:
|
|
179
|
+
|
|
180
|
+
variables = {
|
|
181
|
+
'fullPath': glEntity.path_with_namespace
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
185
|
+
if e.response_code in [401, 403]:
|
|
186
|
+
return {None: 'Insufficient permissions'}
|
|
187
|
+
|
|
188
|
+
client = Client(
|
|
189
|
+
transport=RequestsHTTPTransport(
|
|
190
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
191
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
192
|
+
use_json=True
|
|
193
|
+
),
|
|
194
|
+
fetch_schema_from_transport=True
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
query = gql('''
|
|
198
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
199
|
+
project(fullPath: $fullPath) {
|
|
200
|
+
scanExecutionPolicies {
|
|
201
|
+
nodes {
|
|
202
|
+
name
|
|
203
|
+
enabled
|
|
204
|
+
yaml
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
''')
|
|
210
|
+
|
|
211
|
+
try:
|
|
212
|
+
|
|
213
|
+
results = client.execute(query, variable_values=variables)
|
|
214
|
+
|
|
215
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
216
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
217
|
+
|
|
218
|
+
# when pytest runs without auth:
|
|
219
|
+
except AttributeError:
|
|
220
|
+
return {None: 'Insufficient permissions'}
|
|
221
|
+
|
|
222
|
+
try:
|
|
223
|
+
required_scans = [
|
|
224
|
+
'dast', 'secret_detection', 'cluster_image_scanning',
|
|
225
|
+
'container_scanning', 'sast', 'sast_iac', 'dependency_scanning'
|
|
226
|
+
]
|
|
227
|
+
|
|
228
|
+
scans_found = set()
|
|
229
|
+
dast_policy_found = False
|
|
230
|
+
sast_policy_found = False
|
|
231
|
+
for policy in results['project']['scanExecutionPolicies']['nodes']:
|
|
232
|
+
if policy.get('enabled') is True:
|
|
233
|
+
policy_yaml = yaml.safe_load(policy.get('yaml', ''))
|
|
234
|
+
actions = policy_yaml.get('actions', [])
|
|
235
|
+
rules = policy_yaml.get('rules', [])
|
|
236
|
+
for action in actions:
|
|
237
|
+
scans_found.add(action.get('scan'))
|
|
238
|
+
if action.get('scan') == 'sast':
|
|
239
|
+
for rule in rules:
|
|
240
|
+
if (
|
|
241
|
+
rule.get('type') == 'pipeline'
|
|
242
|
+
and '*' in rule.get('branches', [])
|
|
243
|
+
):
|
|
244
|
+
sast_policy_found = True
|
|
245
|
+
elif action.get('scan') == 'dast':
|
|
246
|
+
for rule in rules:
|
|
247
|
+
if (
|
|
248
|
+
rule.get('type') == 'pipeline'
|
|
249
|
+
and '*' in rule.get('branches', [])
|
|
250
|
+
):
|
|
251
|
+
dast_policy_found = True
|
|
252
|
+
missing_scans = [
|
|
253
|
+
scan for scan in required_scans
|
|
254
|
+
if scan not in scans_found
|
|
255
|
+
]
|
|
256
|
+
if (dast_policy_found and sast_policy_found):
|
|
257
|
+
if missing_scans:
|
|
258
|
+
return {
|
|
259
|
+
True: (
|
|
260
|
+
'Scan Execution Policy for sast and dast is '
|
|
261
|
+
'enabled and triggers for all pipelines and '
|
|
262
|
+
'branches. Other missing scans for manual review:'
|
|
263
|
+
f'{", ".join(missing_scans)}'
|
|
264
|
+
)
|
|
265
|
+
}
|
|
266
|
+
else:
|
|
267
|
+
return {
|
|
268
|
+
True: (
|
|
269
|
+
'Scan Execution Policy for sast and dast is '
|
|
270
|
+
'enabled and triggers for all pipelines and '
|
|
271
|
+
'branches. All required scans are covered.'
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
else:
|
|
275
|
+
return {
|
|
276
|
+
False: (
|
|
277
|
+
'Required Scan Execution Policy '
|
|
278
|
+
'is not enabled to trigger for all pipelines '
|
|
279
|
+
'and branches. Missing scans to '
|
|
280
|
+
f'review: {", ".join(missing_scans)}'
|
|
281
|
+
)
|
|
282
|
+
}
|
|
283
|
+
except KeyError:
|
|
284
|
+
return {False: 'Scan Execution Policy was not found'}
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
# -------------------------------------------------------------------------
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def pipeline_vuln_scanning(glEntity, glObject, **kwargs):
|
|
291
|
+
"""
|
|
292
|
+
id: 2.3.7
|
|
293
|
+
title: Ensure pipelines are automatically scanned for
|
|
294
|
+
vulnerabilities
|
|
295
|
+
"""
|
|
296
|
+
|
|
297
|
+
import yaml
|
|
298
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
299
|
+
GitlabHttpError)
|
|
300
|
+
from gql import Client, gql
|
|
301
|
+
from gql.transport.exceptions import (TransportAlreadyConnected,
|
|
302
|
+
TransportServerError)
|
|
303
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
304
|
+
from graphql import GraphQLError
|
|
305
|
+
|
|
306
|
+
try:
|
|
307
|
+
|
|
308
|
+
variables = {
|
|
309
|
+
'fullPath': glEntity.path_with_namespace
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
313
|
+
if e.response_code in [401, 403]:
|
|
314
|
+
return {None: 'Insufficient permissions'}
|
|
315
|
+
|
|
316
|
+
client = Client(
|
|
317
|
+
transport=RequestsHTTPTransport(
|
|
318
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
319
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
320
|
+
use_json=True
|
|
321
|
+
),
|
|
322
|
+
fetch_schema_from_transport=True
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
query = gql('''
|
|
326
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
327
|
+
project(fullPath: $fullPath) {
|
|
328
|
+
scanExecutionPolicies {
|
|
329
|
+
nodes {
|
|
330
|
+
name
|
|
331
|
+
enabled
|
|
332
|
+
yaml
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
''')
|
|
338
|
+
|
|
339
|
+
try:
|
|
340
|
+
|
|
341
|
+
results = client.execute(query, variable_values=variables)
|
|
342
|
+
|
|
343
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
344
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
345
|
+
|
|
346
|
+
# pytest no auth:
|
|
347
|
+
except AttributeError:
|
|
348
|
+
return {None: 'Insufficient permissions'}
|
|
349
|
+
|
|
350
|
+
try:
|
|
351
|
+
required_scans = [
|
|
352
|
+
'dast', 'secret_detection', 'cluster_image_scanning',
|
|
353
|
+
'container_scanning', 'sast', 'sast_iac', 'dependency_scanning'
|
|
354
|
+
]
|
|
355
|
+
|
|
356
|
+
scans_found = set()
|
|
357
|
+
dast_policy_found = False
|
|
358
|
+
sast_policy_found = False
|
|
359
|
+
for policy in results['project']['scanExecutionPolicies']['nodes']:
|
|
360
|
+
if policy.get('enabled') is True:
|
|
361
|
+
policy_yaml = yaml.safe_load(policy.get('yaml', ''))
|
|
362
|
+
actions = policy_yaml.get('actions', [])
|
|
363
|
+
rules = policy_yaml.get('rules', [])
|
|
364
|
+
for action in actions:
|
|
365
|
+
scans_found.add(action.get('scan'))
|
|
366
|
+
if action.get('scan') == 'sast':
|
|
367
|
+
for rule in rules:
|
|
368
|
+
if (
|
|
369
|
+
rule.get('type') == 'pipeline'
|
|
370
|
+
and '*' in rule.get('branches', [])
|
|
371
|
+
):
|
|
372
|
+
sast_policy_found = True
|
|
373
|
+
elif action.get('scan') == 'dast':
|
|
374
|
+
for rule in rules:
|
|
375
|
+
if (
|
|
376
|
+
rule.get('type') == 'pipeline'
|
|
377
|
+
and '*' in rule.get('branches', [])
|
|
378
|
+
):
|
|
379
|
+
dast_policy_found = True
|
|
380
|
+
missing_scans = [
|
|
381
|
+
scan for scan in required_scans
|
|
382
|
+
if scan not in scans_found
|
|
383
|
+
]
|
|
384
|
+
if (dast_policy_found and sast_policy_found):
|
|
385
|
+
if missing_scans:
|
|
386
|
+
return {
|
|
387
|
+
True: (
|
|
388
|
+
'Scan Execution Policy for sast and dast is '
|
|
389
|
+
'enabled and triggers for all pipelines and '
|
|
390
|
+
'branches. Other missing scans for manual review:'
|
|
391
|
+
f'{", ".join(missing_scans)}'
|
|
392
|
+
)
|
|
393
|
+
}
|
|
394
|
+
else:
|
|
395
|
+
return {
|
|
396
|
+
True: (
|
|
397
|
+
'Scan Execution Policy for sast and dast is '
|
|
398
|
+
'enabled and triggers for all pipelines and '
|
|
399
|
+
'branches. All required scans are covered.'
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
else:
|
|
403
|
+
return {
|
|
404
|
+
False: (
|
|
405
|
+
'Required Scan Execution Policy '
|
|
406
|
+
'is not enabled to trigger for all pipelines '
|
|
407
|
+
'and branches. Missing scans to '
|
|
408
|
+
f'review: {", ".join(missing_scans)}'
|
|
409
|
+
)
|
|
410
|
+
}
|
|
411
|
+
except KeyError:
|
|
412
|
+
return {False: 'Scan Execution Policy was not found'}
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
# -------------------------------------------------------------------------
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def pipeline_secret_scanning(glEntity, glObject, **kwargs):
|
|
419
|
+
"""
|
|
420
|
+
id: 2.3.8
|
|
421
|
+
title: Ensure scanners are in place to identify and prevent
|
|
422
|
+
sensitive data in pipeline files
|
|
423
|
+
"""
|
|
424
|
+
|
|
425
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
426
|
+
GitlabHttpError)
|
|
427
|
+
|
|
428
|
+
from gitlabcis.utils import ci
|
|
429
|
+
|
|
430
|
+
try:
|
|
431
|
+
|
|
432
|
+
_result = ci.searchConfig(
|
|
433
|
+
glEntity, glObject, 'secret-detection')
|
|
434
|
+
|
|
435
|
+
result, reason = _result.popitem()
|
|
436
|
+
|
|
437
|
+
if result is True:
|
|
438
|
+
return {True: 'Secret-Detection is enabled'}
|
|
439
|
+
else:
|
|
440
|
+
return {False: 'Secret-Detection is not enabled'}
|
|
441
|
+
|
|
442
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
443
|
+
if e.response_code in [401, 403]:
|
|
444
|
+
return {None: 'Insufficient permissions'}
|