Skip to content

Commit

Permalink
cluster_logging_operator_exists now handles two APIs
Browse files Browse the repository at this point in the history
Reform rule cluster_logging_operator_exists to check for
existence ClusterlogForwarders from logging and observability APIs.
Adds two rules checking for log forwarding in each API
  • Loading branch information
yuumasato committed Oct 3, 2024
1 parent 6b68bea commit 1fa8af9
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<def-group oval_version="5.11">
<definition class="compliance" id="{{{ rule_id }}}" version="1"> {{{
oval_metadata("Cluster Logging operator is installed and scanning") }}} <criteria
operator="OR">
<extend_definition comment="Ensure clusterlogforwarder object exists"
definition_ref="cluster_logging_operator_exists_observability_api" />
<extend_definition comment="Ensure clusterlogging object exists"
definition_ref="cluster_logging_operator_exists_logging_api" />
</criteria>
</definition>
</def-group>
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,17 @@ references:
ocil_clause: 'OpenShift Logging Operator is not installed'

ocil: |-
Run the following command to retrieve the clusterlogging objects in the system:
<pre>$ oc get clusterloggings --all-namespaces</pre>
Run the following command to retrieve the clusterlogforwarder objects in the system:
<pre>$ oc get clusterlogforwarder --all-namespaces</pre>
Make sure the OpenShift Logging Operator is installed and there exists
at least one active clusterlogging object in the cluster.
at least one active clusterlogforwarder object in the cluster.
severity: medium


warnings:
- general: |-
{{{ openshift_cluster_setting("/apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterloggings/instance") | indent(4) }}}
template:
name: yamlfile_value
vars:
ocp_data: "true"
filepath: /apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterloggings/instance
yamlpath: "metadata.name"
entity_check: "at least one"
values:
- value: ".*"
operation: "pattern match"

{{{ openshift_cluster_setting([
"/apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterloggings/instance",
"/apis/observability.openshift.io/v1/namespaces/openshift-logging/clusterlogforwarders",
]) | indent(4) }}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ yum install -y jq

kube_apipath="/kubernetes-api-resources"

mkdir -p "$kube_apipath/apis/logging.openshift.io/v1/namespaces/openshift-logging/"
mkdir -p "$kube_apipath/apis/observability.openshift.io/v1/namespaces/openshift-logging/"

routes_apipath="/apis/logging.openshift.io/v1/namespaces/openshift-logging/instance"
routes_apipath="/apis/observability.openshift.io/v1/namespaces/openshift-logging/instance"

cat <<EOF > "$kube_apipath$routes_apipath"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,72 @@ yum install -y jq

kube_apipath="/kubernetes-api-resources"

mkdir -p "$kube_apipath/apis/logging.openshift.io/v1/namespaces/openshift-logging/"
mkdir -p "$kube_apipath/apis/observability.openshift.io/v1/namespaces/openshift-logging/"

routes_apipath="/apis/logging.openshift.io/v1/namespaces/openshift-logging/instance"
routes_apipath="/apis/observability.openshift.io/v1/namespaces/openshift-logging/instance"

cat <<EOF > "$kube_apipath$routes_apipath"
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "logging.openshift.io/v1",
"kind": "ClusterLogging",
"apiVersion": "observability.openshift.io/v1",
"kind": "ClusterLogForwarder",
"metadata": {
"creationTimestamp": "2022-04-07T22:31:00Z",
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"observability.openshift.io/v1\",\"kind\":\"ClusterLogForwarder\",\"metadata\":{\"annotations\":{},\"name\":\"instance\",\"namespace\":\"openshift-logging\"},\"spec\":{\"outputs\":[{\"elasticsearch\":{\"index\":\"most-logs\",\"url\":\"https://elasticsearch:9200\",\"version\":6},\"name\":\"default-elasticsearch\",\"type\":\"elasticsearch\"}],\"pipelines\":[{\"inputRefs\":[\"application\",\"audit\",\"infrastructure\"],\"name\":\"most-logs\",\"outputRefs\":[\"default\"]},{\"inputRefs\":[\"audit\"],\"name\":\"audit-logs\",\"outputRefs\":[\"default\"]}],\"serviceAccount\":{\"name\":\"cluster-loggin-operator\"}}}\n"
},
"creationTimestamp": "2024-09-30T15:34:24Z",
"generation": 1,
"name": "instance",
"namespace": "openshift-logging",
"resourceVersion": "16375545",
"uid": "dcc9e26d-934d-4dca-9e88-dcbc6b85c669"
"resourceVersion": "95318",
"uid": "7804fab5-b945-4024-acb7-e89652b5d4f7"
},
"spec": {
"collection": {
"logs": {
"fluentd": {},
"type": "fluentd"
}
},
"curation": {
"curator": {
"schedule": "30 3,9,15,21 * * *"
},
"type": "curator"
},
"logStore": {
"elasticsearch": {
"nodeCount": 1,
"redundancyPolicy": "ZeroRedundancy",
"resources": {
"limits": {
"cpu": "500m",
"memory": "4Gi"
}
},
"storage": {}
},
"type": "elasticsearch"
},
"managementState": "Managed",
"visualization": {
"kibana": {
"replicas": 1
"outputs": [
{
"elasticsearch": {
"index": "most-logs",
"url": "https://elasticsearch:9200",
"version": 6
},
"name": "default-elasticsearch",
"type": "elasticsearch"
}
],
"pipelines": [
{
"inputRefs": [
"application",
"audit",
"infrastructure"
],
"name": "most-logs",
"outputRefs": [
"default"
]
},
"type": "kibana"
}
},
"status": {
"collection": {
"logs": {
"fluentdStatus": {}
{
"inputRefs": [
"audit"
],
"name": "audit-logs",
"outputRefs": [
"default"
]
}
},
"curation": {},
"logStore": {},
"visualization": {}
],
"serviceAccount": {
"name": "cluster-loggin-operator"
}
}
}
],
"kind": "List",
"metadata": {
"resourceVersion": "",
"selfLink": ""
"resourceVersion": ""
}
}
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

title: Ensure that OpenShift Logging Operator is scanning the cluster

description: |-
OpenShift Logging Operator provides ability to aggregate all the logs from the
OpenShift Container Platform cluster, such as node system audit logs, application
container logs, and infrastructure logs. OpenShift Logging aggregates these logs
from throughout OpenShift cluster and stores them in a default log store. [1]
[1]https://docs.openshift.com/container-platform/4.10/logging/cluster-logging.html
rationale: |-
OpenShift Logging Operator is able to collect, aggregate, and manage logs.
identifiers:
cce@ocp4: CCE-86638-4

references:
nist: AU-3(2)
srg: SRG-APP-000092-CTR-000165,SRG-APP-000111-CTR-000220,SRG-APP-000358-CTR-000805

ocil_clause: 'OpenShift Logging Operator is not installed'

ocil: |-
Run the following command to retrieve the clusterlogging objects in the system:
<pre>$ oc get clusterlogging --all-namespaces</pre>
Make sure the OpenShift Logging Operator is installed and there exists
at least one active clusterlogging in the cluster.
severity: medium


warnings:
- general: |-
{{{ openshift_cluster_setting("/apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterloggings/instance") | indent(4) }}}
template:
name: yamlfile_value
vars:
ocp_data: "true"
filepath: /apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterloggings/instance
yamlpath: ".metadata.name"
entity_check: "at least one"
values:
- value: ".*"
operation: "pattern match"

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# remediation = none

yum install -y jq

kube_apipath="/kubernetes-api-resources"

mkdir -p "$kube_apipath/apis/logging.openshift.io/v1/namespaces/openshift-logging/"

routes_apipath="/apis/logging.openshift.io/v1/namespaces/openshift-logging/instance"

cat <<EOF > "$kube_apipath$routes_apipath"
{
"apiVersion": "v1",
"items": [],
"kind": "List",
"metadata": {
"resourceVersion": "",
"selfLink": ""
}
}
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
# remediation = none

yum install -y jq

kube_apipath="/kubernetes-api-resources"

mkdir -p "$kube_apipath/apis/logging.openshift.io/v1/namespaces/openshift-logging/"

routes_apipath="/apis/logging.openshift.io/v1/namespaces/openshift-logging/instance"

cat <<EOF > "$kube_apipath$routes_apipath"
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "observability.openshift.io/v1",
"kind": "ClusterLogForwarder",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"observability.openshift.io/v1\",\"kind\":\"ClusterLogForwarder\",\"metadata\":{\"annotations\":{},\"name\":\"instance\",\"namespace\":\"openshift-logging\"},\"spec\":{\"outputs\":[{\"elasticsearch\":{\"index\":\"most-logs\",\"url\":\"https://elasticsearch:9200\",\"version\":6},\"name\":\"default-elasticsearch\",\"type\":\"elasticsearch\"}],\"pipelines\":[{\"inputRefs\":[\"application\",\"audit\",\"infrastructure\"],\"name\":\"most-logs\",\"outputRefs\":[\"default\"]},{\"inputRefs\":[\"audit\"],\"name\":\"audit-logs\",\"outputRefs\":[\"default\"]}],\"serviceAccount\":{\"name\":\"cluster-loggin-operator\"}}}\n"
},
"creationTimestamp": "2024-09-30T15:34:24Z",
"generation": 1,
"name": "instance",
"namespace": "openshift-logging",
"resourceVersion": "95318",
"uid": "7804fab5-b945-4024-acb7-e89652b5d4f7"
},
"spec": {
"managementState": "Managed",
"outputs": [
{
"elasticsearch": {
"index": "most-logs",
"url": "https://elasticsearch:9200",
"version": 6
},
"name": "default-elasticsearch",
"type": "elasticsearch"
}
],
"pipelines": [
{
"inputRefs": [
"application",
"audit",
"infrastructure"
],
"name": "most-logs",
"outputRefs": [
"default"
]
},
{
"inputRefs": [
"audit"
],
"name": "audit-logs",
"outputRefs": [
"default"
]
}
],
"serviceAccount": {
"name": "cluster-loggin-operator"
}
}
}
],
"kind": "List",
"metadata": {
"resourceVersion": ""
}
}
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
default_result: FAIL
result_after_remediation: PASS
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

title: Ensure that OpenShift Logging Operator is scanning the cluster

description: |-
OpenShift Logging Operator provides ability to aggregate all the logs from the
OpenShift Container Platform cluster, such as node system audit logs, application
container logs, and infrastructure logs. OpenShift Logging aggregates these logs
from throughout OpenShift cluster and stores them in a default log store. [1]
[1]https://docs.openshift.com/container-platform/4.10/logging/cluster-logging.html
rationale: |-
OpenShift Logging Operator is able to collect, aggregate, and manage logs.
identifiers:
cce@ocp4: CCE-86639-2

references:
nist: AU-3(2)
srg: SRG-APP-000092-CTR-000165,SRG-APP-000111-CTR-000220,SRG-APP-000358-CTR-000805

ocil_clause: 'OpenShift Logging Operator is not installed'

ocil: |-
Run the following command to retrieve the clusterlogforwarder objects in the system:
<pre>$ oc get clusterlogforwarder --all-namespaces</pre>
Make sure the OpenShift Logging Operator is installed and there exists
at least one active clusterlogforwarderobject in the cluster.
severity: medium


warnings:
- general: |-
{{{ openshift_cluster_setting("/apis/observability.openshift.io/v1/namespaces/openshift-logging/clusterlogforwarders") | indent(4) }}}
template:
name: yamlfile_value
vars:
ocp_data: "true"
filepath: /apis/observability.openshift.io/v1/namespaces/openshift-logging/clusterlogforwarders
yamlpath: ".items[].metadata.name"
entity_check: "at least one"
values:
- value: ".*"
operation: "pattern match"

Loading

0 comments on commit 1fa8af9

Please sign in to comment.