Metadata
Ruby 2.6.0 Rails 5.2.2.1 PostgreSQL SemanticUI NGINX Phusion passenger
Contents
Navigate to /machines to see our inventory.
The data on this page includes plenty of information:
You can also perform these actions:
Navigate to /uri_entries to see our data from Cyberadapt's network logs.
This data is pulled from Cyberadapt's repository of our internet traffic. In the log it has IP, URI, and how many times visited, and we combine it with other information to make it more insightful.
You can perform these actions:
The Cyberadapt logs are typically massive and we don't want to log all the traffic to conserve space and aid us better in response by filtering away the extra garbage. The Cyberadapt whitelist gets rid of some of the data that we don't care about/is doubled in Carbon black response.
Create a whitelist entry, which is just a regular expression in Ruby, and it will not save the entry if the URI for the entry matches the regular expression. Example:
# Any local IP address is not logged
/192\.168\./(\d+)\.(\d+)/
Before you create or edit one, you should test it first with rubular or with IRB.
You can edit, delete, or create new whitelist rules. When you add a whitelist rule, it will run it against everything currently in the database and remove matching entries.
The FS-ISAC threat feed is heavily populated with emails that will not affect our enterprise. Instead of sifting through manually of what does/doesn't affect us, the whitelist allows us to immediately classify certain emails as not relevant to the enterprise.
When we get an email with the title "IBM blah blah blah" we already know it won't affect us, so we use a ruby regex that automatically classifies the email as "does not apply". Here's an abstraction of what happens basically:
whitelist = /IBM/
whitelist.match? email.title
And if the whitelist matches the email title, it marks the email as does not apply.
You can edit, create, and delete whitelist entries.
The FS-ISAC threat feed is demuxed into a JSON object which is piped into our database so we can use the information for patching and other cybersec purposes. The emails are retrieved from reporting@flexibleplan.com through a forwarding rule.
You can see a subset of information by viewing them in the table, but click on their IDs to see all their information:
You can edit part of the alert but not everything, as a lot of it is directly from FS-ISAC, and should be readonly. You can mark an alert as resolved and mark it as "doesn't apply".
Additional actions include the option to download as a CSV and the more important "pull new alerts" button, which makes an API request to get new alert emails from reporting@flexibleplan.com.
Uploading logs is actually one of the features that, if more development efforts can be pushed, should be completely phased out. At the time of development, I wasn't aware of the APIs that we had access to so we did everything manually and wasted a lot of man-hours and the solution was still worse.
Avoid these features if you can, they are suboptimal
*Please read this first*
Quite simply, this log is how we determine a machine's IP address for /machines. You can get a Carbon Black log by going to Carbon Black defense -> Logging in -> Endpoints -> CSV export. This log is what gets dropped in, and we use that to create our inventory and our DHCP log.
THIS FEATURE IS DEPRECATED, DON'T USE IT
THIS FEATURE IS NOT COMPLETED, DON'T USE IT
Unfortunately, when creating Snitch we were not concerned with a proper development cycle so there's not much documentation on what has to happen or how I accomplished what I did. But this is my best effort to explain everything so at the very least you can reinvent the wheel (better than before) because there were a lot of paths taken that shouldn't have been, but I wasn't aware of them at the time.
General notes:
/lib
folder and put it in /app
. Most Rails devs
see that as better.Under the hood, the Cyberadapt model is actually called
UriEntries
. When you call CyberAdaptSftpClient#get_missing
, you:
PaperTrail
tableString
if I
remember correctly; this doesn't really matter though, the next
step takes care of it anywaysOnce you have this array, each element should be passed into
CyberAdaptLog#new
, which
UriEntries
To get FS-ISAC alerts, we have a rather complicated process but it works really well.
Viewpoint
that
authenticates us to the Exchange serverFsIsacMailClient
FsIsacMailParser
, turning it into a
ruby hashThere are some important details to consider:
secrets.yml
because that's the
only way we can authenticate. Details on this later.Hopefully you should never have to do this but it's possible if restructuring occurs. There's really nothing special here, it's your standard deployment with Rails.
cap production deploy
ssh server-name
bash /home/flexibleplan/var/www/snitch/new_release.sh
cap production deploy
ssh server-name
cd /wherever/you/put/the/app/from/capistrano # it's more than likely /var/www or /home/deploy/var/www/...
rvm use ruby-X.X.X
bundle install --deployment --without development test
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
RAILS_ENV=production
may be deprecated by the time you read this. You may want to change it to whatever's the new waypassenger-config restart-app $(pwd)
Everything you need to know will be on Kanboard for this topic. I have recurring tasks that will automatically repopulate once completed.