Commit 5bb4239
Changed files (5)
app
controllers
agents
workers
lib
tasks
app/controllers/agents/files_controller.rb
@@ -12,7 +12,7 @@ module Agents
@file = Disposition.find_by(fingerprint: params[:id])
Publisher.publish("queries", {
fingerprint: params[:id],
- data: params
+ payload: params[:payload]
})
end
app/workers/cloud_queries.rb
@@ -7,13 +7,14 @@ class CloudQueries
def work(json)
logger.info "Query for: #{json.inspect}"
attributes = JSON.parse(json)
- fingerprint = attributes["fingerprint"]
- disposition = Disposition.find_by(fingerprint: fingerprint)
- if disposition.present?
- logger.info("#{disposition.state} disposition for: #{fingerprint}")
- else
- logger.info("Unknown disposition for: #{fingerprint}")
- end
+ #fingerprint = attributes["fingerprint"]
+ #disposition = Disposition.find_by(fingerprint: fingerprint)
+
+ #if disposition.present?
+ #logger.info("#{disposition.state} disposition for: #{fingerprint}")
+ #else
+ #logger.info("Unknown disposition for: #{fingerprint}")
+ #end
ack!
end
lib/tasks/scan.rake
@@ -7,10 +7,15 @@ namespace :scan do
Dir['**/**/*'].each do |file|
if File.file?(file)
result = `shasum -a 256 #{file}`
- sha = result.split(' ').first
+ sha, * = result.split(' ')
+ full_path = File.expand_path(file)
- uri = URI("http://localhost:3000/agents/#{agent.id}/files/#{sha}")
- puts [sha, Net::HTTP.get(uri)].inspect
+ url = "http://localhost:3000/agents/#{agent.id}/files/#{sha}"
+ Typhoeus.get(url, body: {
+ payload: {
+ full_path: full_path
+ }
+ })
end
end
end
Gemfile
@@ -23,6 +23,7 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'typhoeus'
+gem 'listen'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
Gemfile.lock
@@ -47,6 +47,8 @@ GEM
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
+ celluloid (0.16.0)
+ timers (~> 4.0.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
@@ -72,6 +74,7 @@ GEM
globalid (0.3.0)
activesupport (>= 4.1.0)
hike (1.2.3)
+ hitimes (1.2.2)
i18n (0.7.0)
jbuilder (2.2.6)
activesupport (>= 3.0.0, < 5)
@@ -81,6 +84,10 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.2)
+ listen (2.8.5)
+ celluloid (>= 0.15.2)
+ rb-fsevent (>= 0.9.3)
+ rb-inotify (>= 0.9)
loofah (2.0.1)
nokogiri (>= 1.5.9)
mail (2.6.3)
@@ -120,6 +127,9 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
+ rb-fsevent (0.9.4)
+ rb-inotify (0.9.5)
+ ffi (>= 0.5.0)
rdoc (4.2.0)
sass (3.4.11)
sass-rails (5.0.1)
@@ -154,6 +164,8 @@ GEM
thread (0.1.4)
thread_safe (0.3.4)
tilt (1.4.1)
+ timers (4.0.1)
+ hitimes
turbolinks (2.5.3)
coffee-rails
typhoeus (0.7.1)
@@ -180,6 +192,7 @@ DEPENDENCIES
foundation-rails
jbuilder (~> 2.0)
jquery-rails
+ listen
pg
rails (= 4.2.0)
sass-rails (~> 5.0)