Class: GitlabChecks::Checks::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_checks/checks/repository.rb

Instance Method Summary collapse

Constructor Details

#initializeRepository

Returns a new instance of Repository.



6
7
8
9
# File 'lib/gitlab_checks/checks/repository.rb', line 6

def initialize
  @all_repos = nil
  @repos_with_gitlab_security = nil
end

Instance Method Details

#audit(gitlab_org) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab_checks/checks/repository.rb', line 11

def audit(gitlab_org)
  findings = []

  @all_repos = Gitlab.group_projects(gitlab_org.root_group,
                                     { per_page: 100, include_subgroups: true }).lazy_paginate

  @repos_with_gitlab_security = Gitlab.group_projects(gitlab_org.root_group,
                                                      { per_page: 100, include_subgroups: true,
                                                        with_security_reports: true }).lazy_paginate

  findings
end

#output_resultObject



24
# File 'lib/gitlab_checks/checks/repository.rb', line 24

def output_result; end

#output_statisticsObject



26
27
28
29
30
31
# File 'lib/gitlab_checks/checks/repository.rb', line 26

def output_statistics
  print "Number of projects: #{@all_repos.count}"
  print "Number of projects with active Gitlab security dashboards: #{@repos_with_gitlab_security.count}"
  print "Number of public projects: #{ @all_repos.select { |repo| repo["visibility"].include?("public") }.count}"
  print "Number of public projects: #{ @all_repos.select { |repo| repo["visibility"].include?("internal") }.count}"
end