coguard-cli 0.2.44__tar.gz → 0.2.45__tar.gz
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.
- {coguard_cli-0.2.44/src/coguard_cli.egg-info → coguard_cli-0.2.45}/PKG-INFO +1 -1
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/setup.cfg +1 -1
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/__init__.py +21 -50
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/output_generators/output_generator_sarif.py +2 -2
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/common_functions_test.py +66 -48
- {coguard_cli-0.2.44 → coguard_cli-0.2.45/src/coguard_cli.egg-info}/PKG-INFO +1 -1
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/LICENSE +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/README.md +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/README_PYPI.md +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/pyproject.toml +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/__main__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/api_connection.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/auth/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/auth/auth_config.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/auth/token.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/auth/util.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/ci_cd/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/ci_cd/ci_cd_provider_abc.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/ci_cd/ci_cd_provider_factory.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/ci_cd/ci_cd_providers/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/ci_cd/ci_cd_providers/ci_cd_provider_github.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/ci_cd/ci_cd_scripts/github/github_coguard_action.yml +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/cluster_rule_fail_util.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/cloud_provider_abc.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/cloud_provider_factory.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/cloud_providers/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/cloud_providers/cloud_provider_aws.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/cloud_providers/cloud_provider_azure.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/cloud_providers/cloud_provider_gcp.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/terraformer_extract_image_helper/Dockerfile +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/terraformer_extract_image_helper/data/versions.tf +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/terraformer_extract_image_helper/scripts/cmd_for_dfile +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finder_abc.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finder_factory.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_ansible.py +1 -1
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_apache.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_aws_cfn.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_docker_compose.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_docker_daemon.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_dockerfile.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_elasticsearch.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_github_actions.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_grafana.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_helm.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_iis.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_kafka.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_kerberos.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_kubernetes.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_mongodb.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_mysql.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_netlify.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_nginx.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_open_telemetry_collector.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_openapi.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_postgres.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_rabbitmq.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_redis.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_rethinkdb.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_systemd.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_terraform.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/config_file_finder_tomcat.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/docker_dao.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/folder_scan/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/image_check/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/output_generators/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/print_colors.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/api_connection_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/auth/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/auth/auth_config_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/auth/common_auth_function_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/auth/token_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/ci_cd/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/ci_cd/ci_cd_provider_factory_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/ci_cd/ci_cd_providers/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/ci_cd/ci_cd_providers/ci_cd_provider_github_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/cluster_rule_fail_util_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/cloud_discovery/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/cloud_discovery/cloud_provider_factory_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/cloud_discovery/cloud_providers/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/cloud_discovery/cloud_providers/cloud_provider_aws_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/cloud_discovery/cloud_providers/cloud_provider_azure_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/cloud_discovery/cloud_providers/cloud_provider_gcp_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finder_abc_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finder_factory_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/common_functions_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_ansible_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_apache_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_docker_compose_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_docker_daemon_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_dockerfile_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_elasticsearch_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_helm_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_kafka_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_kerberos_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_kubernetes_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_mongodb_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_mysql_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_nginx_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_open_api_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_opentelemetry_collector_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_postgres_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_rabbit_mq_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_redis_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_rethinkdb_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_systemd_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_terraform_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/discovery/config_file_finders/config_file_finder_tomcat_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/folder_scan/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/folder_scan/common_functions_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/image_check/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/image_check/common_functions_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/image_check/docker_dao_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/output_generators/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/output_generators/output_generator_sarif_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/util_test.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/util.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli.egg-info/SOURCES.txt +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli.egg-info/dependency_links.txt +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli.egg-info/entry_points.txt +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli.egg-info/requires.txt +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli.egg-info/top_level.txt +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coverity_integration/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coverity_integration/src/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coverity_integration/src/coguard_coverity_translator/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coverity_integration/src/coguard_coverity_translator/__main__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coverity_integration/src/coguard_coverity_translator/json_translator.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coverity_integration/src/coguard_coverity_translator/tests/__init__.py +0 -0
- {coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coverity_integration/src/coguard_coverity_translator/tests/json_translator_test.py +0 -0
|
@@ -31,62 +31,37 @@ from coguard_cli.util import convert_posix_path_to_os_path
|
|
|
31
31
|
from coguard_cli.output_generators.output_generator_sarif import \
|
|
32
32
|
translate_result_to_sarif
|
|
33
33
|
|
|
34
|
-
def extract_reference_string(entry_dict: Dict
|
|
34
|
+
def extract_reference_string(entry_dict: Dict):
|
|
35
35
|
"""
|
|
36
36
|
This is a helper function to extract the respective file in the manifest
|
|
37
37
|
corresponding to an entry in the failed rules.
|
|
38
38
|
"""
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]
|
|
55
|
-
if config_file_list_of_container:
|
|
56
|
-
reference = f" (affected files: {', '.join(config_file_list_of_container)})"
|
|
57
|
-
break
|
|
58
|
-
if not reference:
|
|
59
|
-
# Could be in cluster services
|
|
60
|
-
services_dict = manifest_dict.get("clusterServices", {})
|
|
61
|
-
if entry_dict.get("service") in services_dict:
|
|
62
|
-
config_file_list_of_container = \
|
|
63
|
-
[
|
|
64
|
-
os.path.join(
|
|
65
|
-
convert_posix_path_to_os_path(entry["subPath"]),
|
|
66
|
-
entry["fileName"]
|
|
67
|
-
) + \
|
|
68
|
-
" for service " + entry_dict.get("service")
|
|
69
|
-
for entry in services_dict.get(
|
|
70
|
-
entry_dict.get("service")
|
|
71
|
-
).get("configFileList", [])
|
|
72
|
-
]
|
|
73
|
-
if config_file_list_of_container:
|
|
74
|
-
reference = f" (affected files: {', '.join(config_file_list_of_container)})"
|
|
75
|
-
return reference
|
|
39
|
+
config_file_in_entry = entry_dict.get("config_file", {})
|
|
40
|
+
from_line = entry_dict.get("fromLine", None)
|
|
41
|
+
to_line = entry_dict.get("toLine", None)
|
|
42
|
+
if (from_line is not None and to_line is not None) and (from_line != 0 and to_line != 1):
|
|
43
|
+
from_to_line = f", {from_line}-{to_line}"
|
|
44
|
+
else:
|
|
45
|
+
from_to_line = ""
|
|
46
|
+
if not config_file_in_entry:
|
|
47
|
+
return ""
|
|
48
|
+
reference_path = pathlib.Path(
|
|
49
|
+
config_file_in_entry.get("subPath", ".")
|
|
50
|
+
).joinpath(
|
|
51
|
+
config_file_in_entry.get("fileName", ".")
|
|
52
|
+
)
|
|
53
|
+
return f" (affected files: {reference_path}{from_to_line})"
|
|
76
54
|
|
|
77
55
|
def print_failed_check(color: str,
|
|
78
56
|
entry: Dict,
|
|
79
|
-
manifest_dict: Dict,
|
|
80
57
|
fixable_checks: List[str]):
|
|
81
58
|
"""
|
|
82
59
|
This is the function to print a failed check entry, given a color.
|
|
83
60
|
|
|
84
61
|
:param color: The color to use. see e.g. :const:`COLOR_RED`
|
|
85
62
|
:param entry: The entry as returned by the CoGuard API.
|
|
86
|
-
:param manifest_dict: The manifest dictionary containing information about the included
|
|
87
|
-
configuration files
|
|
88
63
|
"""
|
|
89
|
-
reference = extract_reference_string(entry
|
|
64
|
+
reference = extract_reference_string(entry)
|
|
90
65
|
fix_icon = "🔧 " if entry["rule"]["name"] in fixable_checks else ""
|
|
91
66
|
print(
|
|
92
67
|
f'{fix_icon}{color} X Severity {entry["rule"]["severity"]}: '
|
|
@@ -131,7 +106,6 @@ def print_failed_check(color: str,
|
|
|
131
106
|
|
|
132
107
|
def output_result_json_from_coguard(
|
|
133
108
|
result_json: Dict,
|
|
134
|
-
manifest_dict: Dict,
|
|
135
109
|
token: Token,
|
|
136
110
|
coguard_api_url: str,
|
|
137
111
|
user_name: Optional[str],
|
|
@@ -140,8 +114,6 @@ def output_result_json_from_coguard(
|
|
|
140
114
|
The function which outputs the result json in a pretty format to the screen.
|
|
141
115
|
|
|
142
116
|
:param result_json: The output from the API call to CoGuard.
|
|
143
|
-
:param manifest_dict: The manifest dictionary containing information about the included
|
|
144
|
-
configuration files
|
|
145
117
|
"""
|
|
146
118
|
high_checks = [entry for entry in result_json.get("failed", []) \
|
|
147
119
|
if entry["rule"]["severity"] > 3]
|
|
@@ -166,11 +138,11 @@ def output_result_json_from_coguard(
|
|
|
166
138
|
f"(🔧 {len(fixable_checks)} candidates for auto-remediation)")
|
|
167
139
|
print(summary)
|
|
168
140
|
for entry in high_checks:
|
|
169
|
-
print_failed_check(COLOR_RED, entry,
|
|
141
|
+
print_failed_check(COLOR_RED, entry, fixable_check_list)
|
|
170
142
|
for entry in medium_checks:
|
|
171
|
-
print_failed_check(COLOR_YELLOW, entry,
|
|
143
|
+
print_failed_check(COLOR_YELLOW, entry, fixable_check_list)
|
|
172
144
|
for entry in low_checks:
|
|
173
|
-
print_failed_check(COLOR_GRAY, entry,
|
|
145
|
+
print_failed_check(COLOR_GRAY, entry, fixable_check_list)
|
|
174
146
|
print(summary)
|
|
175
147
|
|
|
176
148
|
class SubParserNames(Enum):
|
|
@@ -233,7 +205,7 @@ def upload_and_evaluate_zip_candidate(
|
|
|
233
205
|
f"{COLOR_YELLOW}Unable to identify any known configuration files.{COLOR_TERMINATION}"
|
|
234
206
|
)
|
|
235
207
|
return
|
|
236
|
-
zip_file,
|
|
208
|
+
zip_file, _ = zip_candidate
|
|
237
209
|
result = api_connection.send_zip_file_for_scanning(
|
|
238
210
|
zip_file,
|
|
239
211
|
auth_config.get_username(),
|
|
@@ -257,7 +229,6 @@ def upload_and_evaluate_zip_candidate(
|
|
|
257
229
|
if output_format == 'formatted':
|
|
258
230
|
output_result_json_from_coguard(
|
|
259
231
|
result or {},
|
|
260
|
-
manifest_dict,
|
|
261
232
|
token,
|
|
262
233
|
coguard_api_url,
|
|
263
234
|
auth_config.get_username(),
|
|
@@ -55,8 +55,8 @@ def translate_result_to_sarif(
|
|
|
55
55
|
Remediation: {remediation}
|
|
56
56
|
Sources: {sources}
|
|
57
57
|
""".strip()
|
|
58
|
-
file_uri = pathlib.Path(failed_rule.get("config_file", {}).get("subPath")).joinpath(
|
|
59
|
-
failed_rule.get("config_file", {}).get("fileName")
|
|
58
|
+
file_uri = pathlib.Path(failed_rule.get("config_file", {}).get("subPath", ".")).joinpath(
|
|
59
|
+
failed_rule.get("config_file", {}).get("fileName", "")
|
|
60
60
|
)
|
|
61
61
|
location = {
|
|
62
62
|
"physicalLocation": {
|
|
@@ -13,24 +13,36 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
13
13
|
The class to test the functions in coguard_cli.__init__
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
def
|
|
16
|
+
def test_print_failed_check(self):
|
|
17
17
|
"""
|
|
18
18
|
Prints a failed check entry.
|
|
19
19
|
"""
|
|
20
20
|
new_stdout = StringIO()
|
|
21
|
+
# Comment: we seem to also need to patch logging.debug
|
|
22
|
+
# since it seems to interfere with our mock on
|
|
23
|
+
# sys.stdout. Strange python behavior, and we might
|
|
24
|
+
# want to examine if this is a python bug.
|
|
21
25
|
with unittest.mock.patch(
|
|
22
26
|
'sys.stdout',
|
|
23
|
-
new_callable=lambda: new_stdout)
|
|
27
|
+
new_callable=lambda: new_stdout), \
|
|
28
|
+
unittest.mock.patch(
|
|
29
|
+
'logging.debug',
|
|
30
|
+
new_callable=unittest.mock.MagicMock()
|
|
31
|
+
):
|
|
24
32
|
coguard_cli.print_failed_check(coguard_cli.COLOR_RED, {
|
|
25
33
|
"rule": {
|
|
26
34
|
"name": "foo_bar_baz",
|
|
27
35
|
"severity": 5,
|
|
28
|
-
"documentation":
|
|
36
|
+
"documentation": {
|
|
37
|
+
"documentation": "Let's not even talk about it",
|
|
38
|
+
"remediation": "foo",
|
|
39
|
+
"sources": []
|
|
40
|
+
}
|
|
29
41
|
}
|
|
30
42
|
}, {})
|
|
31
43
|
self.assertIn("not even talk", new_stdout.getvalue())
|
|
32
44
|
|
|
33
|
-
def
|
|
45
|
+
def test_print_output_result_json_from_coguard(self):
|
|
34
46
|
"""
|
|
35
47
|
Prints a failed check entry.
|
|
36
48
|
"""
|
|
@@ -95,13 +107,22 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
95
107
|
}
|
|
96
108
|
with unittest.mock.patch(
|
|
97
109
|
'sys.stdout',
|
|
98
|
-
new_callable=lambda: new_stdout)
|
|
99
|
-
|
|
110
|
+
new_callable=lambda: new_stdout), \
|
|
111
|
+
unittest.mock.patch(
|
|
112
|
+
'coguard_cli.api_connection.get_fixable_rule_list',
|
|
113
|
+
new_callable=lambda: lambda token, coguard_api_url, user_name, organization: []):
|
|
114
|
+
coguard_cli.output_result_json_from_coguard(
|
|
115
|
+
result_json,
|
|
116
|
+
"foo",
|
|
117
|
+
"bar",
|
|
118
|
+
"baz",
|
|
119
|
+
"boo"
|
|
120
|
+
)
|
|
100
121
|
self.assertIn("1 High", new_stdout.getvalue())
|
|
101
122
|
self.assertIn("1 Medium", new_stdout.getvalue())
|
|
102
123
|
self.assertIn("4 Low", new_stdout.getvalue())
|
|
103
124
|
|
|
104
|
-
def
|
|
125
|
+
def test_auth_token_retrieval_auth_config_not_none(self):
|
|
105
126
|
"""
|
|
106
127
|
tests for the auth_token_retrieval.
|
|
107
128
|
"""
|
|
@@ -116,7 +137,7 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
116
137
|
token = coguard_cli.auth_token_retrieval("foo", "bar")
|
|
117
138
|
self.assertIsNotNone(token)
|
|
118
139
|
|
|
119
|
-
def
|
|
140
|
+
def test_auth_token_retrieval_auth_config_none(self):
|
|
120
141
|
"""
|
|
121
142
|
tests for the auth_token_retrieval.
|
|
122
143
|
"""
|
|
@@ -135,7 +156,7 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
135
156
|
token = coguard_cli.auth_token_retrieval("foo", "bar")
|
|
136
157
|
self.assertIsNotNone(token)
|
|
137
158
|
|
|
138
|
-
def
|
|
159
|
+
def test_upload_and_evaluate_zip_candidate_zip_candidate_none(self):
|
|
139
160
|
"""
|
|
140
161
|
Testing zip candidate None
|
|
141
162
|
"""
|
|
@@ -152,24 +173,31 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
152
173
|
"foo",
|
|
153
174
|
None,
|
|
154
175
|
1,
|
|
155
|
-
"foo"
|
|
176
|
+
"foo",
|
|
177
|
+
"iso"
|
|
156
178
|
)
|
|
157
179
|
self.assertIn("Unable to identify any known configuration files.", new_stdout.getvalue())
|
|
158
180
|
|
|
159
|
-
def
|
|
181
|
+
def test_upload_and_evaluate_zip_candidate(self):
|
|
160
182
|
"""
|
|
161
183
|
Testing zip candidate None
|
|
162
184
|
"""
|
|
163
185
|
new_stdout = StringIO()
|
|
164
186
|
with unittest.mock.patch(
|
|
165
187
|
'coguard_cli.api_connection.send_zip_file_for_scanning',
|
|
166
|
-
new_callable=lambda: lambda a, b, c, d, e, f: {"failed": []}), \
|
|
188
|
+
new_callable=lambda: lambda a, b, c, d, e, f, g: {"failed": []}), \
|
|
167
189
|
unittest.mock.patch(
|
|
168
190
|
'sys.stdout',
|
|
169
191
|
new_callable=lambda: new_stdout), \
|
|
170
192
|
unittest.mock.patch(
|
|
171
193
|
'os.remove',
|
|
172
|
-
new_callable=lambda: lambda a: None)
|
|
194
|
+
new_callable=lambda: lambda a: None), \
|
|
195
|
+
unittest.mock.patch(
|
|
196
|
+
'coguard_cli.api_connection.get_fixable_rule_list',
|
|
197
|
+
new_callable=lambda: lambda token, coguard_api_url, user_name, organization: []), \
|
|
198
|
+
unittest.mock.patch(
|
|
199
|
+
'logging.debug',
|
|
200
|
+
new_callable=unittest.mock.MagicMock()):
|
|
173
201
|
auth_config = unittest.mock.MagicMock()
|
|
174
202
|
auth_config.get_username = unittest.mock.Mock(return_value = "foo")
|
|
175
203
|
coguard_cli.upload_and_evaluate_zip_candidate(
|
|
@@ -181,9 +209,10 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
181
209
|
"foo",
|
|
182
210
|
"formatted",
|
|
183
211
|
1,
|
|
184
|
-
"foo"
|
|
212
|
+
"foo",
|
|
213
|
+
"iso"
|
|
185
214
|
)
|
|
186
|
-
self.assertIn("
|
|
215
|
+
self.assertIn("SCANNING OF", new_stdout.getvalue())
|
|
187
216
|
|
|
188
217
|
def upload_and_evaluate_zip_candidate_json_formatted_test(self):
|
|
189
218
|
"""
|
|
@@ -210,7 +239,8 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
210
239
|
"foo",
|
|
211
240
|
"json",
|
|
212
241
|
1,
|
|
213
|
-
"foo"
|
|
242
|
+
"foo",
|
|
243
|
+
"iso"
|
|
214
244
|
)
|
|
215
245
|
self.assertIn('{"failed": []}', new_stdout.getvalue())
|
|
216
246
|
|
|
@@ -219,7 +249,7 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
219
249
|
A test of the extract reference string function.
|
|
220
250
|
"""
|
|
221
251
|
self.assertEqual(coguard_cli.extract_reference_string(
|
|
222
|
-
{}
|
|
252
|
+
{}
|
|
223
253
|
), "")
|
|
224
254
|
|
|
225
255
|
def extract_reference_string_test_non_trivial_dicts(self):
|
|
@@ -227,42 +257,30 @@ class TestCommonFunctions(unittest.TestCase):
|
|
|
227
257
|
A test of the extract reference string function.
|
|
228
258
|
"""
|
|
229
259
|
self.assertEqual(coguard_cli.extract_reference_string(
|
|
230
|
-
{"service": "foo"
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
), " (affected files: bar/foo.txt for service foo)")
|
|
260
|
+
{"service": "foo",
|
|
261
|
+
"fromLine": 0,
|
|
262
|
+
"toLine": 1,
|
|
263
|
+
"config_file": {
|
|
264
|
+
"fileName": "krb5.conf",
|
|
265
|
+
"subPath": ".",
|
|
266
|
+
"configFileType": "krb"
|
|
267
|
+
}}
|
|
268
|
+
), " (affected files: ./krb5.conf)")
|
|
247
269
|
|
|
248
|
-
def
|
|
270
|
+
def extract_reference_string_test_non_trivial_dicts_and_lines(self):
|
|
249
271
|
"""
|
|
250
272
|
A test of the extract reference string function.
|
|
251
273
|
"""
|
|
252
274
|
self.assertEqual(coguard_cli.extract_reference_string(
|
|
253
|
-
{"service": "foo"
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
), " (affected files: bar/foo.txt for service foo)")
|
|
275
|
+
{"service": "foo",
|
|
276
|
+
"fromLine": 2,
|
|
277
|
+
"toLine": 5,
|
|
278
|
+
"config_file": {
|
|
279
|
+
"fileName": "krb5.conf",
|
|
280
|
+
"subPath": ".",
|
|
281
|
+
"configFileType": "krb"
|
|
282
|
+
}}
|
|
283
|
+
), " (affected files: ./krb5.conf, 2-5)")
|
|
266
284
|
|
|
267
285
|
def test_apply_fixes_to_folder(self):
|
|
268
286
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/cloud_discovery/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finder_abc.py
RENAMED
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finder_factory.py
RENAMED
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/discovery/config_file_finders/__init__.py
RENAMED
|
File without changes
|
|
@@ -8,10 +8,10 @@ import re
|
|
|
8
8
|
import logging
|
|
9
9
|
from typing import Dict, List, Optional, Tuple
|
|
10
10
|
import yaml
|
|
11
|
+
from flatten_dict import unflatten
|
|
11
12
|
from coguard_cli.discovery.config_file_finder_abc import ConfigFileFinder
|
|
12
13
|
import coguard_cli.discovery.config_file_finders as cff_util
|
|
13
14
|
from coguard_cli.print_colors import COLOR_CYAN, COLOR_TERMINATION
|
|
14
|
-
from flatten_dict import unflatten
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class ConfigFileFinderAnsible(ConfigFileFinder):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/auth/common_auth_function_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/ci_cd/ci_cd_provider_factory_test.py
RENAMED
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/ci_cd/ci_cd_providers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/cluster_rule_fail_util_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/folder_scan/common_functions_test.py
RENAMED
|
File without changes
|
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/image_check/common_functions_test.py
RENAMED
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/image_check/docker_dao_test.py
RENAMED
|
File without changes
|
{coguard_cli-0.2.44 → coguard_cli-0.2.45}/src/coguard_cli/tests/output_generators/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|