kube_auto_analyzer 0.0.15 → 0.0.16
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/config_dumper.rb +24 -0
- data/lib/kube_auto_analyzer/reporting.rb +128 -121
- data/lib/kube_auto_analyzer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c660dfe01e6def5a3b1dd095f7adaabb69d008969cc74a324cdfd70dc0dcf6b0
|
4
|
+
data.tar.gz: 53caa82754a21d6f5f999edb74c9220581b19a2d8eaf3fa9c33614506dd0cbfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbb9fb819e5bc084e46f02326984968117a0b735aeac4e0f2719990f80214510f3faeaccc5c634fbf22397d7c4f831d80de23deb075bdecd9199e63bc1c6351b
|
7
|
+
data.tar.gz: 5aada0ec4b8d64e05b665c105faef30502c34bfcc7d2902a10624fd8abb5d429faa985ca278a26e8c7bc1db2991b5aafdf731ae245c1f38129f53bff870564ba
|
@@ -5,6 +5,7 @@ module KubeAutoAnalyzer
|
|
5
5
|
@log.debug("dumping the config for #{target}")
|
6
6
|
@results[target][:config] = Hash.new
|
7
7
|
pods = @client.get_pods
|
8
|
+
services = @client.get_services
|
8
9
|
docker_images = Array.new
|
9
10
|
#Specific requirement here in that it's useful to know what Docker images are in use on the cluster.
|
10
11
|
pods.each do |pod|
|
@@ -26,5 +27,28 @@ module KubeAutoAnalyzer
|
|
26
27
|
@results[target][:config][:pod_info] << currpod
|
27
28
|
end
|
28
29
|
|
30
|
+
@results[target][:config][:service_info] = Array.new
|
31
|
+
|
32
|
+
services.each do |service|
|
33
|
+
currserv = Hash.new
|
34
|
+
currserv[:name] = service.metadata[:name]
|
35
|
+
currserv[:cluster_ip] = service.spec[:clusterIP]
|
36
|
+
if service.spec[:externalIP]
|
37
|
+
currserv[:external_ip] = service.spec[:externalIP]
|
38
|
+
else
|
39
|
+
currserv[:external_ip] = "None"
|
40
|
+
end
|
41
|
+
if service.spec[:ports]
|
42
|
+
currserv[:ports] = Array.new
|
43
|
+
service.spec[:ports].each do |port|
|
44
|
+
currserv[:ports] << "#{port[:port]}/#{port[:protocol]}:#{port[:targetPort]}/#{port[:protocol]}"
|
45
|
+
end
|
46
|
+
else
|
47
|
+
currserv[:ports] = "None"
|
48
|
+
end
|
49
|
+
@results[target][:config][:service_info] << currserv
|
50
|
+
end
|
51
|
+
|
52
|
+
|
29
53
|
end
|
30
54
|
end
|
@@ -188,129 +188,10 @@ module KubeAutoAnalyzer
|
|
188
188
|
@html_report_file.puts "<tr><td>#{test}</td><td>#{result}</td></tr>"
|
189
189
|
end
|
190
190
|
@html_report_file.puts "</table>"
|
191
|
-
|
192
|
-
#Show what cluster authentication modes are supported.
|
193
|
-
@html_report_file.puts "<br><br>"
|
194
|
-
@html_report_file.puts "<br><br><h2>Kubernetes Authentication Options</h2>"
|
195
|
-
@html_report_file.puts "<table><thead><tr><th>Authentication Option</th><th>Enabled?</th></tr></thead>"
|
196
|
-
if @results[@options.target_server]['api_server']['CIS 1.1.2 - Ensure that the --basic-auth-file argument is not set'] == "Fail"
|
197
|
-
@html_report_file.puts "<tr><td>Basic Authentication</td><td>Enabled</td></tr>"
|
198
|
-
else
|
199
|
-
@html_report_file.puts "<tr><td>Basic Authentication</td><td>Disabled</td></tr>"
|
200
|
-
end
|
201
|
-
if @results[@options.target_server]['api_server']['CIS 1.1.20 - Ensure that the --token-auth-file argument is not set'] == "Fail"
|
202
|
-
@html_report_file.puts "<tr><td>Token Authentication</td><td>Enabled</td></tr>"
|
203
|
-
else
|
204
|
-
@html_report_file.puts "<tr><td>Token Authentication</td><td>Disabled</td></tr>"
|
205
|
-
end
|
206
|
-
if @results[@options.target_server]['api_server']['CIS 1.1.29 - Ensure that the --client-ca-file argument is set as appropriate'] == "Pass"
|
207
|
-
@html_report_file.puts "<tr><td>Client Certificate Authentication</td><td>Enabled</td></tr>"
|
208
|
-
else
|
209
|
-
@html_report_file.puts "<tr><td>Client Certificate Authentication</td><td>Disabled</td></tr>"
|
210
|
-
end
|
211
|
-
|
212
|
-
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--oidc-issuer-url/}
|
213
|
-
@html_report_file.puts "<tr><td>OpenID Connect Authentication</td><td>Enabled</td></tr>"
|
214
|
-
else
|
215
|
-
@html_report_file.puts "<tr><td>OpenID Connect Authentication</td><td>Disabled</td></tr>"
|
216
|
-
end
|
217
|
-
|
218
|
-
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authentication-token-webhook-config-file/}
|
219
|
-
@html_report_file.puts "<tr><td>Webhook Authentication</td><td>Enabled</td></tr>"
|
220
|
-
else
|
221
|
-
@html_report_file.puts "<tr><td>Webhook Authentication</td><td>Disabled</td></tr>"
|
222
|
-
end
|
223
|
-
|
224
|
-
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--requestheader-username-headers/}
|
225
|
-
@html_report_file.puts "<tr><td>Proxy Authentication</td><td>Enabled</td></tr>"
|
226
|
-
else
|
227
|
-
@html_report_file.puts "<tr><td>Proxy Authentication</td><td>Disabled</td></tr>"
|
228
|
-
end
|
229
|
-
|
230
|
-
@html_report_file.puts "</table>"
|
231
|
-
|
232
|
-
#Show what cluster authorization modes are supported.
|
233
|
-
@html_report_file.puts "<br><br>"
|
234
|
-
@html_report_file.puts "<br><br><h2>Kubernetes Authorization Options</h2>"
|
235
|
-
@html_report_file.puts "<table><thead><tr><th>Authorization Option</th><th>Enabled?</th></tr></thead>"
|
236
|
-
|
237
|
-
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authorization-mode\S*RBAC/}
|
238
|
-
@html_report_file.puts "<tr><td>Role Based Authorization</td><td>Enabled</td></tr>"
|
239
|
-
else
|
240
|
-
@html_report_file.puts "<tr><td>Role Based Authorization</td><td>Disabled</td></tr>"
|
241
|
-
end
|
242
|
-
|
243
|
-
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authorization-mode\S*ABAC/}
|
244
|
-
@html_report_file.puts "<tr><td>Attribute Based Authorization</td><td>Enabled</td></tr>"
|
245
|
-
else
|
246
|
-
@html_report_file.puts "<tr><td>Attribute Based Authorization</td><td>Disabled</td></tr>"
|
247
|
-
end
|
248
|
-
|
249
|
-
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authorization-mode\S*Webhook/}
|
250
|
-
@html_report_file.puts "<tr><td>Webhook Authorization</td><td>Enabled</td></tr>"
|
251
|
-
else
|
252
|
-
@html_report_file.puts "<tr><td>Webhook Authorization</td><td>Disabled</td></tr>"
|
253
|
-
end
|
254
|
-
|
255
|
-
@html_report_file.puts "</table>"
|
256
|
-
|
257
|
-
@html_report_file.puts "<br><br><h2>Evidence</h2><br>"
|
258
|
-
@html_report_file.puts "<table><thead><tr><th>Area</th><th>Output</th></tr></thead>"
|
259
|
-
@results[@options.target_server]['evidence'].each do |area, output|
|
260
|
-
@html_report_file.puts "<tr><td>#{area}</td><td>#{output}</td></tr>"
|
261
|
-
end
|
262
|
-
@html_report_file.puts "</table>"
|
263
|
-
|
264
|
-
#Only show this section if we were asked to dump the config
|
265
|
-
if @options.dump_config
|
266
|
-
@html_report_file.puts "<br><br>"
|
267
|
-
@html_report_file.puts "<br><br><h2>Cluster Config Information</h2>"
|
268
|
-
@html_report_file.puts "<table><thead><tr><th>Docker Images In Use</th></tr></thead>"
|
269
|
-
@results[@options.target_server][:config][:docker_images].each do |image|
|
270
|
-
@html_report_file.puts "<tr><td>#{image}</td></tr>"
|
271
|
-
end
|
272
|
-
@html_report_file.puts "</table>"
|
273
|
-
@html_report_file.puts "<br><br>"
|
274
|
-
@html_report_file.puts "<table><thead><tr><th>Pod Name</th><th>Namespace</th><th>Service Account</th><th>Host IP</th><th>Pod IP</th></tr></thead>"
|
275
|
-
@results[@options.target_server][:config][:pod_info].each do |pod|
|
276
|
-
@html_report_file.puts "<tr><td>#{pod[:name]}</td><td>#{pod[:namespace]}</td><td>#{pod[:service_account]}</td><td>#{pod[:host_ip]}</td><td>#{pod[:pod_ip]}</td></tr>"
|
277
|
-
end
|
278
|
-
@html_report_file.puts "</table>"
|
279
|
-
@html_report_file.puts "<br><br>"
|
280
|
-
end
|
281
|
-
|
282
|
-
#Only show this section if we were asked to dump RBAC
|
283
|
-
if @options.audit_rbac
|
284
|
-
@html_report_file.puts "<br><br>"
|
285
|
-
@html_report_file.puts "<br><br><h2>Cluster Role Information</h2>"
|
286
|
-
@html_report_file.puts "<table><thead><tr><th>Name</th><th>Default?</th><th>Subjects</th><th>Rules</th></tr></thead>"
|
287
|
-
@results[@options.target_server][:rbac][:cluster_roles].each do |name, info|
|
288
|
-
subjects = ''
|
289
|
-
info[:subjects].each do |subject|
|
290
|
-
subjects << "#{subject[:kind]}:#{subject[:namespace]}:#{subject[:name]}<br>"
|
291
|
-
end
|
292
|
-
rules = ''
|
293
|
-
info[:rules].each do |rule|
|
294
|
-
unless rule.verbs
|
295
|
-
rule.verbs = Array.new
|
296
|
-
end
|
297
|
-
unless rule.apiGroups
|
298
|
-
rule.apiGroups = Array.new
|
299
|
-
end
|
300
|
-
unless rule.resources
|
301
|
-
rule.resources = Array.new
|
302
|
-
end
|
303
|
-
rules << "Verbs : #{rule.verbs.join(', ')}<br>API Groups : #{rule.apiGroups.join(', ')}<br>Resources : #{rule.resources.join(', ')}<br><hr>"
|
304
|
-
end
|
305
|
-
@html_report_file.puts "<tr><td>#{name}</td><td>#{info[:default]}</td><td>#{subjects}</td><td>#{rules}</td></tr>"
|
306
|
-
end
|
307
|
-
@html_report_file.puts "</table>"
|
308
|
-
@html_report_file.puts "<br><br>"
|
309
|
-
end
|
310
|
-
|
311
|
-
|
312
191
|
#Close the master Node Div
|
313
192
|
@html_report_file.puts "</table></div>"
|
193
|
+
|
194
|
+
|
314
195
|
if @options.agent_checks
|
315
196
|
@html_report_file.puts '<br><br><div class="worker-node"><h2>Worker Node Results</h2>'
|
316
197
|
|
@@ -493,6 +374,132 @@ module KubeAutoAnalyzer
|
|
493
374
|
|
494
375
|
@html_report_file.puts "</table>"
|
495
376
|
|
377
|
+
#Show what cluster authentication modes are supported.
|
378
|
+
@html_report_file.puts "<br><br><h1>Kubernetes Cluster Information</h1>"
|
379
|
+
@html_report_file.puts "<br><br><h2>Kubernetes Authentication Options</h2>"
|
380
|
+
@html_report_file.puts "<table><thead><tr><th>Authentication Option</th><th>Enabled?</th></tr></thead>"
|
381
|
+
if @results[@options.target_server]['api_server']['CIS 1.1.2 - Ensure that the --basic-auth-file argument is not set'] == "Fail"
|
382
|
+
@html_report_file.puts "<tr><td>Basic Authentication</td><td>Enabled</td></tr>"
|
383
|
+
else
|
384
|
+
@html_report_file.puts "<tr><td>Basic Authentication</td><td>Disabled</td></tr>"
|
385
|
+
end
|
386
|
+
if @results[@options.target_server]['api_server']['CIS 1.1.20 - Ensure that the --token-auth-file argument is not set'] == "Fail"
|
387
|
+
@html_report_file.puts "<tr><td>Token Authentication</td><td>Enabled</td></tr>"
|
388
|
+
else
|
389
|
+
@html_report_file.puts "<tr><td>Token Authentication</td><td>Disabled</td></tr>"
|
390
|
+
end
|
391
|
+
if @results[@options.target_server]['api_server']['CIS 1.1.29 - Ensure that the --client-ca-file argument is set as appropriate'] == "Pass"
|
392
|
+
@html_report_file.puts "<tr><td>Client Certificate Authentication</td><td>Enabled</td></tr>"
|
393
|
+
else
|
394
|
+
@html_report_file.puts "<tr><td>Client Certificate Authentication</td><td>Disabled</td></tr>"
|
395
|
+
end
|
396
|
+
|
397
|
+
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--oidc-issuer-url/}
|
398
|
+
@html_report_file.puts "<tr><td>OpenID Connect Authentication</td><td>Enabled</td></tr>"
|
399
|
+
else
|
400
|
+
@html_report_file.puts "<tr><td>OpenID Connect Authentication</td><td>Disabled</td></tr>"
|
401
|
+
end
|
402
|
+
|
403
|
+
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authentication-token-webhook-config-file/}
|
404
|
+
@html_report_file.puts "<tr><td>Webhook Authentication</td><td>Enabled</td></tr>"
|
405
|
+
else
|
406
|
+
@html_report_file.puts "<tr><td>Webhook Authentication</td><td>Disabled</td></tr>"
|
407
|
+
end
|
408
|
+
|
409
|
+
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--requestheader-username-headers/}
|
410
|
+
@html_report_file.puts "<tr><td>Proxy Authentication</td><td>Enabled</td></tr>"
|
411
|
+
else
|
412
|
+
@html_report_file.puts "<tr><td>Proxy Authentication</td><td>Disabled</td></tr>"
|
413
|
+
end
|
414
|
+
|
415
|
+
@html_report_file.puts "</table>"
|
416
|
+
|
417
|
+
#Show what cluster authorization modes are supported.
|
418
|
+
@html_report_file.puts "<br><br>"
|
419
|
+
@html_report_file.puts "<br><br><h2>Kubernetes Authorization Options</h2>"
|
420
|
+
@html_report_file.puts "<table><thead><tr><th>Authorization Option</th><th>Enabled?</th></tr></thead>"
|
421
|
+
|
422
|
+
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authorization-mode\S*RBAC/}
|
423
|
+
@html_report_file.puts "<tr><td>Role Based Authorization</td><td>Enabled</td></tr>"
|
424
|
+
else
|
425
|
+
@html_report_file.puts "<tr><td>Role Based Authorization</td><td>Disabled</td></tr>"
|
426
|
+
end
|
427
|
+
|
428
|
+
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authorization-mode\S*ABAC/}
|
429
|
+
@html_report_file.puts "<tr><td>Attribute Based Authorization</td><td>Enabled</td></tr>"
|
430
|
+
else
|
431
|
+
@html_report_file.puts "<tr><td>Attribute Based Authorization</td><td>Disabled</td></tr>"
|
432
|
+
end
|
433
|
+
|
434
|
+
if @results[@options.target_server]['evidence']['API Server'].index{|line| line =~ /--authorization-mode\S*Webhook/}
|
435
|
+
@html_report_file.puts "<tr><td>Webhook Authorization</td><td>Enabled</td></tr>"
|
436
|
+
else
|
437
|
+
@html_report_file.puts "<tr><td>Webhook Authorization</td><td>Disabled</td></tr>"
|
438
|
+
end
|
439
|
+
|
440
|
+
@html_report_file.puts "</table>"
|
441
|
+
|
442
|
+
@html_report_file.puts "<br><br><h2>Evidence</h2><br>"
|
443
|
+
@html_report_file.puts "<table><thead><tr><th>Area</th><th>Output</th></tr></thead>"
|
444
|
+
@results[@options.target_server]['evidence'].each do |area, output|
|
445
|
+
@html_report_file.puts "<tr><td>#{area}</td><td>#{output}</td></tr>"
|
446
|
+
end
|
447
|
+
@html_report_file.puts "</table>"
|
448
|
+
|
449
|
+
#Only show this section if we were asked to dump the config
|
450
|
+
if @options.dump_config
|
451
|
+
@html_report_file.puts "<br><br>"
|
452
|
+
@html_report_file.puts "<br><br><h2>Cluster Config Information</h2>"
|
453
|
+
@html_report_file.puts "<table><thead><tr><th>Docker Images In Use</th></tr></thead>"
|
454
|
+
@results[@options.target_server][:config][:docker_images].each do |image|
|
455
|
+
@html_report_file.puts "<tr><td>#{image}</td></tr>"
|
456
|
+
end
|
457
|
+
@html_report_file.puts "</table>"
|
458
|
+
@html_report_file.puts "<br><br>"
|
459
|
+
@html_report_file.puts "<table><thead><tr><th>Pod Name</th><th>Namespace</th><th>Service Account</th><th>Host IP</th><th>Pod IP</th></tr></thead>"
|
460
|
+
@results[@options.target_server][:config][:pod_info].each do |pod|
|
461
|
+
@html_report_file.puts "<tr><td>#{pod[:name]}</td><td>#{pod[:namespace]}</td><td>#{pod[:service_account]}</td><td>#{pod[:host_ip]}</td><td>#{pod[:pod_ip]}</td></tr>"
|
462
|
+
end
|
463
|
+
@html_report_file.puts "</table>"
|
464
|
+
@html_report_file.puts "<br><br>"
|
465
|
+
@html_report_file.puts "<br><br>"
|
466
|
+
@html_report_file.puts "<table><thead><tr><th>Service Name</th><th>Cluster IP</th><th>External IP</th><th>Port:Target Port</th></tr></thead>"
|
467
|
+
@results[@options.target_server][:config][:service_info].each do |service|
|
468
|
+
|
469
|
+
@html_report_file.puts "<tr><td>#{service[:name]}</td><td>#{service[:cluster_ip]}</td><td>#{service[:external_ip]}</td><td>#{service[:ports].join('<br>')}</td></tr>"
|
470
|
+
end
|
471
|
+
@html_report_file.puts "</table>"
|
472
|
+
@html_report_file.puts "<br><br>"
|
473
|
+
end
|
474
|
+
|
475
|
+
#Only show this section if we were asked to dump RBAC
|
476
|
+
if @options.audit_rbac
|
477
|
+
@html_report_file.puts "<br><br>"
|
478
|
+
@html_report_file.puts "<br><br><h2>Cluster Role Information</h2>"
|
479
|
+
@html_report_file.puts "<table><thead><tr><th>Name</th><th>Default?</th><th>Subjects</th><th>Rules</th></tr></thead>"
|
480
|
+
@results[@options.target_server][:rbac][:cluster_roles].each do |name, info|
|
481
|
+
subjects = ''
|
482
|
+
info[:subjects].each do |subject|
|
483
|
+
subjects << "#{subject[:kind]}:#{subject[:namespace]}:#{subject[:name]}<br>"
|
484
|
+
end
|
485
|
+
rules = ''
|
486
|
+
info[:rules].each do |rule|
|
487
|
+
unless rule.verbs
|
488
|
+
rule.verbs = Array.new
|
489
|
+
end
|
490
|
+
unless rule.apiGroups
|
491
|
+
rule.apiGroups = Array.new
|
492
|
+
end
|
493
|
+
unless rule.resources
|
494
|
+
rule.resources = Array.new
|
495
|
+
end
|
496
|
+
rules << "Verbs : #{rule.verbs.join(', ')}<br>API Groups : #{rule.apiGroups.join(', ')}<br>Resources : #{rule.resources.join(', ')}<br><hr>"
|
497
|
+
end
|
498
|
+
@html_report_file.puts "<tr><td>#{name}</td><td>#{info[:default]}</td><td>#{subjects}</td><td>#{rules}</td></tr>"
|
499
|
+
end
|
500
|
+
@html_report_file.puts "</table>"
|
501
|
+
@html_report_file.puts "<br><br>"
|
502
|
+
end
|
496
503
|
|
497
504
|
#Closing the report off
|
498
505
|
@html_report_file.puts '</body></html>'
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rory McCune
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|