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
gitlabcis/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
from gitlabcis import benchmarks # noqa: F401
|
|
4
|
+
from gitlabcis.cli.output import output # noqa: F401
|
|
5
|
+
from gitlabcis.utils import countRecommendations # noqa: F401
|
|
6
|
+
from gitlabcis.utils import mapRecommendations # noqa: F401
|
|
7
|
+
from gitlabcis.utils import readRecommendations # noqa: F401
|
|
8
|
+
|
|
9
|
+
# -------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
__author__ = 'nmcdonald+gitlabcis@gitlab.com'
|
|
12
|
+
__version__ = '1.3.2' # noqa: E999
|
gitlabcis/__main__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
from . import source_code_1 # noqa: F401
|
|
4
|
+
from . import build_pipelines_2 # noqa: F401
|
|
5
|
+
from . import dependencies_3 # noqa: F401
|
|
6
|
+
from . import artifacts_4 # noqa: F401
|
|
7
|
+
from . import deployment_5 # noqa: F401
|
|
8
|
+
# -------------------------------------------------------------------------
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def limit_certifying_artifacts(glEntity, glObject, **kwargs):
|
|
5
|
+
"""
|
|
6
|
+
id: 4.2.1
|
|
7
|
+
title: Ensure the authority to certify artifacts is limited
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
11
|
+
return {None: 'This check requires validation'}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# -------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def limit_artifact_uploaders(glEntity, glObject, **kwargs):
|
|
18
|
+
"""
|
|
19
|
+
id: 4.2.2
|
|
20
|
+
title: Ensure number of permitted users who may upload new
|
|
21
|
+
artifacts is minimized
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
25
|
+
GitlabHttpError)
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
members = glEntity.members.list(all=True)
|
|
29
|
+
maintainer_and_above = sum(
|
|
30
|
+
1 for member in members if
|
|
31
|
+
member.access_level >= 40)
|
|
32
|
+
total_members = len(members)
|
|
33
|
+
maintainer_and_above_percentage = (
|
|
34
|
+
(maintainer_and_above / total_members) * 100
|
|
35
|
+
)
|
|
36
|
+
if maintainer_and_above_percentage < 20 or maintainer_and_above < 3:
|
|
37
|
+
return {True: 'Number of permitted users who can upload new '
|
|
38
|
+
' artifacts are limited'}
|
|
39
|
+
else:
|
|
40
|
+
return {False: 'Number of permitted users who can upload new '
|
|
41
|
+
' artifacts are not limited'}
|
|
42
|
+
|
|
43
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
44
|
+
if e.response_code in [401, 403]:
|
|
45
|
+
return {None: 'Insufficient permissions'}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# -------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def require_mfa_to_package_registry(glEntity, glObject, **kwargs):
|
|
52
|
+
"""
|
|
53
|
+
id: 4.2.3
|
|
54
|
+
title: Ensure user access to the package registry utilizes Multi-
|
|
55
|
+
Factor Authentication (MFA)
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
59
|
+
GitlabHttpError)
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
settings = glObject.settings.get()
|
|
63
|
+
if settings.require_two_factor_authentication:
|
|
64
|
+
return {True: 'Enforce two-factor authentication is enabled'}
|
|
65
|
+
else:
|
|
66
|
+
return {False: 'Enforce two-factor authentication is not enabled'}
|
|
67
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
68
|
+
if e.response_code in [401, 403]:
|
|
69
|
+
return {None: 'Insufficient permissions'}
|
|
70
|
+
|
|
71
|
+
# -------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def external_auth_server(glEntity, glObject, **kwargs):
|
|
75
|
+
"""
|
|
76
|
+
id: 4.2.4
|
|
77
|
+
title: Ensure user management of the package registry is not
|
|
78
|
+
local
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
82
|
+
return {None: 'This check requires validation'}
|
|
83
|
+
|
|
84
|
+
# -------------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def restrict_anonymous_access(glEntity, glObject, **kwargs):
|
|
88
|
+
"""
|
|
89
|
+
id: 4.2.5
|
|
90
|
+
title: Ensure anonymous access to artifacts is revoked
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
94
|
+
GitlabHttpError)
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
settings = glObject.settings.get()
|
|
98
|
+
project_visibility = settings.default_project_visibility
|
|
99
|
+
if (project_visibility == 'public'):
|
|
100
|
+
return {False: 'Project is Public'}
|
|
101
|
+
else:
|
|
102
|
+
return {True: f'Project visibility is {project_visibility}'}
|
|
103
|
+
|
|
104
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
105
|
+
if e.response_code in [401, 403]:
|
|
106
|
+
return {None: 'Insufficient permissions'}
|
|
107
|
+
|
|
108
|
+
# -------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def minimum_package_registry_admins(glEntity, glObject, **kwargs):
|
|
112
|
+
"""
|
|
113
|
+
id: 4.2.6
|
|
114
|
+
title: Ensure minimum number of administrators are set for the
|
|
115
|
+
package registry
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
119
|
+
GitlabHttpError)
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
members = glEntity.members.list(all=True)
|
|
123
|
+
reporter_and_above = sum(
|
|
124
|
+
1 for member in members if
|
|
125
|
+
member.access_level >= 20)
|
|
126
|
+
total_members = len(members)
|
|
127
|
+
reporter_and_above_percentage = (
|
|
128
|
+
(reporter_and_above / total_members) * 100
|
|
129
|
+
)
|
|
130
|
+
if reporter_and_above_percentage < 40 or reporter_and_above < 3:
|
|
131
|
+
return {True: 'Build access is limited, less than 40% '
|
|
132
|
+
'of the members have Reporter/Developer role or above'}
|
|
133
|
+
else:
|
|
134
|
+
return {False: 'Build access is not limited, over 40% '
|
|
135
|
+
'of the members have Reporter/Developer role or above'}
|
|
136
|
+
|
|
137
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
138
|
+
if e.response_code in [401, 403]:
|
|
139
|
+
return {None: 'Insufficient permissions'}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def artifact_origin_info(glEntity, glObject, **kwargs):
|
|
5
|
+
"""
|
|
6
|
+
id: 4.4.1
|
|
7
|
+
title: Ensure artifacts contain information about their origin
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
11
|
+
return {None: 'This check requires validation'}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def validate_signed_artifacts_on_upload(glEntity, glObject, **kwargs):
|
|
5
|
+
"""
|
|
6
|
+
id: 4.3.1
|
|
7
|
+
title: Ensure all signed artifacts are validated upon uploading the
|
|
8
|
+
package registry
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
12
|
+
GitlabHttpError, GitlabListError)
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
commits = glEntity.commits.list(all=True)
|
|
16
|
+
for commit in commits:
|
|
17
|
+
comit_id = commit.id
|
|
18
|
+
commit_info = glEntity.commits.get(comit_id)
|
|
19
|
+
if commit_info.status is None:
|
|
20
|
+
return {False: 'Commits are not signed'}
|
|
21
|
+
if commit_info.status != 'verified':
|
|
22
|
+
return {False: 'There are unverified commits'}
|
|
23
|
+
return {True: 'All commits are verified'}
|
|
24
|
+
|
|
25
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
26
|
+
GitlabListError) as e:
|
|
27
|
+
if e.response_code in [401, 403]:
|
|
28
|
+
return {None: 'Insufficient permissions'}
|
|
29
|
+
|
|
30
|
+
# -------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def all_artifact_versions_signed(glEntity, glObject, **kwargs):
|
|
34
|
+
"""
|
|
35
|
+
id: 4.3.2
|
|
36
|
+
title: Ensure all versions of an existing artifact have their
|
|
37
|
+
signatures validated
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
41
|
+
GitlabHttpError, GitlabListError)
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
commits = glEntity.commits.list(all=True)
|
|
45
|
+
for commit in commits:
|
|
46
|
+
comit_id = commit.id
|
|
47
|
+
commit_info = glEntity.commits.get(comit_id)
|
|
48
|
+
if commit_info.status is None:
|
|
49
|
+
return {False: 'Commits are not signed'}
|
|
50
|
+
if commit_info.status != 'verified':
|
|
51
|
+
return {False: 'There are unverified commits'}
|
|
52
|
+
return {True: 'All commits are verified'}
|
|
53
|
+
|
|
54
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
55
|
+
GitlabListError) as e:
|
|
56
|
+
if e.response_code in [401, 403]:
|
|
57
|
+
return {None: 'Insufficient permissions'}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# -------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def audit_package_registry_config(glEntity, glObject, **kwargs):
|
|
64
|
+
"""
|
|
65
|
+
id: 4.3.3
|
|
66
|
+
title: Ensure changes in package registry configuration are
|
|
67
|
+
audited
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
71
|
+
return {None: 'This check requires validation'}
|
|
72
|
+
|
|
73
|
+
# -------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def secure_repo_webhooks(glEntity, glObject, **kwargs):
|
|
77
|
+
"""
|
|
78
|
+
id: 4.3.4
|
|
79
|
+
title: Ensure webhooks of the repository are secured
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
83
|
+
GitlabHttpError, GitlabListError)
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
webhooks = glEntity.hooks.list()
|
|
87
|
+
if not webhooks:
|
|
88
|
+
return {True: 'No webhooks found'}
|
|
89
|
+
for webhook in webhooks:
|
|
90
|
+
if (webhook.url.startswith('https://') and
|
|
91
|
+
webhook.enable_ssl_verification):
|
|
92
|
+
continue
|
|
93
|
+
elif webhook.url.startswith('https://'):
|
|
94
|
+
return {False: f'{webhook.url}' + ' uses '
|
|
95
|
+
'HTTPS but SSL verification is disabled'}
|
|
96
|
+
else:
|
|
97
|
+
return {False: f'{webhook.url}' + ' is '
|
|
98
|
+
'insecure (not using HTTPS)'}
|
|
99
|
+
|
|
100
|
+
return {True: 'All webhooks are secure'}
|
|
101
|
+
|
|
102
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
103
|
+
GitlabListError) as e:
|
|
104
|
+
if e.response_code in [401, 403]:
|
|
105
|
+
return {None: 'Insufficient permissions'}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def sign_artifacts_in_build_pipeline(glEntity, glObject, **kwargs):
|
|
5
|
+
"""
|
|
6
|
+
id: 4.1.1
|
|
7
|
+
title: Ensure all artifacts are signed by the build pipeline itself
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import io
|
|
11
|
+
import os
|
|
12
|
+
import zipfile
|
|
13
|
+
|
|
14
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
15
|
+
GitlabHttpError, GitlabListError)
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
Build_stage_jobs = []
|
|
19
|
+
build_stage = False
|
|
20
|
+
pipelines = glEntity.pipelines.list(get_all=False)
|
|
21
|
+
|
|
22
|
+
if not pipelines:
|
|
23
|
+
return {False: 'No pipelines found'}
|
|
24
|
+
|
|
25
|
+
latestPipeline = pipelines[0]
|
|
26
|
+
jobs = latestPipeline.jobs.list()
|
|
27
|
+
build_stage = []
|
|
28
|
+
|
|
29
|
+
for job in jobs:
|
|
30
|
+
if job.stage == 'build':
|
|
31
|
+
build_stage = True
|
|
32
|
+
Build_stage_jobs.append(job)
|
|
33
|
+
|
|
34
|
+
if not build_stage:
|
|
35
|
+
return {False: 'No build stages available'}
|
|
36
|
+
|
|
37
|
+
for job in Build_stage_jobs:
|
|
38
|
+
job_info = glEntity.jobs.get(job.id)
|
|
39
|
+
artifact = job_info.artifacts()
|
|
40
|
+
byte_stream = io.BytesIO(artifact)
|
|
41
|
+
|
|
42
|
+
with zipfile.ZipFile(byte_stream) as z:
|
|
43
|
+
file_list = z.namelist()
|
|
44
|
+
|
|
45
|
+
for file_name in file_list:
|
|
46
|
+
base_name, extension = os.path.splitext(file_name)
|
|
47
|
+
sig_file = f"{base_name}.sig"
|
|
48
|
+
|
|
49
|
+
if sig_file not in file_list:
|
|
50
|
+
return {False: 'Artifacts are not being signed'}
|
|
51
|
+
|
|
52
|
+
return {True: 'Artifacts are signed'}
|
|
53
|
+
|
|
54
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
55
|
+
GitlabListError) as e:
|
|
56
|
+
if e.response_code in [401, 403]:
|
|
57
|
+
return {None: 'Insufficient permissions'}
|
|
58
|
+
|
|
59
|
+
# -------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def encrypt_artifacts_before_distribution(glEntity, glObject, **kwargs):
|
|
63
|
+
"""
|
|
64
|
+
id: 4.1.2
|
|
65
|
+
title: Ensure artifacts are encrypted before distribution
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
69
|
+
return {None: 'This check requires validation'}
|
|
70
|
+
|
|
71
|
+
# -------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def only_authorized_platforms_can_decrypt_artifacts(
|
|
75
|
+
glEntity, glObject, **kwargs):
|
|
76
|
+
"""
|
|
77
|
+
id: 4.1.3
|
|
78
|
+
title: Ensure only authorized platforms have decryption
|
|
79
|
+
capabilities of artifacts
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
83
|
+
return {None: 'This check requires validation'}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
def single_responsibility_pipeline(glEntity, glObject, **kwargs):
|
|
4
|
+
"""
|
|
5
|
+
id: 2.1.1
|
|
6
|
+
title: Ensure each pipeline has a single responsibility
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
10
|
+
GitlabHttpError, GitlabListError)
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
pipelines = glEntity.pipelines.list(get_all=False)
|
|
14
|
+
|
|
15
|
+
if not pipelines:
|
|
16
|
+
return {True: 'No pipelines found'}
|
|
17
|
+
|
|
18
|
+
latestPipeline = pipelines[0]
|
|
19
|
+
jobs = latestPipeline.jobs.list()
|
|
20
|
+
|
|
21
|
+
buildStages = set()
|
|
22
|
+
multiBuildJobs = False
|
|
23
|
+
|
|
24
|
+
for job in jobs:
|
|
25
|
+
|
|
26
|
+
_stage = job.stage.lower()
|
|
27
|
+
|
|
28
|
+
if 'build' in _stage:
|
|
29
|
+
if _stage in buildStages:
|
|
30
|
+
multiBuildJobs = True
|
|
31
|
+
break
|
|
32
|
+
buildStages.add(_stage)
|
|
33
|
+
|
|
34
|
+
if len(buildStages) == 0:
|
|
35
|
+
return {None: 'No build stage found'}
|
|
36
|
+
|
|
37
|
+
# either there are multiple pipeline stages with "build" in the name
|
|
38
|
+
# or there are multiple jobs in those stages
|
|
39
|
+
if multiBuildJobs is True:
|
|
40
|
+
return {False: 'Multi build stages or build jobs found'}
|
|
41
|
+
|
|
42
|
+
# there's a single build stage, which has a single job:
|
|
43
|
+
return {True: 'Build phase has a single responsibility'}
|
|
44
|
+
|
|
45
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
46
|
+
GitlabListError) as e:
|
|
47
|
+
if e.response_code in [403, 401]:
|
|
48
|
+
return {None: 'Insufficient permissions'}
|
|
49
|
+
|
|
50
|
+
# -------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def immutable_pipeline_infrastructure(glEntity, glObject, **kwargs):
|
|
54
|
+
"""
|
|
55
|
+
id: 2.1.2
|
|
56
|
+
title: Ensure all aspects of the pipeline infrastructure and
|
|
57
|
+
configuration are immutable
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
61
|
+
return {None: 'This check requires validation'}
|
|
62
|
+
|
|
63
|
+
# -------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def build_logging(glEntity, glObject, **kwargs):
|
|
67
|
+
"""
|
|
68
|
+
id: 2.1.3
|
|
69
|
+
title: Ensure the build environment is logged
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
73
|
+
return {None: 'This check requires validation'}
|
|
74
|
+
|
|
75
|
+
# -------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def build_automation(glEntity, glObject, **kwargs):
|
|
79
|
+
"""
|
|
80
|
+
id: 2.1.4
|
|
81
|
+
title: Ensure the creation of the build environment is automated
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
85
|
+
GitlabHttpError)
|
|
86
|
+
|
|
87
|
+
from gitlabcis.utils import ci
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
gitlab_ci_yml = ci.getConfig(glEntity, glObject, **kwargs)
|
|
91
|
+
|
|
92
|
+
ciFile, reason = gitlab_ci_yml.popitem()
|
|
93
|
+
|
|
94
|
+
if ciFile in [None, False]:
|
|
95
|
+
return {ciFile: reason}
|
|
96
|
+
else:
|
|
97
|
+
return {True: 'The build environment creation is automated'}
|
|
98
|
+
|
|
99
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
100
|
+
if e.response_code in [401, 403]:
|
|
101
|
+
return {None: 'Insufficient permissions'}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# -------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def limit_build_access(glEntity, glObject, **kwargs):
|
|
108
|
+
"""
|
|
109
|
+
id: 2.1.5
|
|
110
|
+
title: Ensure access to build environments is limited
|
|
111
|
+
"""
|
|
112
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
113
|
+
GitlabHttpError)
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
members = glEntity.members.list(all=True)
|
|
117
|
+
reporter_and_above = sum(
|
|
118
|
+
1 for member in members if
|
|
119
|
+
member.access_level >= 20)
|
|
120
|
+
total_members = len(members)
|
|
121
|
+
reporter_and_above_percentage = (
|
|
122
|
+
(reporter_and_above / total_members) * 100
|
|
123
|
+
)
|
|
124
|
+
if reporter_and_above_percentage < 40 or reporter_and_above < 3:
|
|
125
|
+
return {True: 'Build access is limited, less than 40% '
|
|
126
|
+
'of the members have Reporter/Developer role or above'}
|
|
127
|
+
else:
|
|
128
|
+
return {False: 'Build access is not limited, over 40% '
|
|
129
|
+
'of the members have Reporter/Developer role or above'}
|
|
130
|
+
|
|
131
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
132
|
+
if e.response_code in [401, 403]:
|
|
133
|
+
return {None: 'Insufficient permissions'}
|
|
134
|
+
|
|
135
|
+
# -------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def authenticate_build_access(glEntity, glObject, **kwargs):
|
|
139
|
+
"""
|
|
140
|
+
id: 2.1.6
|
|
141
|
+
title: Ensure users must authenticate to access the build
|
|
142
|
+
environment
|
|
143
|
+
"""
|
|
144
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
145
|
+
GitlabHttpError)
|
|
146
|
+
|
|
147
|
+
try:
|
|
148
|
+
members = glEntity.members.list(all=True)
|
|
149
|
+
reporter_and_above = sum(
|
|
150
|
+
1 for member in members if
|
|
151
|
+
member.access_level >= 20)
|
|
152
|
+
total_members = len(members)
|
|
153
|
+
reporter_and_above_percentage = (
|
|
154
|
+
(reporter_and_above / total_members) * 100
|
|
155
|
+
)
|
|
156
|
+
if reporter_and_above_percentage < 40 or reporter_and_above < 3:
|
|
157
|
+
return {True: 'Build access is limited, less than 40% '
|
|
158
|
+
'of the members have Reporter/Developer role or above'}
|
|
159
|
+
else:
|
|
160
|
+
return {False: 'Build access is not limited, over 40% '
|
|
161
|
+
'of the members have Reporter/Developer role or above'}
|
|
162
|
+
|
|
163
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
164
|
+
if e.response_code in [401, 403]:
|
|
165
|
+
return {None: 'Insufficient permissions'}
|
|
166
|
+
|
|
167
|
+
# -------------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def limit_build_secrets_scope(glEntity, glObject, **kwargs):
|
|
171
|
+
"""
|
|
172
|
+
id: 2.1.7
|
|
173
|
+
title: Ensure build secrets are limited to the minimal necessary
|
|
174
|
+
scope
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
178
|
+
return {None: 'This check requires validation'}
|
|
179
|
+
|
|
180
|
+
# -------------------------------------------------------------------------
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def vuln_scanning(glEntity, glObject, **kwargs):
|
|
184
|
+
"""
|
|
185
|
+
id: 2.1.8
|
|
186
|
+
title: Ensure the build infrastructure is automatically scanned for
|
|
187
|
+
vulnerabilities
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
191
|
+
return {None: 'This check requires validation.'}
|
|
192
|
+
|
|
193
|
+
# -------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def disable_build_tools_default_passwords(glEntity, glObject, **kwargs):
|
|
197
|
+
"""
|
|
198
|
+
id: 2.1.9
|
|
199
|
+
title: Ensure default passwords are not used
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
# We cannot automatically answer this check, therefore we SKIP:
|
|
203
|
+
return {None: 'This check requires validation.'}
|
|
204
|
+
|
|
205
|
+
# -------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def secure_build_env_webhooks(glEntity, glObject, **kwargs):
|
|
209
|
+
"""
|
|
210
|
+
id: 2.1.10
|
|
211
|
+
title: Ensure webhooks of the build environment are secured
|
|
212
|
+
"""
|
|
213
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
214
|
+
GitlabHttpError, GitlabListError)
|
|
215
|
+
|
|
216
|
+
try:
|
|
217
|
+
webhooks = glEntity.hooks.list()
|
|
218
|
+
if not webhooks:
|
|
219
|
+
return {True: 'No webhooks found'}
|
|
220
|
+
for webhook in webhooks:
|
|
221
|
+
if (webhook.url.startswith('https://') and
|
|
222
|
+
webhook.enable_ssl_verification):
|
|
223
|
+
continue
|
|
224
|
+
elif webhook.url.startswith('https://'):
|
|
225
|
+
return {False: f'{webhook.url}' + ' uses '
|
|
226
|
+
'HTTPS but SSL verification is disabled'}
|
|
227
|
+
else:
|
|
228
|
+
return {False: f'{webhook.url}' + ' is '
|
|
229
|
+
'insecure (not using HTTPS)'}
|
|
230
|
+
|
|
231
|
+
return {True: 'All webhooks are secure'}
|
|
232
|
+
|
|
233
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError,
|
|
234
|
+
GitlabListError) as e:
|
|
235
|
+
if e.response_code in [401, 403]:
|
|
236
|
+
return {None: 'Insufficient permissions'}
|
|
237
|
+
|
|
238
|
+
# -------------------------------------------------------------------------
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def build_env_admins(glEntity, glObject, **kwargs):
|
|
242
|
+
"""
|
|
243
|
+
id: 2.1.11
|
|
244
|
+
title: Ensure minimum number of administrators are set for the
|
|
245
|
+
build environment
|
|
246
|
+
"""
|
|
247
|
+
from gitlab.exceptions import (GitlabAuthenticationError, GitlabGetError,
|
|
248
|
+
GitlabHttpError)
|
|
249
|
+
|
|
250
|
+
try:
|
|
251
|
+
members = glEntity.members.list(all=True)
|
|
252
|
+
maintainer_and_above = sum(
|
|
253
|
+
1 for member in members if
|
|
254
|
+
member.access_level >= 40)
|
|
255
|
+
total_members = len(members)
|
|
256
|
+
maintainer_and_above_percentage = (
|
|
257
|
+
(maintainer_and_above / total_members) * 100
|
|
258
|
+
)
|
|
259
|
+
if maintainer_and_above_percentage < 20 or maintainer_and_above < 3:
|
|
260
|
+
return {True: 'Build access is limited, less than 20% '
|
|
261
|
+
'of the members have Owner/Maintainer role'}
|
|
262
|
+
else:
|
|
263
|
+
return {False: 'Build access is not limited, over than 20% of '
|
|
264
|
+
'the members have Owner/Maintainer role'}
|
|
265
|
+
|
|
266
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
267
|
+
if e.response_code in [401, 403]:
|
|
268
|
+
return {None: 'Insufficient permissions'}
|