lib/paraxial/cli.rb in paraxial-0.9.1 vs lib/paraxial/cli.rb in paraxial-1.0.0
- old
+ new
@@ -13,10 +13,11 @@
option :github_app, type: :boolean, default: false, desc: 'Use GitHub app'
option :install_id, type: :numeric, desc: 'GitHub App installation ID'
option :repo_owner, type: :string, desc: 'Repository owner'
option :repo_name, type: :string, desc: 'Repository name'
option :pr_number, type: :numeric, desc: 'Pull request number'
+ option :exit_code, type: :boolean, default: false, desc: 'Non-zero exit code if findings > 0'
def scan
puts '[Paraxial] Scan starting...'
if check_rubocop_configuration
puts '[Paraxial] .rubocop.yml is valid.'
@@ -25,19 +26,19 @@
puts '.rubocop.yml'
puts 'require:'
puts '- rubocop-erb'
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]
repo_owner = options[:repo_owner]
repo_name = options[:repo_name]
pr_number = options[:pr_number]
+ exit_code = options[:exit_code]
cops = 'Paraxial,Security/Eval,Security/IoMethods,Security/JSONLoad,Security/MarshalLoad,Security/Open,Security/YAMLLoad'
rubocop = `rubocop --require paraxial --only #{cops} --disable-pending-cops --format json`
lockfile = File.read('./Gemfile.lock')
api_key = ENV['PARAXIAL_API_KEY']
@@ -92,9 +93,13 @@
puts '[Paraxial] No scan UUID found'
end
else
:ok
+ end
+
+ if exit_code and (findings.length > 0)
+ exit(1)
end
end
end
private