Skip to content

Commit

Permalink
fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jeniawhite committed Nov 5, 2023
1 parent 295d18f commit b3670fd
Showing 1 changed file with 41 additions and 12 deletions.
53 changes: 41 additions & 12 deletions tests/integration/tests/test_sanity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@
"project-management",
"data-processing",
],
"cis_azure": ["configuration"], # Azure environment is not static, so we can't guarantee findings of all types.
"cis_azure": [
"configuration"
], # Azure environment is not static, so we can't guarantee findings of all types.
"cis_k8s": ["file", "process", "k8s_object"],
"cis_eks": ["process", "k8s_object"], # Optimize search findings by excluding 'file'.
"cis_eks": [
"process",
"k8s_object",
], # Optimize search findings by excluding 'file'.
"cnvm": ["vulnerability"],
}

Expand All @@ -56,8 +61,13 @@ def test_kspm_unmanaged_findings(kspm_client, match_type):
Raises:
AssertionError: If the resource type is missing.
"""
query_list = [{"term": {"rule.benchmark.id": "cis_k8s"}}, {"term": {"resource.type": match_type}}]
query, sort = kspm_client.build_es_must_match_query(must_query_list=query_list, time_range="now-4h")
query_list = [
{"term": {"rule.benchmark.id": "cis_k8s"}},
{"term": {"resource.type": match_type}},
]
query, sort = kspm_client.build_es_must_match_query(
must_query_list=query_list, time_range="now-4h"
)

result = get_findings(kspm_client, CONFIG_TIMEOUT, query, sort, match_type)
assert len(result) > 0, f"The resource type '{match_type}' is missing"
Expand All @@ -79,8 +89,13 @@ def test_kspm_e_k_s_findings(kspm_client, match_type):
Raises:
AssertionError: If the resource type is missing.
"""
query_list = [{"term": {"rule.benchmark.id": "cis_eks"}}, {"term": {"resource.type": match_type}}]
query, sort = kspm_client.build_es_must_match_query(must_query_list=query_list, time_range="now-4h")
query_list = [
{"term": {"rule.benchmark.id": "cis_eks"}},
{"term": {"resource.type": match_type}},
]
query, sort = kspm_client.build_es_must_match_query(
must_query_list=query_list, time_range="now-4h"
)

results = get_findings(kspm_client, CONFIG_TIMEOUT, query, sort, match_type)
assert len(results) > 0, f"The resource type '{match_type}' is missing"
Expand All @@ -102,8 +117,13 @@ def test_cspm_findings(cspm_client, match_type):
Raises:
AssertionError: If the resource type is missing.
"""
query_list = [{"term": {"rule.benchmark.id": "cis_aws"}}, {"term": {"resource.type": match_type}}]
query, sort = cspm_client.build_es_must_match_query(must_query_list=query_list, time_range="now-24h")
query_list = [
{"term": {"rule.benchmark.id": "cis_aws"}},
{"term": {"resource.type": match_type}},
]
query, sort = cspm_client.build_es_must_match_query(
must_query_list=query_list, time_range="now-24h"
)

results = get_findings(cspm_client, CONFIG_TIMEOUT, query, sort, match_type)
assert len(results) > 0, f"The resource type '{match_type}' is missing"
Expand All @@ -126,7 +146,9 @@ def test_cnvm_findings(cnvm_client, match_type):
AssertionError: If the resource type is missing.
"""
query_list = []
query, sort = cnvm_client.build_es_must_match_query(must_query_list=query_list, time_range="now-24h")
query, sort = cnvm_client.build_es_must_match_query(
must_query_list=query_list, time_range="now-24h"
)
results = get_findings(cnvm_client, CNVM_CONFIG_TIMEOUT, query, sort, match_type)
assert len(results) > 0, f"The resource type '{match_type}' is missing"

Expand All @@ -147,8 +169,13 @@ def test_cspm_gcp_findings(cspm_client, match_type):
Raises:
AssertionError: If the resource type is missing.
"""
query_list = [{"term": {"rule.benchmark.id": "cis_gcp"}}, {"term": {"resource.type": match_type}}]
query, sort = cspm_client.build_es_must_match_query(must_query_list=query_list, time_range="now-24h")
query_list = [
{"term": {"rule.benchmark.id": "cis_gcp"}},
{"term": {"resource.type": match_type}},
]
query, sort = cspm_client.build_es_must_match_query(
must_query_list=query_list, time_range="now-24h"
)

results = get_findings(cspm_client, GCP_CONFIG_TIMEOUT, query, sort, match_type)
assert len(results) > 0, f"The resource type '{match_type}' is missing"
Expand All @@ -171,7 +198,9 @@ def test_cspm_azure_findings(cspm_client, match_type):
AssertionError: If the resource type is missing.
"""
query_list = [{"term": {"rule.benchmark.id": "cis_azure"}}]
query, sort = cspm_client.build_es_must_match_query(must_query_list=query_list, time_range="now-24h")
query, sort = cspm_client.build_es_must_match_query(
must_query_list=query_list, time_range="now-24h"
)

results = get_findings(cspm_client, CONFIG_TIMEOUT, query, sort, match_type)
assert len(results) > 0, f"The resource type '{match_type}' is missing"

0 comments on commit b3670fd

Please sign in to comment.