require 'thor' require 'paraxial' require 'net/http' require 'uri' require 'json' require 'time' module Paraxial class CLI < Thor desc "scan", "Run scan" def scan puts "[Paraxial] Scan NOW" cops = "Paraxial,Security/Eval,Security/IoMethods,Security/JSONLoad,Security/MarshalLoad,Security/Open,Security/YAMLLoad" rubocop = `rubocop --only #{cops} --format json` lockfile = File.read("./Gemfile.lock") api_key = ENV['PARAXIAL_API_KEY'] uri = URI.parse(ENV['PARAXIAL_URL'] + "/api/ruby_scan") headers = { 'Content-Type': 'application/json' } body = { rubocop: rubocop, lockfile: lockfile, api_key: api_key, timestamp: Paraxial.get_timestamp() } response = Net::HTTP.post(uri, body.to_json, headers) puts response.body if ENV['PARAXIAL_API_KEY'] == nil puts "[Paraxial] Environment variable PARAXIAL_API_KEY not found, set with: " puts "[Paraxial] export PARAXIAL_API_KEY=your_site_api_key_here" puts "[Paraxial] Exiting" exit() else puts "[Paraxial] Scan result here" end end end end