kube_auto_analyzer 0.0.2 → 0.0.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d00aa23fd9d10f06f08ca8dbb0ce90f4ebe4418
|
4
|
+
data.tar.gz: 20b0155fa55984544566af728ea62ef13ddab85d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fed5d88cdf8af7f495462bfe3432708861946d6fe19e21b8bd1c546a90cc20e01fbd9da88a02711fe15fd3c82ae7f84c8c9fd5b86ac371c2962efd7edaf6abf
|
7
|
+
data.tar.gz: d9b66e719e362dc057cd50b078c8a82fd7cff214e7bb0f474a3abe003088e1b6140eac1b7f899d411052d67ed14ee00c5c6135fc10e5b6a9f444837022f7afeb
|
@@ -51,7 +51,6 @@ module KubeAutoAnalyzer
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.html_report
|
54
|
-
base_report = File.open(@report_file_name + '.txt','r').read
|
55
54
|
logo_path = File.join(__dir__, "data-logo.b64")
|
56
55
|
logo = File.open(logo_path).read
|
57
56
|
@log.debug("Starting HTML Report")
|
@@ -257,6 +256,20 @@ module KubeAutoAnalyzer
|
|
257
256
|
@html_report_file.puts "</table>"
|
258
257
|
end
|
259
258
|
|
259
|
+
if @options.agent_checks
|
260
|
+
@html_report_file.puts '<br><h3>Default Service Token In Use</h3>'
|
261
|
+
@html_report_file.puts "<table><thead><tr><th>API endpoint</th><th>Result</th></thead>"
|
262
|
+
@results[@options.target_server]['vulns']['service_token'].each do |node, result|
|
263
|
+
unless (result =~ /Forbidden/ || result =~ /Not Open/)
|
264
|
+
output = "Vulnerable"
|
265
|
+
else
|
266
|
+
output = result
|
267
|
+
end
|
268
|
+
@html_report_file.puts "<tr><td>#{node}</td><td>#{output}</td></tr>"
|
269
|
+
end
|
270
|
+
@html_report_file.puts "</table>"
|
271
|
+
end
|
272
|
+
|
260
273
|
|
261
274
|
|
262
275
|
@html_report_file.puts "<br><br><h2>Vulnerability Evidence</h2><br>"
|
@@ -277,6 +290,11 @@ module KubeAutoAnalyzer
|
|
277
290
|
@html_report_file.puts "<tr><td>Internal Insecure API Server Access</td><td>#{node}</td><td>#{result}</td></tr>"
|
278
291
|
end
|
279
292
|
end
|
293
|
+
if @options.agent_checks
|
294
|
+
@results[@options.target_server]['vulns']['service_token'].each do |node, result|
|
295
|
+
@html_report_file.puts "<tr><td>Default Service Token In Use</td><td>#{node}</td><td>#{result}</td></tr>"
|
296
|
+
end
|
297
|
+
end
|
280
298
|
@html_report_file.puts "</table>"
|
281
299
|
|
282
300
|
|
@@ -0,0 +1,40 @@
|
|
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, as a weakness in Kubelet, it makes more sense here.
|
5
|
+
def self.test_service_token_internal
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
@log.debug("Doing the internal Service Token check")
|
9
|
+
target = @options.target_server
|
10
|
+
@results[target]['vulns']['service_token'] = Hash.new
|
11
|
+
api_server_url = @client.api_endpoint.to_s
|
12
|
+
container_name = "kaakubeletunauthtest"
|
13
|
+
pod = Kubeclient::Resource.new
|
14
|
+
pod.metadata = {}
|
15
|
+
pod.metadata.name = container_name
|
16
|
+
pod.metadata.namespace = "default"
|
17
|
+
pod.spec = {}
|
18
|
+
pod.spec.restartPolicy = "Never"
|
19
|
+
pod.spec.containers = {}
|
20
|
+
pod.spec.containers = [{name: "kubeautoanalyzerservicetokentest", image: "raesene/kaa-agent:latest"}]
|
21
|
+
pod.spec.containers[0].args = ["/service-token-checker.rb",api_server_url]
|
22
|
+
begin
|
23
|
+
@log.debug("About to start Service Token Check pod")
|
24
|
+
@client.create_pod(pod)
|
25
|
+
@log.debug("Executed the create pod")
|
26
|
+
begin
|
27
|
+
sleep(5) until @client.get_pod(container_name,"default")['status']['containerStatuses'][0]['state']['terminated']['reason'] == "Completed"
|
28
|
+
rescue
|
29
|
+
retry
|
30
|
+
end
|
31
|
+
@log.debug ("started Service Token Check pod")
|
32
|
+
results = JSON.parse(@client.get_pod_log(container_name,"default"))
|
33
|
+
results.each do |node, results|
|
34
|
+
@results[target]['vulns']['service_token'][api_server_url] = results
|
35
|
+
end
|
36
|
+
ensure
|
37
|
+
@client.delete_pod(container_name,"default")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/kube_auto_analyzer.rb
CHANGED
@@ -7,6 +7,7 @@ module KubeAutoAnalyzer
|
|
7
7
|
require "kube_auto_analyzer/agent_checks/process_checks"
|
8
8
|
require "kube_auto_analyzer/vuln_checks/kubelet"
|
9
9
|
require "kube_auto_analyzer/vuln_checks/api_server"
|
10
|
+
require "kube_auto_analyzer/vuln_checks/service_token"
|
10
11
|
require "kube_auto_analyzer/utility/network"
|
11
12
|
|
12
13
|
|
@@ -31,7 +32,8 @@ module KubeAutoAnalyzer
|
|
31
32
|
@log.debug("Target API Server is " + @options.target_server)
|
32
33
|
|
33
34
|
@report_file_name = @base_dir + '/' + @options.report_file
|
34
|
-
|
35
|
+
#Remove the Text report for now as we're not using this option
|
36
|
+
#@report_file = File.new(@report_file_name + '.txt','w+')
|
35
37
|
@html_report_file = File.new(@report_file_name + '.html','w+')
|
36
38
|
@log.debug("New Report File created #{@report_file_name}")
|
37
39
|
|
@@ -88,6 +90,7 @@ module KubeAutoAnalyzer
|
|
88
90
|
if @options.agent_checks
|
89
91
|
test_unauth_kubelet_internal
|
90
92
|
test_insecure_api_internal
|
93
|
+
test_service_token_internal
|
91
94
|
check_files
|
92
95
|
check_kubelet_process
|
93
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rory McCune
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- lib/kube_auto_analyzer/version.rb
|
75
75
|
- lib/kube_auto_analyzer/vuln_checks/api_server.rb
|
76
76
|
- lib/kube_auto_analyzer/vuln_checks/kubelet.rb
|
77
|
+
- lib/kube_auto_analyzer/vuln_checks/service_token.rb
|
77
78
|
homepage: https://github.com/nccgroup/kube-auto-analyzer
|
78
79
|
licenses:
|
79
80
|
- AGPL
|