Sha256: 7c25b37d32df73e25f9282e3aeae13df39f6fc8b827ab5949615607db9b1f3f7

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

require_relative "./make_pr/base"
require "pry"

module Neetob
  class CLI
    module Github
      class BundleAudit < MakePr::Base
        DESCRIPTION = "Fix security vulnerabilities reported by bundle audit"
        attr_accessor :repos, :sandbox

        def initialize(repos, sandbox = false)
          super()
          @repos = repos
          @sandbox = sandbox
        end

        def run
          matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
          report = nil
          matching_repos.each do |repo|
            begin
              ui.info("\nWorking on repo #{repo}", print_to_audit_log: false)
              clone_repo_in_tmp_dir(repo)
              gemfile_path = File.join(tmp_repo_path(repo), "Gemfile")
              until File.exist?(gemfile_path)
                ui.info("Waiting for clone to finish", print_to_audit_log: false)
                sleep(1)
              end
              bundle_install!(repo)
              report = run_bundle_audit(repo)
              ui.success("Successfully executed bundle audit for #{repo}", print_to_audit_log: false)
            rescue StandardError => e
              ExceptionHandler.new(e).process
            end
          end
          `rm -rf /tmp/neetob`
          if Thread.current[:audit_mode]
            report
          end
        end

        private

          def run_bundle_audit(repo)
            `#{cd_to_repo(repo)} & rbenv local 3.3.5 & bundle-audit check`
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neetob-0.5.18 lib/neetob/cli/github/bundle_audit.rb