kube_auto_analyzer 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kube_auto_analyzer/api_checks/master_node.rb +30 -6
- data/lib/kube_auto_analyzer/reporting.rb +24 -0
- data/lib/kube_auto_analyzer/utility/network.rb +2 -0
- data/lib/kube_auto_analyzer/version.rb +2 -2
- data/lib/kube_auto_analyzer/vuln_checks/amicontained.rb +50 -0
- data/lib/kube_auto_analyzer.rb +2 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0356e457db66e2456e2a1aec7b6c26324690279
|
4
|
+
data.tar.gz: 4850a960a8827606b9f1f180fafd3aa992b705d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7efa8ea0b79bf980ad966e75ec5dd309277fec0eb1a3f4ec17e29ebca0bfb9e122b75015850c24fb15e1f2bbffa2f3139e0c161f7bbd9a21860bf6b1c4bfd59
|
7
|
+
data.tar.gz: e296498d5128895ef21e6c11515cc1071c248629ff6d4d4a43078ff4dfd44d7e0ea97beeac2ef2f52f9ba2815d831afbdde5bcd94cd04c0828fbae23434100de
|
@@ -219,6 +219,24 @@ module KubeAutoAnalyzer
|
|
219
219
|
@results[target]['api_server']['CIS 1.1.31 - Ensure that the --etcd-cafile argument is set as appropriate'] = "Pass"
|
220
220
|
end
|
221
221
|
|
222
|
+
unless api_server_command_line.index{|line| line =~ /--authorization-mode\S*Node/}
|
223
|
+
@results[target]['api_server']['CIS 1.1.32 - Ensure that the --authorization-mode argument is set to Node'] = "Fail"
|
224
|
+
else
|
225
|
+
@results[target]['api_server']['CIS 1.1.32 - Ensure that the --authorization-mode argument is set to Node'] = "Pass"
|
226
|
+
end
|
227
|
+
|
228
|
+
unless api_server_command_line.index{|line| line =~ /--admission-control\S*NodeRestriction/}
|
229
|
+
@results[target]['api_server']['CIS 1.1.33 - Ensure that the admission control policy is set to NodeRestriction'] = "Fail"
|
230
|
+
else
|
231
|
+
@results[target]['api_server']['CIS 1.1.33 - Ensure that the admission control policy is set to NodeRestriction'] = "Pass"
|
232
|
+
end
|
233
|
+
|
234
|
+
unless api_server_command_line.index{|line| line =~ /--experimental-encryption-provider-config/}
|
235
|
+
@results[target]['api_server']['CIS 1.1.34 - Ensure that the --experimental-encryption-provider-config argument is set as appropriate'] = "Fail"
|
236
|
+
else
|
237
|
+
@results[target]['api_server']['CIS 1.1.34 - Ensure that the --experimental-encryption-provider-config argument is set as appropriate'] = "Pass"
|
238
|
+
end
|
239
|
+
|
222
240
|
@results[target]['evidence']['API Server'] = api_server_command_line
|
223
241
|
end
|
224
242
|
|
@@ -286,21 +304,27 @@ module KubeAutoAnalyzer
|
|
286
304
|
end
|
287
305
|
|
288
306
|
unless controller_manager_command_line.index{|line| line =~ /--use-service-account-credentials=true/}
|
289
|
-
@results[target]['controller_manager']['CIS 1.3.
|
307
|
+
@results[target]['controller_manager']['CIS 1.3.3 - Ensure that the --use-service-account-credentials argument is set to true'] = "Fail"
|
290
308
|
else
|
291
|
-
@results[target]['controller_manager']['CIS 1.3.
|
309
|
+
@results[target]['controller_manager']['CIS 1.3.3 - Ensure that the --use-service-account-credentials argument is set to true'] = "Pass"
|
292
310
|
end
|
293
311
|
|
294
312
|
unless controller_manager_command_line.index{|line| line =~ /--service-account-private-key-file/}
|
295
|
-
@results[target]['controller_manager']['CIS 1.3.
|
313
|
+
@results[target]['controller_manager']['CIS 1.3.4 - Ensure that the --service-account-private-key-file argument is set as appropriate'] = "Fail"
|
296
314
|
else
|
297
|
-
@results[target]['controller_manager']['CIS 1.3.
|
315
|
+
@results[target]['controller_manager']['CIS 1.3.4 - Ensure that the --service-account-private-key-file argument is set as appropriate'] = "Pass"
|
298
316
|
end
|
299
317
|
|
300
318
|
unless controller_manager_command_line.index{|line| line =~ /--root-ca-file/}
|
301
|
-
@results[target]['controller_manager']['CIS 1.3.
|
319
|
+
@results[target]['controller_manager']['CIS 1.3.5 - Ensure that the --root-ca-file argument is set as appropriate'] = "Fail"
|
320
|
+
else
|
321
|
+
@results[target]['controller_manager']['CIS 1.3.5 - Ensure that the --root-ca-file argument is set as appropriate'] = "Pass"
|
322
|
+
end
|
323
|
+
|
324
|
+
unless controller_manager_command_line.index{|line| line =~ /RotateKubeletServerCertificate=true/}
|
325
|
+
@results[target]['controller_manager']['CIS 1.3.7 - Ensure that the RotateKubeletServerCertificate argument is set to true'] = "Fail"
|
302
326
|
else
|
303
|
-
@results[target]['controller_manager']['CIS 1.3.
|
327
|
+
@results[target]['controller_manager']['CIS 1.3.7 - Ensure that the RotateKubeletServerCertificate argument is set to true'] = "Pass"
|
304
328
|
end
|
305
329
|
|
306
330
|
@results[target]['evidence']['Controller Manager'] = controller_manager_command_line
|
@@ -270,6 +270,24 @@ module KubeAutoAnalyzer
|
|
270
270
|
@html_report_file.puts "</table>"
|
271
271
|
end
|
272
272
|
|
273
|
+
if @options.agent_checks
|
274
|
+
@html_report_file.puts '<br><h3>Container Configuration checks</h3>'
|
275
|
+
@results[@options.target_server]['vulns']['amicontained'].each do |node, result|
|
276
|
+
@html_report_file.puts "<br><b>#{node} Container Checks</b>"
|
277
|
+
@html_report_file.puts "<table><thead><tr><th>Container item</th><th>Result</th></thead>"
|
278
|
+
@html_report_file.puts "<tr><td>Runtime in Use</td><td>#{result['runtime']}</td></tr>"
|
279
|
+
@html_report_file.puts "<tr><td>Host PID namespace used?</td><td>#{result['hostpid']}</td></tr>"
|
280
|
+
@html_report_file.puts "<tr><td>AppArmor Profile</td><td>#{result['apparmor']}</td></tr>"
|
281
|
+
@html_report_file.puts "<tr><td>User Namespaces in use?</td><td>#{result['uid_map']}</td></tr>"
|
282
|
+
@html_report_file.puts "<tr><td>Inherited Capabilities</td><td>#{result['cap_inh']}</td></tr>"
|
283
|
+
@html_report_file.puts "<tr><td>Effective Capabilities</td><td>#{result['cap_eff']}</td></tr>"
|
284
|
+
@html_report_file.puts "<tr><td>Permitted Capabilities</td><td>#{result['cap_per']}</td></tr>"
|
285
|
+
@html_report_file.puts "<tr><td>Bounded Capabilities</td><td>#{result['cap_bnd']}</td></tr>"
|
286
|
+
@html_report_file.puts "</table>"
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
|
273
291
|
|
274
292
|
|
275
293
|
@html_report_file.puts "<br><br><h2>Vulnerability Evidence</h2><br>"
|
@@ -295,6 +313,12 @@ module KubeAutoAnalyzer
|
|
295
313
|
@html_report_file.puts "<tr><td>Default Service Token In Use</td><td>#{node}</td><td>#{result}</td></tr>"
|
296
314
|
end
|
297
315
|
end
|
316
|
+
if @options.agent_checks
|
317
|
+
@results[@options.target_server]['vulns']['amicontained'].each do |node, result|
|
318
|
+
@html_report_file.puts "<tr><td>Am I Contained Output</td><td>#{node}</td><td>#{result}</td></tr>"
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
298
322
|
@html_report_file.puts "</table>"
|
299
323
|
|
300
324
|
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module KubeAutoAnalyzer
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.4"
|
3
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module KubeAutoAnalyzer
|
2
|
+
|
3
|
+
#This is somewhat awkward placement. Deployment mechanism sits more with the agent checks
|
4
|
+
#But from a "what it's looking for" perspective, its more with the vuln. checks as there's not a CIS check for it.
|
5
|
+
def self.check_amicontained
|
6
|
+
require 'json'
|
7
|
+
@log.debug("Doing Am I contained check")
|
8
|
+
target = @options.target_server
|
9
|
+
@results[target]['vulns']['amicontained'] = Hash.new
|
10
|
+
|
11
|
+
nodes = Array.new
|
12
|
+
@client.get_nodes.each do |node|
|
13
|
+
unless node.spec.taints.to_s =~ /NoSchedule/
|
14
|
+
nodes << node
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
nodes.each do |nod|
|
19
|
+
node_hostname = nod.metadata.labels['kubernetes.io/hostname']
|
20
|
+
node_ip = nod['status']['addresses'][0]['address']
|
21
|
+
container_name = "kaa" + node_hostname
|
22
|
+
pod = Kubeclient::Resource.new
|
23
|
+
pod.metadata = {}
|
24
|
+
pod.metadata.name = container_name
|
25
|
+
pod.metadata.namespace = "default"
|
26
|
+
pod.spec = {}
|
27
|
+
pod.spec.restartPolicy = "Never"
|
28
|
+
pod.spec.containers = {}
|
29
|
+
pod.spec.containers = [{name: "kubeautoanalyzerkubelettest", image: "raesene/kaa-agent:latest"}]
|
30
|
+
pod.spec.containers[0].args = ["/amicontained.rb"]
|
31
|
+
pod.spec.nodeselector = {}
|
32
|
+
pod.spec.nodeselector['kubernetes.io/hostname'] = node_hostname
|
33
|
+
begin
|
34
|
+
@log.debug("About to start amicontained pod")
|
35
|
+
@client.create_pod(pod)
|
36
|
+
@log.debug("Executed the create pod")
|
37
|
+
begin
|
38
|
+
sleep(5) until @client.get_pod(container_name,"default")['status']['containerStatuses'][0]['state']['terminated']['reason'] == "Completed"
|
39
|
+
rescue
|
40
|
+
retry
|
41
|
+
end
|
42
|
+
@log.debug ("started amicontained pod")
|
43
|
+
results = JSON.parse(@client.get_pod_log(container_name,"default"))
|
44
|
+
@results[target]['vulns']['amicontained'][node_ip] = results
|
45
|
+
ensure
|
46
|
+
@client.delete_pod(container_name,"default")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/kube_auto_analyzer.rb
CHANGED
@@ -8,6 +8,7 @@ module KubeAutoAnalyzer
|
|
8
8
|
require "kube_auto_analyzer/vuln_checks/kubelet"
|
9
9
|
require "kube_auto_analyzer/vuln_checks/api_server"
|
10
10
|
require "kube_auto_analyzer/vuln_checks/service_token"
|
11
|
+
require "kube_auto_analyzer/vuln_checks/amicontained"
|
11
12
|
require "kube_auto_analyzer/utility/network"
|
12
13
|
|
13
14
|
|
@@ -93,6 +94,7 @@ module KubeAutoAnalyzer
|
|
93
94
|
test_service_token_internal
|
94
95
|
check_files
|
95
96
|
check_kubelet_process
|
97
|
+
check_amicontained
|
96
98
|
end
|
97
99
|
html_report
|
98
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kube_auto_analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rory McCune
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/kube_auto_analyzer/reporting.rb
|
73
73
|
- lib/kube_auto_analyzer/utility/network.rb
|
74
74
|
- lib/kube_auto_analyzer/version.rb
|
75
|
+
- lib/kube_auto_analyzer/vuln_checks/amicontained.rb
|
75
76
|
- lib/kube_auto_analyzer/vuln_checks/api_server.rb
|
76
77
|
- lib/kube_auto_analyzer/vuln_checks/kubelet.rb
|
77
78
|
- lib/kube_auto_analyzer/vuln_checks/service_token.rb
|
@@ -95,10 +96,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
98
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.4.8
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: A Gem which provides a script and class analyze the security of a Kubernetes
|
102
103
|
cluster.
|
103
104
|
test_files: []
|
104
|
-
has_rdoc:
|