Skip to content

Commit 583e602

Browse files
committed
(WIP) Test: Verify if secrets are encrypted
1 parent 6924e10 commit 583e602

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed

RATIONALE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,6 @@ closing watches for ConfigMaps marked as immutable.*"
381381
382382
#### *Check if Tiller is being used on the plaform*: [Tiller images](docs/LIST_OF_TESTS.md#tiller-images)
383383
> *Tiller, found in Helm v2, has known security challenges. It requires administrative privileges and acts as a shared resource accessible to any authenticated user. Tiller can lead to privilege escalation as restricted users can impact other users. It is recommend to use Helm v3+ which does not contain Tiller for these reasons
384+
385+
#### *Check if secrets are encrypted on the plaform*: [Kubescape secret/etcd](docs/LIST_OF_TESTS.md#kubescape-secret-etcd)
386+
> *Secret encryption is not enabled by default in kubernetes environment. As secrets contains sensitive information, it is recommended to encrypt these values. For encrypting secret in etcd, we are using encryption in rest, this will cause, that there wont be secret key value in plain text format anymore in etcd.

USAGE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,3 +1395,17 @@ Switch to using Helm v3+ and make sure not to pull any images with name tiller i
13951395
</b>
13961396

13971397

1398+
## [Kubescape secret/etcd](docs/LIST_OF_TESTS.md#kubescape-secret-etcd)
1399+
1400+
##### To run the Kubescape secret/etcd test, you can use the following command:
1401+
```
1402+
./cnf-testsuite platform:kubescape_secret_etc
1403+
```
1404+
1405+
<b>Remediation for failing this test: </b>
1406+
1407+
Check version of ETCDCTL in etcd pod, it should be v3.+
1408+
1409+
</b>
1410+
1411+

src/tasks/platform/security.cr

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,6 @@ namespace "platform" do
6464
end
6565
end
6666

67-
desc "Kubescape secret/etcd"
68-
task "kubescape_secret_etcd", ["kubescape_scan"] do |t, args|
69-
next if args.named["offline"]?
70-
71-
CNFManager::Task.task_runner(args, task: t, check_cnf_installed: false) do |args, config|
72-
results_json = Kubescape.parse
73-
test_json = Kubescape.test_by_test_name(results_json, "Secret/etcd encryption enabled")
74-
test_report = Kubescape.parse_test_report(test_json)
75-
76-
if test_report.failed_resources.size == 0
77-
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Passed, "Secret/etcd encryption enabled")
78-
else
79-
test_report.failed_resources.map {|r| stdout_failure(r.alert_message) }
80-
stdout_failure("Remediation: #{test_report.remediation}")
81-
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Failed, "Secret/etcd encryption disabled")
82-
end
83-
end
84-
end
85-
8667
desc "Check if the CNF is running containers with name tiller in their image name?"
8768
task "helm_tiller" do |t, args|
8869
Kyverno.install
@@ -102,4 +83,23 @@ namespace "platform" do
10283
end
10384
end
10485
end
86+
87+
desc "Kubescape secret/etcd"
88+
task "kubescape_secret_etcd", ["kubescape_scan"] do |t, args|
89+
next if args.named["offline"]?
90+
91+
CNFManager::Task.task_runner(args, task: t, check_cnf_installed: false) do |args, config|
92+
results_json = Kubescape.parse
93+
test_json = Kubescape.test_by_test_name(results_json, "Secret/etcd encryption enabled")
94+
test_report = Kubescape.parse_test_report(test_json)
95+
96+
if test_report.failed_resources.size == 0
97+
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Passed, "Secret/etcd encryption enabled")
98+
else
99+
test_report.failed_resources.map {|r| stdout_failure(r.alert_message) }
100+
stdout_failure("Remediation: #{test_report.remediation}")
101+
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Failed, "Secret/etcd encryption disabled")
102+
end
103+
end
104+
end
105105
end

0 commit comments

Comments
 (0)