# 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) 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