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,419 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
from conftest import run
|
|
4
|
+
|
|
5
|
+
from gitlabcis.benchmarks.source_code_1 import code_risks_1_5
|
|
6
|
+
|
|
7
|
+
# -------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_enable_secret_detection(glEntity, glObject, gqlClient):
|
|
11
|
+
from gql.transport.exceptions import TransportServerError
|
|
12
|
+
|
|
13
|
+
test = code_risks_1_5.enable_secret_detection
|
|
14
|
+
|
|
15
|
+
kwargs = {
|
|
16
|
+
'graphQLEndpoint': 'https://example.com/graphql',
|
|
17
|
+
'graphQLHeaders': {'Authorization': 'Bearer token'}
|
|
18
|
+
}
|
|
19
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
20
|
+
|
|
21
|
+
glEntity.path_with_namespace = 'test/project'
|
|
22
|
+
gqlClient.return_value.execute.return_value = {
|
|
23
|
+
"project": {
|
|
24
|
+
"securityScanners": {
|
|
25
|
+
"enabled": ["SECRET_DETECTION", "CONTAINER_SCANNING"]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
run(glEntity, glObject, test, True, **kwargs)
|
|
30
|
+
|
|
31
|
+
glEntity.path_with_namespace = 'test/project'
|
|
32
|
+
gqlClient.return_value.execute.return_value = {
|
|
33
|
+
"project": {
|
|
34
|
+
"securityScanners": {
|
|
35
|
+
"enabled": ["DEPENDENCY_SCANNING"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
40
|
+
|
|
41
|
+
glEntity.path_with_namespace = 'test/project'
|
|
42
|
+
gqlClient.return_value.execute.return_value = {
|
|
43
|
+
"project": {
|
|
44
|
+
"securityScanners": {
|
|
45
|
+
"enabled": []
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
50
|
+
|
|
51
|
+
glEntity.path_with_namespace = 'test/project'
|
|
52
|
+
gqlClient.return_value.execute.return_value = {
|
|
53
|
+
"project": {}
|
|
54
|
+
}
|
|
55
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
56
|
+
|
|
57
|
+
gqlClient.return_value.execute.side_effect = \
|
|
58
|
+
TransportServerError('GraphQL Error')
|
|
59
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
60
|
+
|
|
61
|
+
gqlClient.return_value.execute.side_effect = \
|
|
62
|
+
AttributeError()
|
|
63
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
64
|
+
|
|
65
|
+
# -------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_secure_pipeline_instructions(glEntity, glObject, unauthorised):
|
|
69
|
+
|
|
70
|
+
test = code_risks_1_5.secure_pipeline_instructions
|
|
71
|
+
run(glEntity, glObject, test, None)
|
|
72
|
+
|
|
73
|
+
# -------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_secure_iac_instructions(glEntity, glObject, gqlClient):
|
|
77
|
+
from gql.transport.exceptions import TransportServerError
|
|
78
|
+
|
|
79
|
+
test = code_risks_1_5.secure_iac_instructions
|
|
80
|
+
|
|
81
|
+
kwargs = {
|
|
82
|
+
'graphQLEndpoint': 'https://example.com/graphql',
|
|
83
|
+
'graphQLHeaders': {'Authorization': 'Bearer token'}
|
|
84
|
+
}
|
|
85
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
86
|
+
|
|
87
|
+
glEntity.path_with_namespace = 'test/project'
|
|
88
|
+
gqlClient.return_value.execute.return_value = {
|
|
89
|
+
"project": {
|
|
90
|
+
"securityScanners": {
|
|
91
|
+
"enabled": ["SAST", "CONTAINER_SCANNING"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
run(glEntity, glObject, test, True, **kwargs)
|
|
96
|
+
|
|
97
|
+
glEntity.path_with_namespace = 'test/project'
|
|
98
|
+
gqlClient.return_value.execute.return_value = {
|
|
99
|
+
"project": {
|
|
100
|
+
"securityScanners": {
|
|
101
|
+
"enabled": ["DEPENDENCY_SCANNING"]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
106
|
+
|
|
107
|
+
glEntity.path_with_namespace = 'test/project'
|
|
108
|
+
gqlClient.return_value.execute.return_value = {
|
|
109
|
+
"project": {
|
|
110
|
+
"securityScanners": {
|
|
111
|
+
"enabled": []
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
116
|
+
|
|
117
|
+
glEntity.path_with_namespace = 'test/project'
|
|
118
|
+
gqlClient.return_value.execute.return_value = {
|
|
119
|
+
"project": {}
|
|
120
|
+
}
|
|
121
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
122
|
+
|
|
123
|
+
gqlClient.return_value.execute.side_effect = \
|
|
124
|
+
TransportServerError('GraphQL Error')
|
|
125
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
126
|
+
|
|
127
|
+
gqlClient.return_value.execute.side_effect = \
|
|
128
|
+
AttributeError()
|
|
129
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
130
|
+
|
|
131
|
+
# -------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def test_vulnerability_scanning(glEntity, glObject, gqlClient):
|
|
135
|
+
from gql.transport.exceptions import TransportServerError
|
|
136
|
+
|
|
137
|
+
test = code_risks_1_5.vulnerability_scanning
|
|
138
|
+
|
|
139
|
+
kwargs = {
|
|
140
|
+
'graphQLEndpoint': 'https://example.com/graphql',
|
|
141
|
+
'graphQLHeaders': {'Authorization': 'Bearer token'}
|
|
142
|
+
}
|
|
143
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
144
|
+
|
|
145
|
+
glEntity.path_with_namespace = 'test/project'
|
|
146
|
+
gqlClient.return_value.execute.return_value = {
|
|
147
|
+
"project": {
|
|
148
|
+
"securityScanners": {
|
|
149
|
+
"enabled": ["SAST", "CONTAINER_SCANNING"]
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
run(glEntity, glObject, test, True, **kwargs)
|
|
154
|
+
|
|
155
|
+
glEntity.path_with_namespace = 'test/project'
|
|
156
|
+
gqlClient.return_value.execute.return_value = {
|
|
157
|
+
"project": {
|
|
158
|
+
"securityScanners": {
|
|
159
|
+
"enabled": ["DEPENDENCY_SCANNING"]
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
164
|
+
|
|
165
|
+
glEntity.path_with_namespace = 'test/project'
|
|
166
|
+
gqlClient.return_value.execute.return_value = {
|
|
167
|
+
"project": {
|
|
168
|
+
"securityScanners": {
|
|
169
|
+
"enabled": []
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
174
|
+
|
|
175
|
+
glEntity.path_with_namespace = 'test/project'
|
|
176
|
+
gqlClient.return_value.execute.return_value = {
|
|
177
|
+
"project": {}
|
|
178
|
+
}
|
|
179
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
180
|
+
|
|
181
|
+
gqlClient.return_value.execute.side_effect = \
|
|
182
|
+
TransportServerError('GraphQL Error')
|
|
183
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
184
|
+
|
|
185
|
+
gqlClient.return_value.execute.side_effect = \
|
|
186
|
+
AttributeError()
|
|
187
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
188
|
+
|
|
189
|
+
# -------------------------------------------------------------------------
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def test_dependency_scanning(glEntity, glObject, gqlClient):
|
|
193
|
+
from gql.transport.exceptions import TransportServerError
|
|
194
|
+
|
|
195
|
+
test = code_risks_1_5.dependency_scanning
|
|
196
|
+
|
|
197
|
+
kwargs = {
|
|
198
|
+
'graphQLEndpoint': 'https://example.com/graphql',
|
|
199
|
+
'graphQLHeaders': {'Authorization': 'Bearer token'}
|
|
200
|
+
}
|
|
201
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
202
|
+
|
|
203
|
+
glEntity.path_with_namespace = 'test/project'
|
|
204
|
+
gqlClient.return_value.execute.return_value = {
|
|
205
|
+
"project": {
|
|
206
|
+
"securityScanners": {
|
|
207
|
+
"enabled": ["DEPENDENCY_SCANNING", "CONTAINER_SCANNING"]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
run(glEntity, glObject, test, True, **kwargs)
|
|
212
|
+
|
|
213
|
+
glEntity.path_with_namespace = 'test/project'
|
|
214
|
+
gqlClient.return_value.execute.return_value = {
|
|
215
|
+
"project": {
|
|
216
|
+
"securityScanners": {
|
|
217
|
+
"enabled": ["CONTAINER_SCANNING"]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
222
|
+
|
|
223
|
+
glEntity.path_with_namespace = 'test/project'
|
|
224
|
+
gqlClient.return_value.execute.return_value = {
|
|
225
|
+
"project": {
|
|
226
|
+
"securityScanners": {
|
|
227
|
+
"enabled": []
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
232
|
+
|
|
233
|
+
glEntity.path_with_namespace = 'test/project'
|
|
234
|
+
gqlClient.return_value.execute.return_value = {
|
|
235
|
+
"project": {}
|
|
236
|
+
}
|
|
237
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
238
|
+
|
|
239
|
+
gqlClient.return_value.execute.side_effect = \
|
|
240
|
+
TransportServerError('GraphQL Error')
|
|
241
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
242
|
+
|
|
243
|
+
gqlClient.return_value.execute.side_effect = \
|
|
244
|
+
AttributeError()
|
|
245
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
246
|
+
|
|
247
|
+
# -------------------------------------------------------------------------
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def test_license_scanning(glEntity, glObject, gqlClient):
|
|
251
|
+
from gql.transport.exceptions import TransportServerError
|
|
252
|
+
|
|
253
|
+
test = code_risks_1_5.license_scanning
|
|
254
|
+
|
|
255
|
+
kwargs = {
|
|
256
|
+
'graphQLEndpoint': 'https://example.com/graphql',
|
|
257
|
+
'graphQLHeaders': {'Authorization': 'Bearer token'}
|
|
258
|
+
}
|
|
259
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
260
|
+
|
|
261
|
+
glEntity.path_with_namespace = 'test/project'
|
|
262
|
+
gqlClient.return_value.execute.return_value = {
|
|
263
|
+
"project": {
|
|
264
|
+
"securityScanners": {
|
|
265
|
+
"enabled": ["DEPENDENCY_SCANNING", "CONTAINER_SCANNING"]
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
run(glEntity, glObject, test, True, **kwargs)
|
|
270
|
+
|
|
271
|
+
glEntity.path_with_namespace = 'test/project'
|
|
272
|
+
gqlClient.return_value.execute.return_value = {
|
|
273
|
+
"project": {
|
|
274
|
+
"securityScanners": {
|
|
275
|
+
"enabled": ["CONTAINER_SCANNING"]
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
280
|
+
|
|
281
|
+
glEntity.path_with_namespace = 'test/project'
|
|
282
|
+
gqlClient.return_value.execute.return_value = {
|
|
283
|
+
"project": {
|
|
284
|
+
"securityScanners": {
|
|
285
|
+
"enabled": []
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
290
|
+
|
|
291
|
+
glEntity.path_with_namespace = 'test/project'
|
|
292
|
+
gqlClient.return_value.execute.return_value = {
|
|
293
|
+
"project": {}
|
|
294
|
+
}
|
|
295
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
296
|
+
|
|
297
|
+
gqlClient.return_value.execute.side_effect = \
|
|
298
|
+
TransportServerError('GraphQL Error')
|
|
299
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
300
|
+
|
|
301
|
+
gqlClient.return_value.execute.side_effect = \
|
|
302
|
+
AttributeError()
|
|
303
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
304
|
+
|
|
305
|
+
# -------------------------------------------------------------------------
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def test_dast_web_scanning(glEntity, glObject, gqlClient):
|
|
309
|
+
from gql.transport.exceptions import TransportServerError
|
|
310
|
+
|
|
311
|
+
test = code_risks_1_5.dast_web_scanning
|
|
312
|
+
|
|
313
|
+
kwargs = {
|
|
314
|
+
'graphQLEndpoint': 'https://example.com/graphql',
|
|
315
|
+
'graphQLHeaders': {'Authorization': 'Bearer token'}
|
|
316
|
+
}
|
|
317
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
318
|
+
|
|
319
|
+
glEntity.path_with_namespace = 'test/project'
|
|
320
|
+
gqlClient.return_value.execute.return_value = {
|
|
321
|
+
"project": {
|
|
322
|
+
"securityScanners": {
|
|
323
|
+
"enabled": ["DAST", "CONTAINER_SCANNING"]
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
run(glEntity, glObject, test, True, **kwargs)
|
|
328
|
+
|
|
329
|
+
glEntity.path_with_namespace = 'test/project'
|
|
330
|
+
gqlClient.return_value.execute.return_value = {
|
|
331
|
+
"project": {
|
|
332
|
+
"securityScanners": {
|
|
333
|
+
"enabled": ["DEPENDENCY_SCANNING"]
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
338
|
+
|
|
339
|
+
glEntity.path_with_namespace = 'test/project'
|
|
340
|
+
gqlClient.return_value.execute.return_value = {
|
|
341
|
+
"project": {
|
|
342
|
+
"securityScanners": {
|
|
343
|
+
"enabled": []
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
348
|
+
|
|
349
|
+
glEntity.path_with_namespace = 'test/project'
|
|
350
|
+
gqlClient.return_value.execute.return_value = {
|
|
351
|
+
"project": {}
|
|
352
|
+
}
|
|
353
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
354
|
+
|
|
355
|
+
gqlClient.return_value.execute.side_effect = \
|
|
356
|
+
TransportServerError('GraphQL Error')
|
|
357
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
358
|
+
|
|
359
|
+
gqlClient.return_value.execute.side_effect = \
|
|
360
|
+
AttributeError()
|
|
361
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
362
|
+
|
|
363
|
+
# -------------------------------------------------------------------------
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def test_dast_api_scanning(glEntity, glObject, gqlClient):
|
|
367
|
+
from gql.transport.exceptions import TransportServerError
|
|
368
|
+
|
|
369
|
+
test = code_risks_1_5.dast_api_scanning
|
|
370
|
+
|
|
371
|
+
kwargs = {
|
|
372
|
+
'graphQLEndpoint': 'https://example.com/graphql',
|
|
373
|
+
'graphQLHeaders': {'Authorization': 'Bearer token'}
|
|
374
|
+
}
|
|
375
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
376
|
+
|
|
377
|
+
glEntity.path_with_namespace = 'test/project'
|
|
378
|
+
gqlClient.return_value.execute.return_value = {
|
|
379
|
+
"project": {
|
|
380
|
+
"securityScanners": {
|
|
381
|
+
"enabled": ["DAST", "CONTAINER_SCANNING"]
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
run(glEntity, glObject, test, True, **kwargs)
|
|
386
|
+
|
|
387
|
+
glEntity.path_with_namespace = 'test/project'
|
|
388
|
+
gqlClient.return_value.execute.return_value = {
|
|
389
|
+
"project": {
|
|
390
|
+
"securityScanners": {
|
|
391
|
+
"enabled": ["DEPENDENCY_SCANNING"]
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
396
|
+
|
|
397
|
+
glEntity.path_with_namespace = 'test/project'
|
|
398
|
+
gqlClient.return_value.execute.return_value = {
|
|
399
|
+
"project": {
|
|
400
|
+
"securityScanners": {
|
|
401
|
+
"enabled": []
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
406
|
+
|
|
407
|
+
glEntity.path_with_namespace = 'test/project'
|
|
408
|
+
gqlClient.return_value.execute.return_value = {
|
|
409
|
+
"project": {}
|
|
410
|
+
}
|
|
411
|
+
run(glEntity, glObject, test, False, **kwargs)
|
|
412
|
+
|
|
413
|
+
gqlClient.return_value.execute.side_effect = \
|
|
414
|
+
TransportServerError('GraphQL Error')
|
|
415
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
416
|
+
|
|
417
|
+
gqlClient.return_value.execute.side_effect = \
|
|
418
|
+
AttributeError()
|
|
419
|
+
run(glEntity, glObject, test, None, **kwargs)
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
from unittest.mock import Mock
|
|
4
|
+
|
|
5
|
+
from gitlabcis.benchmarks.source_code_1 import contribution_access_1_3
|
|
6
|
+
from conftest import run
|
|
7
|
+
|
|
8
|
+
# -----------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_review_and_remove_inactive_users(glEntity, glObject, unauthorised):
|
|
12
|
+
from gitlab.exceptions import GitlabGetError
|
|
13
|
+
|
|
14
|
+
from dateutil.relativedelta import relativedelta
|
|
15
|
+
from datetime import datetime, timezone
|
|
16
|
+
|
|
17
|
+
test = contribution_access_1_3.review_and_remove_inactive_users
|
|
18
|
+
|
|
19
|
+
user = Mock()
|
|
20
|
+
hundredDaysAgo = datetime.strftime(
|
|
21
|
+
datetime.now(timezone.utc) - relativedelta(days=100),
|
|
22
|
+
'%Y-%m-%d')
|
|
23
|
+
yesterday = datetime.strftime(
|
|
24
|
+
datetime.now(timezone.utc) - relativedelta(days=1),
|
|
25
|
+
'%Y-%m-%d')
|
|
26
|
+
|
|
27
|
+
unauthorised.users.list.side_effect = GitlabGetError(response_code=401)
|
|
28
|
+
run(unauthorised, unauthorised, test, None)
|
|
29
|
+
|
|
30
|
+
user.last_activity_on = None
|
|
31
|
+
glObject.users.list.return_value = [user]
|
|
32
|
+
run(glEntity, glObject, test, True)
|
|
33
|
+
|
|
34
|
+
user.last_activity_on = yesterday
|
|
35
|
+
glObject.users.list.return_value = [user]
|
|
36
|
+
run(glEntity, glObject, test, False)
|
|
37
|
+
|
|
38
|
+
user.last_activity_on = hundredDaysAgo
|
|
39
|
+
glObject.users.list.return_value = [user]
|
|
40
|
+
run(glEntity, glObject, test, True)
|
|
41
|
+
|
|
42
|
+
del user.last_activity_on
|
|
43
|
+
glObject.users.list.return_value = [user]
|
|
44
|
+
run(glEntity, glObject, test, None)
|
|
45
|
+
|
|
46
|
+
# -----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_limit_top_level_group_creation(glEntity, glObject, unauthorised):
|
|
50
|
+
from gitlab.exceptions import GitlabGetError
|
|
51
|
+
|
|
52
|
+
test = contribution_access_1_3.limit_top_level_group_creation
|
|
53
|
+
|
|
54
|
+
unauthorised.settings.get.side_effect = GitlabGetError(
|
|
55
|
+
response_code=401)
|
|
56
|
+
run(unauthorised, unauthorised, test, None)
|
|
57
|
+
|
|
58
|
+
glObject.settings.get.return_value = Mock(can_create_group=False)
|
|
59
|
+
run(glEntity, glObject, test, True)
|
|
60
|
+
|
|
61
|
+
glObject.settings.get.return_value = Mock(can_create_group=True)
|
|
62
|
+
run(glEntity, glObject, test, False)
|
|
63
|
+
|
|
64
|
+
# -------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_minimum_number_of_admins(glEntity, glObject, unauthorised):
|
|
68
|
+
|
|
69
|
+
from gitlab.exceptions import GitlabGetError
|
|
70
|
+
|
|
71
|
+
test = contribution_access_1_3.minimum_number_of_admins
|
|
72
|
+
|
|
73
|
+
unauthorised.members_all.list.side_effect = GitlabGetError(
|
|
74
|
+
response_code=401)
|
|
75
|
+
run(unauthorised, unauthorised, test, None)
|
|
76
|
+
|
|
77
|
+
member = Mock(access_level=40)
|
|
78
|
+
glEntity.members_all.list.return_value = [member]
|
|
79
|
+
run(glEntity, glObject, test, None)
|
|
80
|
+
|
|
81
|
+
member2 = Mock(access_level=10)
|
|
82
|
+
member3 = Mock(access_level=10)
|
|
83
|
+
glEntity.members_all.list.return_value = [member, member2, member3]
|
|
84
|
+
run(glEntity, glObject, test, True)
|
|
85
|
+
|
|
86
|
+
member2 = Mock(access_level=40)
|
|
87
|
+
member3 = Mock(access_level=40)
|
|
88
|
+
glEntity.members_all.list.return_value = [member, member2, member3]
|
|
89
|
+
run(glEntity, glObject, test, False)
|
|
90
|
+
|
|
91
|
+
# -------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_require_mfa_for_contributors(glEntity, glObject, unauthorised):
|
|
95
|
+
|
|
96
|
+
from gitlab.exceptions import GitlabGetError
|
|
97
|
+
|
|
98
|
+
test = contribution_access_1_3.require_mfa_for_contributors
|
|
99
|
+
|
|
100
|
+
unauthorised.settings.get.side_effect = GitlabGetError(response_code=401)
|
|
101
|
+
run(unauthorised, unauthorised, test, None)
|
|
102
|
+
|
|
103
|
+
settings = Mock()
|
|
104
|
+
|
|
105
|
+
settings.require_two_factor_authentication = True
|
|
106
|
+
glObject.settings.get.return_value = settings
|
|
107
|
+
run(glEntity, glObject, test, True)
|
|
108
|
+
|
|
109
|
+
settings.require_two_factor_authentication = False
|
|
110
|
+
glObject.settings.get.return_value = settings
|
|
111
|
+
run(glEntity, glObject, test, False)
|
|
112
|
+
|
|
113
|
+
# -------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_require_mfa_at_org_level(glEntity, glObject, unauthorised):
|
|
117
|
+
|
|
118
|
+
from gitlab.exceptions import GitlabGetError
|
|
119
|
+
|
|
120
|
+
test = contribution_access_1_3.require_mfa_at_org_level
|
|
121
|
+
|
|
122
|
+
unauthorised.settings.get.side_effect = GitlabGetError(response_code=401)
|
|
123
|
+
run(unauthorised, unauthorised, test, None)
|
|
124
|
+
|
|
125
|
+
settings = Mock()
|
|
126
|
+
|
|
127
|
+
settings.require_two_factor_authentication = True
|
|
128
|
+
glObject.settings.get.return_value = settings
|
|
129
|
+
run(glEntity, glObject, test, True)
|
|
130
|
+
|
|
131
|
+
settings.require_two_factor_authentication = False
|
|
132
|
+
settings.two_factor_grace_period = 1
|
|
133
|
+
glObject.settings.get.return_value = settings
|
|
134
|
+
run(glEntity, glObject, test, True)
|
|
135
|
+
|
|
136
|
+
settings.require_two_factor_authentication = False
|
|
137
|
+
settings.two_factor_grace_period = 0
|
|
138
|
+
glObject.settings.get.return_value = settings
|
|
139
|
+
run(glEntity, glObject, test, False)
|
|
140
|
+
|
|
141
|
+
# -------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_limit_user_registration_domain(glEntity, glObject):
|
|
145
|
+
|
|
146
|
+
test = contribution_access_1_3.limit_user_registration_domain
|
|
147
|
+
|
|
148
|
+
run(glEntity, glObject, test, None)
|
|
149
|
+
|
|
150
|
+
# -------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_ensure_2_admins_per_repo(glEntity, glObject, unauthorised):
|
|
154
|
+
from gitlab.exceptions import GitlabGetError
|
|
155
|
+
|
|
156
|
+
test = contribution_access_1_3.ensure_2_admins_per_repo
|
|
157
|
+
|
|
158
|
+
unauthorised.members_all.list.side_effect = GitlabGetError(
|
|
159
|
+
response_code=401)
|
|
160
|
+
run(unauthorised, unauthorised, test, None)
|
|
161
|
+
|
|
162
|
+
del unauthorised.members_all
|
|
163
|
+
run(unauthorised, unauthorised, test, None)
|
|
164
|
+
|
|
165
|
+
member = Mock(access_level=50)
|
|
166
|
+
member2 = Mock(access_level=50)
|
|
167
|
+
glEntity.members_all.list.return_value = [member, member2]
|
|
168
|
+
run(glEntity, glObject, test, True)
|
|
169
|
+
|
|
170
|
+
member = Mock(access_level=10)
|
|
171
|
+
glEntity.members_all.list.return_value = [member]
|
|
172
|
+
run(glEntity, glObject, test, True)
|
|
173
|
+
|
|
174
|
+
member = Mock(access_level=50)
|
|
175
|
+
glEntity.members_all.list.return_value = [member]
|
|
176
|
+
run(glEntity, glObject, test, True)
|
|
177
|
+
|
|
178
|
+
# -------------------------------------------------------------------------
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def test_strict_permissions_for_repo(glEntity, glObject, unauthorised):
|
|
182
|
+
from gitlab.exceptions import GitlabGetError
|
|
183
|
+
|
|
184
|
+
test = contribution_access_1_3.strict_permissions_for_repo
|
|
185
|
+
|
|
186
|
+
unauthorised.members_all.list.side_effect = GitlabGetError(
|
|
187
|
+
response_code=401)
|
|
188
|
+
run(unauthorised, unauthorised, test, None)
|
|
189
|
+
|
|
190
|
+
member = Mock(access_level=40)
|
|
191
|
+
glEntity.members_all.list.return_value = [member]
|
|
192
|
+
run(glEntity, glObject, test, None)
|
|
193
|
+
|
|
194
|
+
member = Mock(access_level=40)
|
|
195
|
+
member2 = Mock(access_level=10)
|
|
196
|
+
member3 = Mock(access_level=10)
|
|
197
|
+
glEntity.members_all.list.return_value = [member, member2, member3]
|
|
198
|
+
run(glEntity, glObject, test, True)
|
|
199
|
+
|
|
200
|
+
member = Mock(access_level=40)
|
|
201
|
+
member2 = Mock(access_level=40)
|
|
202
|
+
glEntity.members_all.list.return_value = [member, member2]
|
|
203
|
+
run(glEntity, glObject, test, False)
|
|
204
|
+
|
|
205
|
+
# -------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def test_domain_verification(glEntity, glObject):
|
|
209
|
+
|
|
210
|
+
test = contribution_access_1_3.domain_verification
|
|
211
|
+
|
|
212
|
+
run(glEntity, glObject, test, None)
|
|
213
|
+
|
|
214
|
+
# -------------------------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_scm_notification_restriction(glEntity, glObject):
|
|
218
|
+
|
|
219
|
+
test = contribution_access_1_3.scm_notification_restriction
|
|
220
|
+
|
|
221
|
+
run(glEntity, glObject, test, None)
|
|
222
|
+
|
|
223
|
+
# -------------------------------------------------------------------------
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def test_org_provided_ssh_certs(glEntity, glObject, unauthorised):
|
|
227
|
+
|
|
228
|
+
from gitlab.exceptions import GitlabGetError
|
|
229
|
+
|
|
230
|
+
test = contribution_access_1_3.org_provided_ssh_certs
|
|
231
|
+
|
|
232
|
+
unauthorised.settings.get.side_effect = GitlabGetError(response_code=401)
|
|
233
|
+
run(unauthorised, unauthorised, test, None)
|
|
234
|
+
|
|
235
|
+
settings = Mock()
|
|
236
|
+
settings.ed25519_key_restriction = 1
|
|
237
|
+
glObject.settings.get.return_value = settings
|
|
238
|
+
run(glEntity, glObject, test, True)
|
|
239
|
+
|
|
240
|
+
settings.ed25519_key_restriction = 0
|
|
241
|
+
settings.ecdsa_key_restriction = 0
|
|
242
|
+
settings.dsa_key_restriction = 0
|
|
243
|
+
settings.rsa_key_restriction = 0
|
|
244
|
+
settings.ecdsa_sk_key_restriction = 0
|
|
245
|
+
settings.ed25519_sk_key_restriction = 0
|
|
246
|
+
glObject.settings.get.return_value = settings
|
|
247
|
+
run(glEntity, glObject, test, False)
|
|
248
|
+
|
|
249
|
+
# -------------------------------------------------------------------------
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def test_restrict_ip_addresses(glEntity, glObject):
|
|
253
|
+
|
|
254
|
+
test = contribution_access_1_3.restrict_ip_addresses
|
|
255
|
+
|
|
256
|
+
run(glEntity, glObject, test, None)
|
|
257
|
+
|
|
258
|
+
# -------------------------------------------------------------------------
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def test_track_code_anomalies(glEntity, glObject):
|
|
262
|
+
|
|
263
|
+
test = contribution_access_1_3.track_code_anomalies
|
|
264
|
+
|
|
265
|
+
run(glEntity, glObject, test, None)
|