Class: GhBbAudit::RepoScanner
- Inherits:
-
Object
- Object
- GhBbAudit::RepoScanner
- Includes:
- SemanticLogger::Loggable
- Defined in:
- lib/gh_bb_audit/repo_scanner.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ RepoScanner
constructor
A new instance of RepoScanner.
- #start_scan ⇒ Object
Constructor Details
#initialize(options) ⇒ RepoScanner
Returns a new instance of RepoScanner.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gh_bb_audit/repo_scanner.rb', line 6 def initialize() @user_csv_path = [:user_file_path] @keyword_csv_path = [:keywords_file_path] @output_file_path = [:output_file_path] GithubApi.set_user_name_pwd([:github_user], [:github_password]) if .include?(:github_user) && .include?(:github_password) @matcher = ::GhBbAudit::KeywordMatcher.new(::GhBbAudit::KeywordsList.new(@keyword_csv_path).all_keywords) @users = ::GhBbAudit::UsersList.new(@user_csv_path).all_users @output_writer = ::GhBbAudit::OutputWriter.new(@output_file_path) end |
Instance Method Details
#start_scan ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gh_bb_audit/repo_scanner.rb', line 17 def start_scan begin [::GhBbAudit::GithubHost, ::GhBbAudit::BitbucketHost].each do |repo_source| @users.each do |user| logger.info("#{repo_source.name}:: Scanning for User: #{user}") repo_source.user(user).public_repos.each do |public_repo| logger.info("#{repo_source.name}:: Scanning Repo: #{public_repo} for User: #{user}") if @matcher.repo_contains_keyword?([public_repo]) @output_writer.repo_name_matched(public_repo,user, repo_source.name) end file_paths = repo_source.repo(user,public_repo).get_all_file_paths if @matcher.repo_contains_keyword?(file_paths) @output_writer.file_paths_matched_in_repo(@matcher.matched_file_paths(file_paths),public_repo, user, repo_source.name) end end end end rescue StandardError => e logger.error "Error in scanning", error: e.inspect ensure @output_writer.close end end |