bin/veracodecli in veracodecli-0.2.0 vs bin/veracodecli in veracodecli-1.0.0

- old
+ new

@@ -1,9 +1,10 @@ #!/usr/bin/env ruby require 'commander' require 'veracodecli' +require_relative '../lib/veracodecli/settings' include VeracodeApiResults include VeracodeApiScan include VeracodeApiBase include VeracodeApiMacros @@ -14,23 +15,27 @@ program :help, 'Author', 'Isaiah Thiessen <isaiah.thiessen@telus.com>' command :scan do |c| c.syntax = 'veracodecli scan [app_name] [repo] --option [option]' c.description = 'Submits a scan to Veracode.' - c.option '--business_unit NAME', String, 'Business Unit Name' - c.option '--team NAME', String, 'Team Name' - c.option '--business_criticality', String, 'Application business criticality' - c.action do |args,options| - fail 'Specify application Name.' if args.first.nil? - fail 'Specify repo location.' if args[1].nil? - options.default :business_criticality => 'High' - options.default :business_unit => 'TELUS Digital' - directory = "/home/#{ENV['USER']}/veracodecli_data/sast_clone" - VeracodeApiBase.load_config - VeracodeApiBase.get_repo_archive args[1], directory - VeracodeApiMacros.submit_scan_macro args[0], options.business_criticality, options.business_unit, options.team, "#{directory}/sast_upload.tar" - `cd #{directory}; rm -r sast_upload.tar` + c.option '--business_unit STRING', String, 'Business Unit Name' + c.option '--team STRING', String, 'Team Name' + c.option '--business_criticality STRING', String, 'Application business criticality' + c.option '--app_name STRING', String, 'Name of the app to scan' + c.option '--repo STRING', String, 'The URL of application repo' + c.action do |_,options| + abort 'Missing parameter --repo' unless options.repo + abort 'Missing parameter --app_name' unless options.app_name + abort 'Missing parameter --business_unit' unless options.business_unit || defined? Settings.business_unit + abort 'Missing parameter --team' unless options.team || defined? Settings.team + abort 'Missing parameter --business_criticality' unless options.business_criticality || defined? Settings.business_criticality + + business_criticality = options.business_criticality || Settings.business_criticality + business_unit = options.business_unit || Settings.business_unit + team = options.team || Settings.team + VeracodeApiBase.get_repo_archive options.repo + VeracodeApiMacros.submit_scan_macro options.app_name, business_criticality, business_unit, team end end command :get_prescan_results do |c| c.syntax = 'veracodecli get-prescan-results [app_id]' @@ -49,22 +54,27 @@ VeracodeApiResults.get_build_status args.first end end command :get_report do |c| - c.syntax = 'veracodecli get-report [app_name]' + c.syntax = 'veracodecli get_report [app_name]' c.description = 'Downloads the final scan report from Veracode.' c.action do |args| fail 'Specify app_name.' if args.first.nil? VeracodeApiMacros.get_report_macro args.first end end command :get_pdf_report do |c| - c.syntax = 'veracodecli get-pdf [app_name]' + c.syntax = 'veracodecli get_pdf_report [app_name] --option [option]' + c.option '--app STRING', String, 'Upload report to slack?' + c.option '--slack_upload STRING', String, 'Upload report to slack?' c.description = 'Downloads the final scan report in pdf format.' - c.action do |args| - fail 'Specify app_name.' if args.first.nil? - VeracodeApiMacros.get_pdf_macro args.first + c.action do |args, options| + abort 'Please specify slack token in config.yml' if ((!defined? Settings.slack_token) && (options.slack_upload.eql? 'yes')) + abort 'Please specify slack channel in config.yml' if ((!defined? Settings.slack_channel) && (options.slack_upload.eql? 'yes')) + abort 'Please specify an app' unless options.app + file = VeracodeApiMacros.get_pdf_macro args.first + Slack.send_to_slack file if (options.slack_upload.eql? 'yes') end end end