lib/paraxial/cli.rb in paraxial-1.1.0 vs lib/paraxial/cli.rb in paraxial-1.2.0
- old
+ new
@@ -37,10 +37,29 @@
puts ''
when :found_with_erb
puts '[Paraxial] .paraxial-rubocop.yml is valid, .erb files will be scanned.'
end
+ paraxial_config = get_paraxial_configuration
+
+ if paraxial_config && paraxial_config["ignore-gems"]
+ puts '[Paraxial] .paraxial.yml configuration file found.'
+ puts '[Paraxial] Gems ignored by dependency scan:'
+ puts paraxial_config["ignore-gems"]
+ elsif paraxial_config == :error
+ puts '[Paraxial] .paraxial.yml file is not well formed and is being ignored.'
+ paraxial_config = false
+ elsif paraxial_config
+ puts '[Paraxial] .paraxial.yml does not define a valid configuration. Using default configuration.'
+ paraxial_config = false
+ elsif paraxial_config == false
+ puts '[Paraxial] .paraxial.yml configuration file was not found. Using default configuration.'
+ else
+ puts '[Paraxial] .paraxial.yml configuration is empty. Using default configuration.'
+ paraxial_config = false
+ end
+
if Paraxial::Helpers.get_api_key.nil?
puts '[Paraxial] Environment variable PARAXIAL_API_KEY not found'
else
github_app = options[:github_app]
install_id = options[:install_id]
@@ -62,11 +81,11 @@
lockfile = File.read('./Gemfile.lock')
api_key = ENV['PARAXIAL_API_KEY']
uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/ruby_scan')
headers = { 'Content-Type': 'application/json' }
- body = { rubocop: rubocop, lockfile: lockfile, api_key: api_key, timestamp: Paraxial.get_timestamp }
+ body = { rubocop: rubocop, lockfile: lockfile, api_key: api_key, paraxial_config: paraxial_config, timestamp: Paraxial.get_timestamp }
response = Net::HTTP.post(uri, body.to_json, headers)
m = JSON.parse(response.body)
if m['ok'].nil?
puts "[Paraxial] Upload failed, check if PARAXIAL_API_KEY is valid"
@@ -127,9 +146,21 @@
end
end
end
private
+
+ def get_paraxial_configuration
+ config_file = File.join(Dir.pwd, '.paraxial.yml')
+
+ return false unless File.exist?(config_file)
+
+ begin
+ YAML.load_file(config_file)
+ rescue
+ :error
+ end
+ end
def check_rubocop_configuration
# return values:
# :does_not_exist, :found_no_erb, :found_with_erb