Sha256: dc55702bbf0a04791c1ee8d85f3f77e7b2f5037cb8dddcc7c6ecdee38c4c9f96

Contents?: true

Size: 1.5 KB

Versions: 15

Compression:

Stored size: 1.5 KB

Contents

namespace :ci do
  desc 'Brakeman'
  task brakeman: 'ci:rugged:setup' do
    next unless defined?(Rails)

    require 'ndr_dev_support/rake_ci/brakeman_helper'
    # Usage: bundle exec rake ci:brakeman

    @metrics ||= []
    @attachments ||= []

    brakeman = NdrDevSupport::RakeCI::BrakemanHelper.new
    brakeman.commit = @commit
    brakeman.run

    Brakeman::Warning::TEXT_CONFIDENCE.each do |confidence, text|
      metric = {
        name: 'brakeman_warnings',
        type: :gauge,
        label_set: { confidence: text },
        value: brakeman.warning_counts_by_confidence[confidence] || 0
      }
      @metrics << metric
      puts metric.inspect
    end

    unless brakeman.new_fingerprints.empty?
      # new warnings found
      attachment = {
        color: 'danger',
        title: "#{brakeman.new_fingerprints.size} new Brakeman warning(s) :rotating_light:",
        text: '_Brakeman_ warning fingerprint(s):' \
              "```#{brakeman.new_fingerprints.to_a.join("\n")}```",
        footer: 'bundle exec rake ci:brakeman',
        mrkdwn_in: ['text']
      }
      @attachments << attachment
      puts attachment.inspect
    end

    unless brakeman.old_fingerprints.empty?
      # old warnings missing
      attachment = {
        color: 'good',
        title: "#{brakeman.old_fingerprints.size} Brakeman warning(s) resolved :+1:",
        footer: 'bundle exec rake ci:brakeman'
      }
      @attachments << attachment
      puts attachment.inspect
    end

    brakeman.save_current_fingerprints
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ndr_dev_support-5.1.0 lib/tasks/ci/brakeman.rake
ndr_dev_support-5.0.1 lib/tasks/ci/brakeman.rake
ndr_dev_support-5.0.0 lib/tasks/ci/brakeman.rake
ndr_dev_support-4.2.1 lib/tasks/ci/brakeman.rake
ndr_dev_support-4.2.0 lib/tasks/ci/brakeman.rake
ndr_dev_support-4.1.3 lib/tasks/ci/brakeman.rake
ndr_dev_support-4.1.2 lib/tasks/ci/brakeman.rake
ndr_dev_support-4.1.1 lib/tasks/ci/brakeman.rake
ndr_dev_support-4.1.0 lib/tasks/ci/brakeman.rake
ndr_dev_support-4.0.0 lib/tasks/ci/brakeman.rake
ndr_dev_support-3.1.3 lib/tasks/ci/brakeman.rake
ndr_dev_support-3.1.2 lib/tasks/ci/brakeman.rake
ndr_dev_support-3.1.1 lib/tasks/ci/brakeman.rake
ndr_dev_support-3.1.0 lib/tasks/ci/brakeman.rake
ndr_dev_support-3.0.0 lib/tasks/ci/brakeman.rake