Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YAML to Markdown conversion script and generated Markdown files #497

Merged
merged 46 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
691af86
initial version of cis hardening reference
eaudetcobello Jun 14, 2024
bffb2d2
replace variable
eaudetcobello Jun 14, 2024
ae1a04a
add expected output to each control
eaudetcobello Jun 15, 2024
4f52fc7
add newline before audit
eaudetcobello Jun 15, 2024
1910950
remove newline from top of file
eaudetcobello Jun 15, 2024
058e22f
add cis yaml to markdown script
eaudetcobello Jun 15, 2024
9c6386b
change usage and run isort
eaudetcobello Jun 15, 2024
010e5b4
move file logic out of generate_markdown
eaudetcobello Jun 15, 2024
e778872
remove $DATA_DIR subst
eaudetcobello Jun 15, 2024
dd39725
revert changing $data_dir in the files
eaudetcobello Jun 15, 2024
4b5140c
add markdownlint-disable to template
eaudetcobello Jun 15, 2024
c01dc9f
each control is anchored for easy reference
eaudetcobello Jun 15, 2024
7c6bd6f
remove bold from id because it is part of a title now
eaudetcobello Jun 15, 2024
ecf9ddf
Update cis-yaml-to-md.py
eaudetcobello Jun 15, 2024
602ab7e
update type hint
eaudetcobello Jun 17, 2024
9d2aa63
use proper current directory
eaudetcobello Jun 20, 2024
99c2c6a
add spacing to template file
eaudetcobello Jun 20, 2024
c5a59a1
wordwrap description and add spacing
eaudetcobello Jun 20, 2024
78fdc62
Merge branch 'main' into cis-hardening-docs-2
eaudetcobello Jun 20, 2024
e00833a
use global var
eaudetcobello Jun 20, 2024
ed244db
add expected outputs from node.md
eaudetcobello Jun 20, 2024
c490de6
controlplane.md and etcd.md in expected-outputs
eaudetcobello Jun 20, 2024
30b9450
add master.md to expected-outputs
eaudetcobello Jun 20, 2024
e192998
change expected-outputs file format
eaudetcobello Jun 21, 2024
f827577
refactor cis-yaml-to-md.py and cis-template.jinja2
eaudetcobello Jun 21, 2024
dd683a3
add default to custom output
eaudetcobello Jun 21, 2024
6d8bd3b
generate docs
eaudetcobello Jun 21, 2024
62e9b2b
change empty output to TODO for now
eaudetcobello Jun 21, 2024
267dffd
move cis output to _parts
eaudetcobello Jun 25, 2024
ad16e1f
modify expected outputs of etcd controls
eaudetcobello Jun 26, 2024
6479818
more accurate expected outputs
eaudetcobello Jun 27, 2024
7c4dfaf
reorder fields, change code blocks to normal text
eaudetcobello Jun 27, 2024
5c83175
output to _parts/cis
eaudetcobello Jun 27, 2024
08e7af9
delete files from howto/cis-hardening
eaudetcobello Jun 27, 2024
f743969
don't say "not applicable" and re-generate
eaudetcobello Jun 27, 2024
756a014
fix double newlines
eaudetcobello Jun 27, 2024
081cd0d
improve description
eaudetcobello Jun 27, 2024
16cf932
s/pod specification/configuration
eaudetcobello Jun 27, 2024
eaa3dc1
re-generate after modifying kube-bench etcd.yaml
eaudetcobello Jun 27, 2024
1585060
re-generate with kube-bench changes
eaudetcobello Jun 27, 2024
aa13351
improve formatting in node.md
eaudetcobello Jun 27, 2024
8354b8e
re-generate following major wording rework
eaudetcobello Jun 27, 2024
eec027f
re-generate after improving etcd.md format
eaudetcobello Jun 27, 2024
1ffd8cb
re-generate after small changes in master and node yamls
eaudetcobello Jun 27, 2024
11353c2
add readme and requirements file
eaudetcobello Jun 27, 2024
b37d55d
improve readme
eaudetcobello Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/src/snap/howto/cis-hardening/controlplane.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!-- markdownlint-disable -->
## Control Plane Configuration
### Authentication and Authorization
eaudetcobello marked this conversation as resolved.
Show resolved Hide resolved
#### Control 3.1.1

Description: `Client certificate authentication should not be used for users (Manual)`

Remediation:
```
Alternative mechanisms provided by Kubernetes such as the use of OIDC should be
implemented in place of client certificates.
```

### Logging
#### Control 3.2.1

Description: `Ensure that a minimal audit policy is created (Manual)`

Audit:
```
/bin/ps -ef | grep kube-apiserver | grep -v grep
```

Remediation:
```
Create an audit policy file for your cluster.
```

Expected output:
```
test_items:
- flag: --audit-policy-file
set: true
```

#### Control 3.2.2

Description: `Ensure that the audit policy covers key security concerns (Manual)`

Remediation:
```
Review the audit policy provided for the cluster and ensure that it covers
at least the following areas,
- Access to Secrets managed by the cluster. Care should be taken to only
log Metadata for requests to Secrets, ConfigMaps, and TokenReviews, in
order to avoid risk of logging sensitive data.
- Modification of Pod and Deployment objects.
- Use of `pods/exec`, `pods/portforward`, `pods/proxy` and `services/proxy`.
For most requests, minimally logging at the Metadata level is recommended
(the most basic level of logging).
```

198 changes: 198 additions & 0 deletions docs/src/snap/howto/cis-hardening/etcd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<!-- markdownlint-disable -->
## Etcd Node Configuration
### Etcd Node Configuration
eaudetcobello marked this conversation as resolved.
Show resolved Hide resolved
#### Control 2.1

Description: `Ensure that the --cert-file and --key-file arguments are set as appropriate (Automated)`

Audit:
```
/bin/ps -ef | /bin/grep etcd | /bin/grep -v grep
```

Remediation:
```
Follow the etcd service documentation and configure TLS encryption.
eaudetcobello marked this conversation as resolved.
Show resolved Hide resolved
Then, edit the etcd pod specification file /etc/kubernetes/manifests/etcd.yaml
on the master node and set the below parameters.
--cert-file=</path/to/ca-file>
--key-file=</path/to/key-file>
```

Expected output:
```
bin_op: and
test_items:
- env: ETCD_CERT_FILE
flag: --cert-file
- env: ETCD_KEY_FILE
flag: --key-file
```

#### Control 2.2

Description: `Ensure that the --client-cert-auth argument is set to true (Automated)`

Audit:
```
/bin/ps -ef | /bin/grep etcd | /bin/grep -v grep
```

Remediation:
```
Edit the etcd pod specification file /etc/default/etcd on the master
node and set the below parameter.
--client-cert-auth="true"
```

Expected output:
```
test_items:
- compare:
op: eq
value: true
env: ETCD_CLIENT_CERT_AUTH
flag: --client-cert-auth
```

#### Control 2.3

Description: `Ensure that the --auto-tls argument is not set to true (Automated)`

Audit:
```
/bin/ps -ef | /bin/grep etcd | /bin/grep -v grep
```

Remediation:
```
Edit the etcd pod specification file /etc/default/etcd on the master
node and either remove the --auto-tls parameter or set it to false.
--auto-tls=false
```

Expected output:
```
bin_op: or
test_items:
- env: ETCD_AUTO_TLS
flag: --auto-tls
set: false
- compare:
op: eq
value: false
env: ETCD_AUTO_TLS
flag: --auto-tls
```

#### Control 2.4

Description: `Ensure that the --peer-cert-file and --peer-key-file arguments are set as appropriate (Automated)`

Audit:
```
/bin/ps -ef | /bin/grep etcd | /bin/grep -v grep
```

Remediation:
```
Follow the etcd service documentation and configure peer TLS encryption as appropriate
for your etcd cluster.
Then, edit the etcd pod specification file /etc/default/etcd on the
master node and set the below parameters.
--peer-client-file=</path/to/peer-cert-file>
--peer-key-file=</path/to/peer-key-file>
```

Expected output:
```
bin_op: and
test_items:
- env: ETCD_PEER_CERT_FILE
flag: --peer-cert-file
- env: ETCD_PEER_KEY_FILE
flag: --peer-key-file
```

#### Control 2.5

Description: `Ensure that the --peer-client-cert-auth argument is set to true (Automated)`

Audit:
```
/bin/ps -ef | /bin/grep etcd | /bin/grep -v grep
```

Remediation:
```
Edit the etcd pod specification file /etc/default/etcd on the master
node and set the below parameter.
--peer-client-cert-auth=true
```

Expected output:
```
test_items:
- compare:
op: eq
value: true
env: ETCD_PEER_CLIENT_CERT_AUTH
flag: --peer-client-cert-auth
```

#### Control 2.6

Description: `Ensure that the --peer-auto-tls argument is not set to true (Automated)`

Audit:
```
/bin/ps -ef | /bin/grep etcd | /bin/grep -v grep
```

Remediation:
```
Edit the etcd pod specification file /etc/default/etcd on the master
node and either remove the --peer-auto-tls parameter or set it to false.
--peer-auto-tls=false
```

Expected output:
```
bin_op: or
test_items:
- env: ETCD_PEER_AUTO_TLS
flag: --peer-auto-tls
set: false
- compare:
op: eq
value: false
env: ETCD_PEER_AUTO_TLS
flag: --peer-auto-tls
```

#### Control 2.7

Description: `Ensure that a unique Certificate Authority is used for etcd (Manual)`

Audit:
```
/bin/ps -ef | /bin/grep etcd | /bin/grep -v grep
```

Remediation:
```
[Manual test]
Follow the etcd documentation and create a dedicated certificate authority setup for the
etcd service.
Then, edit the etcd pod specification file /etc/default/etcd on the
master node and set the below parameter.
--trusted-ca-file=</path/to/ca-file>
```

Expected output:
```
test_items:
- env: ETCD_TRUSTED_CA_FILE
flag: --trusted-ca-file
```

Loading
Loading