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,506 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
def enable_secret_detection(glEntity, glObject, **kwargs):
|
|
4
|
+
"""
|
|
5
|
+
id: 1.5.1
|
|
6
|
+
title: Ensure scanners are in place to identify and prevent sensitive
|
|
7
|
+
data in code
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
|
|
11
|
+
from gitlab.exceptions import GitlabAuthenticationError
|
|
12
|
+
from gql import gql
|
|
13
|
+
from graphql import GraphQLError
|
|
14
|
+
from gql.transport.exceptions import TransportServerError
|
|
15
|
+
from gql.transport.exceptions import TransportAlreadyConnected
|
|
16
|
+
from gql import Client
|
|
17
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
|
|
21
|
+
variables = {
|
|
22
|
+
'fullPath': glEntity.path_with_namespace
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
26
|
+
if e.response_code in [401, 403]:
|
|
27
|
+
return {None: 'Insufficient permissions'}
|
|
28
|
+
|
|
29
|
+
client = Client(
|
|
30
|
+
transport=RequestsHTTPTransport(
|
|
31
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
32
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
33
|
+
use_json=True
|
|
34
|
+
),
|
|
35
|
+
fetch_schema_from_transport=True
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
query = gql('''
|
|
39
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
40
|
+
project(fullPath: $fullPath) {
|
|
41
|
+
securityScanners {
|
|
42
|
+
enabled
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
''')
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
|
|
50
|
+
results = client.execute(query, variable_values=variables)
|
|
51
|
+
|
|
52
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
53
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
54
|
+
|
|
55
|
+
# pytest no auth:
|
|
56
|
+
except AttributeError:
|
|
57
|
+
return {None: 'Insufficient permissions'}
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
|
|
61
|
+
if 'SECRET_DETECTION' in \
|
|
62
|
+
results['project']['securityScanners']['enabled']:
|
|
63
|
+
return {True: 'Secret Detection is enabled'}
|
|
64
|
+
|
|
65
|
+
else:
|
|
66
|
+
return {False: 'Secret Detection is not enabled'}
|
|
67
|
+
|
|
68
|
+
except KeyError:
|
|
69
|
+
return {False: 'Secret Detection is not enabled'}
|
|
70
|
+
|
|
71
|
+
# -------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def secure_pipeline_instructions(glEntity, glObject, **kwargs):
|
|
75
|
+
"""
|
|
76
|
+
id: 1.5.2
|
|
77
|
+
title: Detect and prevent misconfigurations and insecure instructions
|
|
78
|
+
in CI pipelines
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
return {None: 'This check requires validation'}
|
|
82
|
+
|
|
83
|
+
# -------------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def secure_iac_instructions(glEntity, glObject, **kwargs):
|
|
87
|
+
"""
|
|
88
|
+
id: 1.5.3
|
|
89
|
+
title: Ensure scanners are in place to secure Infrastructure as Code
|
|
90
|
+
(IaC) instructions
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
|
|
94
|
+
from gitlab.exceptions import GitlabAuthenticationError
|
|
95
|
+
from gql import gql
|
|
96
|
+
from graphql import GraphQLError
|
|
97
|
+
from gql.transport.exceptions import TransportServerError
|
|
98
|
+
from gql.transport.exceptions import TransportAlreadyConnected
|
|
99
|
+
from gql import Client
|
|
100
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
101
|
+
|
|
102
|
+
try:
|
|
103
|
+
|
|
104
|
+
variables = {
|
|
105
|
+
'fullPath': glEntity.path_with_namespace
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
109
|
+
if e.response_code in [401, 403]:
|
|
110
|
+
return {None: 'Insufficient permissions'}
|
|
111
|
+
|
|
112
|
+
client = Client(
|
|
113
|
+
transport=RequestsHTTPTransport(
|
|
114
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
115
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
116
|
+
use_json=True
|
|
117
|
+
),
|
|
118
|
+
fetch_schema_from_transport=True
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
query = gql('''
|
|
122
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
123
|
+
project(fullPath: $fullPath) {
|
|
124
|
+
securityScanners {
|
|
125
|
+
enabled
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
''')
|
|
130
|
+
|
|
131
|
+
try:
|
|
132
|
+
|
|
133
|
+
results = client.execute(query, variable_values=variables)
|
|
134
|
+
|
|
135
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
136
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
137
|
+
|
|
138
|
+
# pytest no auth:
|
|
139
|
+
except AttributeError:
|
|
140
|
+
return {None: 'Insufficient permissions'}
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
|
|
144
|
+
if 'SAST' in \
|
|
145
|
+
results['project']['securityScanners']['enabled']:
|
|
146
|
+
return {True: 'SAST Scanning is enabled'}
|
|
147
|
+
|
|
148
|
+
else:
|
|
149
|
+
return {False: 'SAST Scanning is not enabled'}
|
|
150
|
+
|
|
151
|
+
except KeyError:
|
|
152
|
+
return {False: 'SAST Scanning is not enabled'}
|
|
153
|
+
|
|
154
|
+
# -------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def vulnerability_scanning(glEntity, glObject, **kwargs):
|
|
158
|
+
"""
|
|
159
|
+
id: 1.5.4
|
|
160
|
+
title: Ensure scanners are in place for code vulnerabilities
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
|
|
164
|
+
from gitlab.exceptions import GitlabAuthenticationError
|
|
165
|
+
from gql import gql
|
|
166
|
+
from graphql import GraphQLError
|
|
167
|
+
from gql.transport.exceptions import TransportServerError
|
|
168
|
+
from gql.transport.exceptions import TransportAlreadyConnected
|
|
169
|
+
from gql import Client
|
|
170
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
171
|
+
|
|
172
|
+
try:
|
|
173
|
+
|
|
174
|
+
variables = {
|
|
175
|
+
'fullPath': glEntity.path_with_namespace
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
179
|
+
if e.response_code in [401, 403]:
|
|
180
|
+
return {None: 'Insufficient permissions'}
|
|
181
|
+
|
|
182
|
+
client = Client(
|
|
183
|
+
transport=RequestsHTTPTransport(
|
|
184
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
185
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
186
|
+
use_json=True
|
|
187
|
+
),
|
|
188
|
+
fetch_schema_from_transport=True
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
query = gql('''
|
|
192
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
193
|
+
project(fullPath: $fullPath) {
|
|
194
|
+
securityScanners {
|
|
195
|
+
enabled
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
''')
|
|
200
|
+
|
|
201
|
+
try:
|
|
202
|
+
|
|
203
|
+
results = client.execute(query, variable_values=variables)
|
|
204
|
+
|
|
205
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
206
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
207
|
+
|
|
208
|
+
# pytest no auth:
|
|
209
|
+
except AttributeError:
|
|
210
|
+
return {None: 'Insufficient permissions'}
|
|
211
|
+
|
|
212
|
+
try:
|
|
213
|
+
|
|
214
|
+
if 'SAST' in \
|
|
215
|
+
results['project']['securityScanners']['enabled']:
|
|
216
|
+
return {True: 'Vulnerability Scanning is enabled'}
|
|
217
|
+
|
|
218
|
+
else:
|
|
219
|
+
return {False: 'Vulnerability Scanning is not enabled'}
|
|
220
|
+
|
|
221
|
+
except KeyError:
|
|
222
|
+
return {False: 'Vulnerability Scanning is not enabled'}
|
|
223
|
+
|
|
224
|
+
# -------------------------------------------------------------------------
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def dependency_scanning(glEntity, glObject, **kwargs):
|
|
228
|
+
"""
|
|
229
|
+
id: 1.5.5
|
|
230
|
+
title: Ensure scanners are in place for open-source vulnerabilities in
|
|
231
|
+
used packages
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
|
|
235
|
+
from gitlab.exceptions import GitlabAuthenticationError
|
|
236
|
+
from gql import gql
|
|
237
|
+
from graphql import GraphQLError
|
|
238
|
+
from gql.transport.exceptions import TransportServerError
|
|
239
|
+
from gql.transport.exceptions import TransportAlreadyConnected
|
|
240
|
+
from gql import Client
|
|
241
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
242
|
+
|
|
243
|
+
try:
|
|
244
|
+
|
|
245
|
+
variables = {
|
|
246
|
+
'fullPath': glEntity.path_with_namespace
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
250
|
+
if e.response_code in [401, 403]:
|
|
251
|
+
return {None: 'Insufficient permissions'}
|
|
252
|
+
|
|
253
|
+
client = Client(
|
|
254
|
+
transport=RequestsHTTPTransport(
|
|
255
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
256
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
257
|
+
use_json=True
|
|
258
|
+
),
|
|
259
|
+
fetch_schema_from_transport=True
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
query = gql('''
|
|
263
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
264
|
+
project(fullPath: $fullPath) {
|
|
265
|
+
securityScanners {
|
|
266
|
+
enabled
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
''')
|
|
271
|
+
|
|
272
|
+
try:
|
|
273
|
+
|
|
274
|
+
results = client.execute(query, variable_values=variables)
|
|
275
|
+
|
|
276
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
277
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
278
|
+
|
|
279
|
+
# pytest no auth:
|
|
280
|
+
except AttributeError:
|
|
281
|
+
return {None: 'Insufficient permissions'}
|
|
282
|
+
|
|
283
|
+
try:
|
|
284
|
+
|
|
285
|
+
if 'DEPENDENCY_SCANNING' in \
|
|
286
|
+
results['project']['securityScanners']['enabled']:
|
|
287
|
+
return {True: 'Dependency Scanning is enabled'}
|
|
288
|
+
|
|
289
|
+
else:
|
|
290
|
+
return {False: 'Dependency Scanning is not enabled'}
|
|
291
|
+
|
|
292
|
+
except KeyError:
|
|
293
|
+
return {False: 'Dependency Scanning is not enabled'}
|
|
294
|
+
|
|
295
|
+
# -------------------------------------------------------------------------
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def license_scanning(glEntity, glObject, **kwargs):
|
|
299
|
+
"""
|
|
300
|
+
id: 1.5.6
|
|
301
|
+
title: Ensure scanners are in place for open-source license issues in
|
|
302
|
+
used packages
|
|
303
|
+
"""
|
|
304
|
+
|
|
305
|
+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
|
|
306
|
+
from gitlab.exceptions import GitlabAuthenticationError
|
|
307
|
+
from gql import gql
|
|
308
|
+
from graphql import GraphQLError
|
|
309
|
+
from gql.transport.exceptions import TransportServerError
|
|
310
|
+
from gql.transport.exceptions import TransportAlreadyConnected
|
|
311
|
+
from gql import Client
|
|
312
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
313
|
+
|
|
314
|
+
try:
|
|
315
|
+
|
|
316
|
+
variables = {
|
|
317
|
+
'fullPath': glEntity.path_with_namespace
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
321
|
+
if e.response_code in [401, 403]:
|
|
322
|
+
return {None: 'Insufficient permissions'}
|
|
323
|
+
|
|
324
|
+
client = Client(
|
|
325
|
+
transport=RequestsHTTPTransport(
|
|
326
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
327
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
328
|
+
use_json=True
|
|
329
|
+
),
|
|
330
|
+
fetch_schema_from_transport=True
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
query = gql('''
|
|
334
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
335
|
+
project(fullPath: $fullPath) {
|
|
336
|
+
securityScanners {
|
|
337
|
+
enabled
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
''')
|
|
342
|
+
|
|
343
|
+
try:
|
|
344
|
+
|
|
345
|
+
results = client.execute(query, variable_values=variables)
|
|
346
|
+
|
|
347
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
348
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
349
|
+
|
|
350
|
+
# pytest no auth:
|
|
351
|
+
except AttributeError:
|
|
352
|
+
return {None: 'Insufficient permissions'}
|
|
353
|
+
|
|
354
|
+
try:
|
|
355
|
+
|
|
356
|
+
# License scanning is covered under dependency scanning:
|
|
357
|
+
if 'DEPENDENCY_SCANNING' in \
|
|
358
|
+
results['project']['securityScanners']['enabled']:
|
|
359
|
+
return {True: 'License Scanning is enabled'}
|
|
360
|
+
|
|
361
|
+
else:
|
|
362
|
+
return {False: 'License Scanning is not enabled'}
|
|
363
|
+
|
|
364
|
+
except KeyError:
|
|
365
|
+
return {False: 'License Scanning is not enabled'}
|
|
366
|
+
|
|
367
|
+
# -------------------------------------------------------------------------
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def dast_web_scanning(glEntity, glObject, **kwargs):
|
|
371
|
+
"""
|
|
372
|
+
id: 1.5.7
|
|
373
|
+
title: Ensure scanners are in place for web application runtime
|
|
374
|
+
security weaknesses
|
|
375
|
+
"""
|
|
376
|
+
|
|
377
|
+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
|
|
378
|
+
from gitlab.exceptions import GitlabAuthenticationError
|
|
379
|
+
from gql import gql
|
|
380
|
+
from graphql import GraphQLError
|
|
381
|
+
from gql.transport.exceptions import TransportServerError
|
|
382
|
+
from gql.transport.exceptions import TransportAlreadyConnected
|
|
383
|
+
from gql import Client
|
|
384
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
385
|
+
|
|
386
|
+
try:
|
|
387
|
+
|
|
388
|
+
variables = {
|
|
389
|
+
'fullPath': glEntity.path_with_namespace
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
393
|
+
if e.response_code in [401, 403]:
|
|
394
|
+
return {None: 'Insufficient permissions'}
|
|
395
|
+
|
|
396
|
+
client = Client(
|
|
397
|
+
transport=RequestsHTTPTransport(
|
|
398
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
399
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
400
|
+
use_json=True
|
|
401
|
+
),
|
|
402
|
+
fetch_schema_from_transport=True
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
query = gql('''
|
|
406
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
407
|
+
project(fullPath: $fullPath) {
|
|
408
|
+
securityScanners {
|
|
409
|
+
enabled
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
''')
|
|
414
|
+
|
|
415
|
+
try:
|
|
416
|
+
|
|
417
|
+
results = client.execute(query, variable_values=variables)
|
|
418
|
+
|
|
419
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
420
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
421
|
+
|
|
422
|
+
# pytest no auth:
|
|
423
|
+
except AttributeError:
|
|
424
|
+
return {None: 'Insufficient permissions'}
|
|
425
|
+
|
|
426
|
+
try:
|
|
427
|
+
|
|
428
|
+
if 'DAST' in \
|
|
429
|
+
results['project']['securityScanners']['enabled']:
|
|
430
|
+
return {True: 'DAST Scanning is enabled'}
|
|
431
|
+
|
|
432
|
+
else:
|
|
433
|
+
return {False: 'DAST Scanning is not enabled'}
|
|
434
|
+
|
|
435
|
+
except KeyError:
|
|
436
|
+
return {False: 'DAST Scanning is not enabled'}
|
|
437
|
+
|
|
438
|
+
# -------------------------------------------------------------------------
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def dast_api_scanning(glEntity, glObject, **kwargs):
|
|
442
|
+
"""
|
|
443
|
+
id: 1.5.8
|
|
444
|
+
title: Ensure scanners are in place for API runtime security weaknesses
|
|
445
|
+
"""
|
|
446
|
+
|
|
447
|
+
from gitlab.exceptions import GitlabGetError, GitlabHttpError
|
|
448
|
+
from gitlab.exceptions import GitlabAuthenticationError
|
|
449
|
+
from gql import gql
|
|
450
|
+
from graphql import GraphQLError
|
|
451
|
+
from gql.transport.exceptions import TransportServerError
|
|
452
|
+
from gql.transport.exceptions import TransportAlreadyConnected
|
|
453
|
+
from gql import Client
|
|
454
|
+
from gql.transport.requests import RequestsHTTPTransport
|
|
455
|
+
|
|
456
|
+
try:
|
|
457
|
+
|
|
458
|
+
variables = {
|
|
459
|
+
'fullPath': glEntity.path_with_namespace
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
except (GitlabHttpError, GitlabGetError, GitlabAuthenticationError) as e:
|
|
463
|
+
if e.response_code in [401, 403]:
|
|
464
|
+
return {None: 'Insufficient permissions'}
|
|
465
|
+
|
|
466
|
+
client = Client(
|
|
467
|
+
transport=RequestsHTTPTransport(
|
|
468
|
+
url=kwargs.get('graphQLEndpoint'),
|
|
469
|
+
headers=kwargs.get('graphQLHeaders'),
|
|
470
|
+
use_json=True
|
|
471
|
+
),
|
|
472
|
+
fetch_schema_from_transport=True
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
query = gql('''
|
|
476
|
+
query GetSecurityScanners($fullPath: ID!) {
|
|
477
|
+
project(fullPath: $fullPath) {
|
|
478
|
+
securityScanners {
|
|
479
|
+
enabled
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
''')
|
|
484
|
+
|
|
485
|
+
try:
|
|
486
|
+
|
|
487
|
+
results = client.execute(query, variable_values=variables)
|
|
488
|
+
|
|
489
|
+
except (GraphQLError, TransportServerError, TransportAlreadyConnected):
|
|
490
|
+
return {None: 'Error: Issue with GraphQL Query'}
|
|
491
|
+
|
|
492
|
+
# pytest no auth:
|
|
493
|
+
except AttributeError:
|
|
494
|
+
return {None: 'Insufficient permissions'}
|
|
495
|
+
|
|
496
|
+
try:
|
|
497
|
+
|
|
498
|
+
if 'DAST' in \
|
|
499
|
+
results['project']['securityScanners']['enabled']:
|
|
500
|
+
return {True: 'DAST Scanning is enabled'}
|
|
501
|
+
|
|
502
|
+
else:
|
|
503
|
+
return {False: 'DAST Scanning is not enabled'}
|
|
504
|
+
|
|
505
|
+
except KeyError:
|
|
506
|
+
return {False: 'DAST Scanning is not enabled'}
|