Skip to content

Instantly share code, notes, and snippets.

@dwbutler
Last active December 14, 2015 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwbutler/172159577b268edb5239 to your computer and use it in GitHub Desktop.
Save dwbutler/172159577b268edb5239 to your computer and use it in GitHub Desktop.
Appcanary gem interface
require 'appcanary'
Appcanary.configure do |config|
config.api_key = ENV['APPCANARY_API_KEY']
end
# Explicitly specify language and file
Appcanary.check(language: :ruby, file: 'Gemfile.lock')
# Autodetect Ruby as the language and Gemfile.lock as the file
Appcanary.check
# A normal response would be wrapped in a Hashie::Mash
# Any error would raise an exception with the error object in the message
@phillmv
Copy link

phillmv commented Dec 13, 2015

Suggestion:

Appcanary.api_key = ENV['APPCANARY_API_KEY']

begin
  Appcanary.vulnerable? 
  # => false, Hashie

  Appcanary.vulnerable?("Gemfile.lock", :env => :ruby)
rescue OhNoTheNetworkIsDown => e
  # or whatever the appropriate exception is
end

@dwbutler
Copy link
Author

I like it. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment