-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into param-store-check-dec24
- Loading branch information
Showing
20 changed files
with
501 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
checkov/terraform/checks/resource/azure/OpenAICognitiveServicesRestrictOutboundNetwork.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Any, List, Dict | ||
|
||
from checkov.common.models.enums import CheckCategories, CheckResult | ||
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck | ||
|
||
|
||
class OpenAICognitiveServicesRestrictOutboundNetwork(BaseResourceCheck): | ||
def __init__(self): | ||
name = "Ensure that Azure Cognitive Services account hosted with OpenAI is configured with data loss prevention" | ||
id = "CKV_AZURE_247" | ||
supported_resources = ('azurerm_cognitive_account', ) | ||
categories = (CheckCategories.NETWORKING, ) | ||
super().__init__( | ||
name=name, | ||
id=id, | ||
categories=categories, | ||
supported_resources=supported_resources, | ||
) | ||
|
||
def scan_resource_conf(self, conf: Dict[str, List[Any]]) -> CheckResult: | ||
if conf.get("kind", [""])[0].lower() != 'openai': | ||
return CheckResult.PASSED | ||
|
||
outbound_network_access_restricted = conf.get('outbound_network_access_restricted', [None])[0] | ||
fqdns = conf.get('fqdns', [[]])[0] | ||
if not outbound_network_access_restricted or not fqdns: | ||
return CheckResult.FAILED | ||
|
||
return CheckResult.PASSED | ||
|
||
|
||
check = OpenAICognitiveServicesRestrictOutboundNetwork() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
from typing import Any | ||
|
||
import requests | ||
|
||
|
||
class ProxyClient: | ||
def __init__(self) -> None: | ||
self.proxy_ca_path = os.getenv('PROXY_CA_PATH', None) | ||
if self.proxy_ca_path is None: | ||
raise Exception("[ProxyClient] CA certificate path is missing") | ||
|
||
def get_session(self) -> requests.Session: | ||
if not os.getenv('PROXY_URL', None): | ||
raise Exception('Please provide "PROXY_URL" env var') | ||
proxy_url = os.getenv('PROXY_URL') | ||
session = requests.Session() | ||
proxies = { | ||
"http": proxy_url, | ||
"https": proxy_url, | ||
} | ||
session.proxies.update(proxies) # type: ignore | ||
return session | ||
|
||
def send_request(self, request: requests.Request) -> requests.Response: | ||
session = self.get_session() | ||
prepared_request = session.prepare_request(request) | ||
return session.send(prepared_request, verify=self.proxy_ca_path) | ||
|
||
|
||
def call_http_request_with_proxy(request: requests.Request) -> Any: | ||
proxy_client = ProxyClient() | ||
return proxy_client.send_request(request=request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = '3.2.343' | ||
version = '3.2.344' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
checkov==3.2.343 | ||
checkov==3.2.344 |
40 changes: 40 additions & 0 deletions
40
tests/kubernetes/checks/example_NoDefaultNamespace/Dev-PASSED.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: dev | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
namespace: dev | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:latest | ||
ports: | ||
- containerPort: 80 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx-service | ||
namespace: dev | ||
spec: | ||
selector: | ||
app: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 | ||
type: LoadBalancer |
4 changes: 2 additions & 2 deletions
4
tests/kubernetes/graph/checks/resources/AllowPrivilegeEscalation/expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pass: | ||
- 'Pod.default.nginx-ingress-controller-2.app.kubernetes.io/name-ingress-nginx.app.kubernetes.io/part-of-ingress-nginx' | ||
- 'Pod.example-ns.nginx-ingress-controller-2.app.kubernetes.io/name-ingress-nginx.app.kubernetes.io/part-of-ingress-nginx' | ||
fail: | ||
- 'Pod.default.nginx-ingress-controller.app.kubernetes.io/name-ingress-nginx.app.kubernetes.io/part-of-ingress-nginx' | ||
- 'Pod.example-ns.nginx-ingress-controller.app.kubernetes.io/name-ingress-nginx.app.kubernetes.io/part-of-ingress-nginx' |
4 changes: 4 additions & 0 deletions
4
tests/kubernetes/graph/checks/resources/NoDefaultNamespace/expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pass: | ||
- 'Pod.dev.nginx-deployment.app-nginx' | ||
- 'Deployment.dev.nginx-deployment' | ||
- 'Service.dev.nginx-service' |
40 changes: 40 additions & 0 deletions
40
tests/kubernetes/graph/checks/resources/NoDefaultNamespace/template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: dev | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
namespace: dev | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:latest | ||
ports: | ||
- containerPort: 80 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: nginx-service | ||
namespace: dev | ||
spec: | ||
selector: | ||
app: nginx | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 | ||
type: LoadBalancer |
61 changes: 61 additions & 0 deletions
61
tests/kubernetes/graph/checks/test_checks/NoDefaultNamespace.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
metadata: | ||
id: "CKV_K8S_160" | ||
name: "Ensure resources in k8s not in default namespace" | ||
category: "KUBERNETES" | ||
definition: | ||
and: | ||
- cond_type: "attribute" | ||
resource_types: | ||
- "Deployment" | ||
- "StatefulSet" | ||
- "DaemonSet" | ||
- "Job" | ||
- "CronJob" | ||
- "Pod" | ||
- "Service" | ||
- "ConfigMap" | ||
- "Secret" | ||
attribute: "metadata.namespace" | ||
operator: "exists" | ||
- cond_type: "attribute" | ||
resource_types: | ||
- "Deployment" | ||
- "StatefulSet" | ||
- "DaemonSet" | ||
- "Job" | ||
- "CronJob" | ||
- "Pod" | ||
- "Service" | ||
- "ConfigMap" | ||
- "Secret" | ||
attribute: "metadata.namespace" | ||
operator: "not_equals" | ||
value: "default" | ||
- cond_type: "attribute" | ||
resource_types: | ||
- "Deployment" | ||
- "StatefulSet" | ||
- "DaemonSet" | ||
- "Job" | ||
- "CronJob" | ||
- "Pod" | ||
- "Service" | ||
- "ConfigMap" | ||
- "Secret" | ||
attribute: "metadata.namespace" | ||
operator: "not_equals" | ||
value: "kube-system" | ||
- cond_type: "attribute" | ||
resource_types: | ||
- "Deployment" | ||
- "StatefulSet" | ||
- "DaemonSet" | ||
- "Job" | ||
- "CronJob" | ||
- "Pod" | ||
- "Service" | ||
- "ConfigMap" | ||
- "Secret" | ||
attribute: "metadata.namespace" | ||
operator: "not_regex_match" | ||
value: "^kube-.*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.