Sha256: 8255e501727989be6b4e8e81326e4dadec11bbcc608c44238b26dae36d5bd530

Contents?: true

Size: 1.77 KB

Versions: 19

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

require_relative "../../../github/repositories/pull_requests"

module Neetob
  class CLI
    module MonthlyAudit
      module Security
        module Github
          class DependabotPrsMerged < CLI::Base
            def initialize
              super()
            end

            def run
              ui.success("### 1.2.2. Checking whether all dependabot PRs created before 2 days have been merged")
              ui.info "\n"

              repo_data = [[
                "Repository",
                "All dependabot PRs older than 2 days have been merged",
                "Comments",
                "Audit Passed"
                ]
              ]
              NeetoCompliance::NeetoRepos.products.keys.each do |repo|
                ui.info "Checking #{repo}...", print_to_audit_log: false
                pull_requests = Neetob::CLI::Github::Repositories::PullRequests.new([repo]).run[0]
                dependabot_prs = pull_requests.select { |pr| pr[:user][:login] == "dependabot[bot]" }
                dependabot_prs_older_than_2_days = dependabot_prs.select { |pr| pr[:created_at] < 2.days.ago }
                dependabot_prs_older_than_2_days_merged = "No"
                audit_passed = "No"
                comments = nil
                if dependabot_prs_older_than_2_days.empty?
                  audit_passed = dependabot_prs_older_than_2_days_merged = "Yes"
                else
                  comments = "PRs older than 2 days: #{dependabot_prs_older_than_2_days.map { |pr| pr[:number] }.join(', ')}"
                end
                repo_data << [repo, dependabot_prs_older_than_2_days_merged, comments, audit_passed]
              end
              ui.print_table(repo_data)
            end
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
neetob-0.5.35 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.34 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.33 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.32 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.31 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.30 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.29 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.28 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.27 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.26 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.25 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.24 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.23 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.22 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.21 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.20 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.19 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.18 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
neetob-0.5.17 lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb