9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/stratagem/client.rb', line 9
def send(snapshot)
Stratagem.logger.debug "Sending report to server"
url = URI.parse("#{@authentication.base_url}/snapshots")
req = Net::HTTPS::Post.new(url.path)
req.set_form_data({
'auth_token' => @authentication.credentials[:token],
'project_id' => @authentication.credentials[:project],
'timestamp' => snapshot.timestamp.to_i,
'model' => snapshot.model.export.to_json
}, ';')
res = Net::HTTPS.new(url.host, url.port).start {|http| http.request(req) }
puts "response:"
case res
when Net::HTTPSuccess, Net::HTTPRedirection
puts "Visit #{@authentication.base_url} for your security posture."
else
res.error!
end
Stratagem.logger.phase('complete')
end
|