Browse Source

New output format

aeris 1 year ago
parent
commit
fd47d21390
2 changed files with 7 additions and 41 deletions
  1. 6
    34
      app/workers/check_worker.rb
  2. 1
    7
      app/workers/https_worker.rb

+ 6
- 34
app/workers/check_worker.rb View File

@@ -3,32 +3,14 @@ class CheckWorker
3 3
 	sidekiq_options retry: false
4 4
 
5 5
 	def key_to_json(key)
6
-		key.nil? ? nil : { type: key.type, size: key.size, rsa_size: key.rsa_equivalent_size }
6
+		key.nil? ? nil : { type: key.type, size: key.size }
7 7
 	end
8 8
 
9 9
 	def perform(host, port=nil)
10
-		host   = SimpleIDN.to_ascii host.downcase
11
-		hosts  = self.analyze *(port ? [host, port] : [host])
12
-		hosts  = hosts.collect do |host, result|
13
-			name, ip, p = host
14
-			host           = { name: name, ip: ip, port: p }
15
-
16
-			if result.is_a? CryptCheck::AnalysisFailure
17
-				next {
18
-						host:  host,
19
-						error: result.to_s
20
-				}
21
-			end
22
-
23
-			grade  = result
24
-			server = grade.server
25
-			{
26
-					host:      host,
27
-					handshake: to_json(server),
28
-					grade: grade_to_json(grade)
29
-			}
30
-		end
31
-		result = { date: DateTime.now, hosts: hosts }
10
+		host          = SimpleIDN.to_ascii host.downcase
11
+		result        = self.analyze *(port ? [host, port] : [host])
12
+		result        = result.to_h
13
+		result[:date] = DateTime.now
32 14
 		Datastore.post self.type, host, port, result
33 15
 	end
34 16
 
@@ -46,17 +28,7 @@ class CheckWorker
46 28
 	private
47 29
 	def grade_to_json(grade)
48 30
 		{
49
-				rank:    grade.grade,
50
-				details: {
51
-						score:            grade.score,
52
-						protocol:         grade.protocol_score,
53
-						key_exchange:     grade.key_exchange_score,
54
-						cipher_strengths: grade.cipher_strengths_score
55
-				},
56
-				error:   grade.error,
57
-				danger:  grade.danger,
58
-				warning: grade.warning,
59
-				success: grade.success
31
+				rank: grade.grade,
60 32
 		}
61 33
 	end
62 34
 end

+ 1
- 7
app/workers/https_worker.rb View File

@@ -3,16 +3,10 @@ class HTTPSWorker < CheckWorker
3 3
 
4 4
 	protected
5 5
 	def analyze(host, port=443)
6
-		CryptCheck::Tls::Https.analyze host, port
6
+		CryptCheck::Tls::Https::Host.new host, port
7 7
 	end
8 8
 
9 9
 	def type
10 10
 		:https
11 11
 	end
12
-
13
-	def to_json(server)
14
-		result = super
15
-		result[:hsts] = server.hsts
16
-		result
17
-	end
18 12
 end

Loading…
Cancel
Save