Sha256: b80160a3ca8c24761795df3c600de58e27cfb950fd5d822271cab3135575dfa4

Contents?: true

Size: 925 Bytes

Versions: 6

Compression:

Stored size: 925 Bytes

Contents

namespace :commitment do
  namespace :brakeman do
    task scan: [:environment] do
      $stdout.puts "Checking commitment:brakeman"
      require 'brakeman'
      Brakeman.run app_path: '.', output_files: [Commitment.config.brakeman_output_pathname.to_s], print_report: true
    end

    task(guard: [:environment, 'commitment:brakeman:scan']) do
      begin
        json_document = Commitment.config.brakeman_output_pathname.read
        json = JSON.parse(json_document)
      ensure
        Commitment.config.brakeman_output_pathname.unlink
      end
      errors = []
      ['errors', 'warnings', 'ignored_warnings'].each do |key|
        errors += Array.wrap(json.fetch(key))
      end
      if errors.any?
        abort("Brakeman Vulnerabilities Detected:\n\n\t" << errors.join("\n\t"))
      end
    end
  end

  desc 'Ensure that brakeman has not detected any vulnerabilities'
  task brakeman: ['brakeman:guard']
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commitment-0.2.0 lib/commitment/tasks/brakeman.rake
commitment-0.1.4 lib/commitment/tasks/brakeman.rake
commitment-0.1.3 lib/commitment/tasks/brakeman.rake
commitment-0.1.2 lib/commitment/tasks/brakeman.rake
commitment-0.1.1 lib/commitment/tasks/brakeman.rake
commitment-0.1.0 lib/commitment/tasks/brakeman.rake