Class: Msf::Util::DocumentGenerator::PullRequestFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/util/document_generator/pull_request_finder.rb

Defined Under Namespace

Classes: Exception

Constant Summary collapse

MANUAL_BASE_PATH =
File.expand_path(File.join(Msf::Config.module_directory, '..', 'documentation', 'modules' ))
USER_MANUAL_BASE_PATH =
File.expand_path(File.join(Msf::Config.user_module_directory, '..', 'documentation', 'modules' ))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid

Initializes Msf::Util::DocumenGenerator::PullRequestFinder

Raises:



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/msf/util/document_generator/pull_request_finder.rb', line 36

def initialize
  unless ENV.has_key?('GITHUB_OAUTH_TOKEN')
    msg = ''
    raise PullRequestFinder::Exception, 'GITHUB_OAUTH_TOKEN environment variable not set.'
  end

  self.owner            = 'rapid7'
  self.repository       = "#{owner}/metasploit-framework"
  self.branch           = 'master'
  self.git_access_token = ENV['GITHUB_OAUTH_TOKEN']
  self.git_client       = Octokit::Client.new(access_token: git_access_token)
end

Instance Attribute Details

#branchString

Returns Metasploit Framework’s branch.

Returns:

  • (String)

    Metasploit Framework’s branch



23
24
25
# File 'lib/msf/util/document_generator/pull_request_finder.rb', line 23

def branch
  @branch
end

#git_access_tokenString

Returns Git access token.

Returns:

  • (String)

    Git access token



29
30
31
# File 'lib/msf/util/document_generator/pull_request_finder.rb', line 29

def git_access_token
  @git_access_token
end

#git_clientOctokit::Client

Returns Git client.

Returns:

  • (Octokit::Client)

    Git client



17
18
19
# File 'lib/msf/util/document_generator/pull_request_finder.rb', line 17

def git_client
  @git_client
end

#ownerString

Returns Metasploit Framework’s repository owner.

Returns:

  • (String)

    Metasploit Framework’s repository owner



26
27
28
# File 'lib/msf/util/document_generator/pull_request_finder.rb', line 26

def owner
  @owner
end

#repositoryString

Returns Metasploit Framework’s repository.

Returns:

  • (String)

    Metasploit Framework’s repository



20
21
22
# File 'lib/msf/util/document_generator/pull_request_finder.rb', line 20

def repository
  @repository
end

Instance Method Details

#search(mod) ⇒ Hash

Returns pull requests associated with a particular Metasploit module.

Parameters:

Returns:

  • (Hash)


54
55
56
57
58
# File 'lib/msf/util/document_generator/pull_request_finder.rb', line 54

def search(mod)
  file_name = get_normalized_module_name(mod)
  commits = get_commits_from_file(file_name)
  get_pull_requests_from_commits(commits)
end