Module: CMSScanner::References

Extended by:
ActiveSupport::Concern
Included in:
Vulnerability
Defined in:
lib/cms_scanner/references.rb

Overview

References related to the issue

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#cve_url(cve) ⇒ String

Returns The URL to the CVE.

Returns:

  • (String)

    The URL to the CVE



53
54
55
# File 'lib/cms_scanner/references.rb', line 53

def cve_url(cve)
  "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-#{cve}"
end

#cve_urlsArray<String>

Returns:

  • (Array<String>)


48
49
50
# File 'lib/cms_scanner/references.rb', line 48

def cve_urls
  cves.reduce([]) { |acc, elem| acc << cve_url(elem) }
end

#cvesArray<String>

Returns The CVEs.

Returns:

  • (Array<String>)

    The CVEs



43
44
45
# File 'lib/cms_scanner/references.rb', line 43

def cves
  references[:cve] || []
end

#exploitdb_idsArray<String>

Returns The ExploitDB ID.

Returns:

  • (Array<String>)

    The ExploitDB ID



58
59
60
# File 'lib/cms_scanner/references.rb', line 58

def exploitdb_ids
  references[:exploitdb] || []
end

#exploitdb_url(id) ⇒ String

Returns:

  • (String)


68
69
70
# File 'lib/cms_scanner/references.rb', line 68

def exploitdb_url(id)
  "https://www.exploit-db.com/exploits/#{id}/"
end

#exploitdb_urlsArray<String>

Returns:

  • (Array<String>)


63
64
65
# File 'lib/cms_scanner/references.rb', line 63

def exploitdb_urls
  exploitdb_ids.reduce([]) { |acc, elem| acc << exploitdb_url(elem) }
end

#msf_modulesArray<String>

Returns The metasploit modules.

Returns:

  • (Array<String>)

    The metasploit modules



78
79
80
# File 'lib/cms_scanner/references.rb', line 78

def msf_modules
  references[:metasploit] || []
end

#msf_url(mod) ⇒ String

Returns The URL to the metasploit module page.

Returns:

  • (String)

    The URL to the metasploit module page



88
89
90
# File 'lib/cms_scanner/references.rb', line 88

def msf_url(mod)
  "https://www.rapid7.com/db/modules/#{mod.sub(%r{^/}, '')}/"
end

#msf_urlsArray<String>

Returns:

  • (Array<String>)


83
84
85
# File 'lib/cms_scanner/references.rb', line 83

def msf_urls
  msf_modules.reduce([]) { |acc, elem| acc << msf_url(elem) }
end

#packetstorm_idsArray<String>

Returns The Packetstormsecurity IDs.

Returns:

  • (Array<String>)

    The Packetstormsecurity IDs



93
94
95
# File 'lib/cms_scanner/references.rb', line 93

def packetstorm_ids
  @packetstorm_ids ||= references[:packetstorm] || []
end

#packetstorm_url(id) ⇒ String

Returns:

  • (String)


103
104
105
# File 'lib/cms_scanner/references.rb', line 103

def packetstorm_url(id)
  "https://packetstormsecurity.com/files/#{id}/"
end

#packetstorm_urlsArray<String>

Returns:

  • (Array<String>)


98
99
100
# File 'lib/cms_scanner/references.rb', line 98

def packetstorm_urls
  packetstorm_ids.reduce([]) { |acc, elem| acc << packetstorm_url(elem) }
end

#referencesHash

Returns:

  • (Hash)


32
33
34
# File 'lib/cms_scanner/references.rb', line 32

def references
  @references ||= {}
end

#references=(refs) ⇒ Object

Parameters:

  • refs (Hash)


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cms_scanner/references.rb', line 17

def references=(refs)
  @references = {}

  self.class.references_keys.each do |key|
    next unless refs.key?(key)

    @references[key] = if key == :youtube
                         Array(refs[:youtube]).map { |id| youtube_url(id) }
                       else
                         Array(refs[key]).map(&:to_s)
                       end
  end
end

#references_urlsArray<String>

Returns All the references URLs.

Returns:

  • (Array<String>)

    All the references URLs



37
38
39
40
# File 'lib/cms_scanner/references.rb', line 37

def references_urls
  cve_urls + exploitdb_urls + urls + msf_urls +
    packetstorm_urls + securityfocus_urls + youtube_urls
end

#securityfocus_idsArray<String>

Returns The Security Focus IDs.

Returns:

  • (Array<String>)

    The Security Focus IDs



108
109
110
# File 'lib/cms_scanner/references.rb', line 108

def securityfocus_ids
  references[:securityfocus] || []
end

#securityfocus_url(id) ⇒ String

Returns:

  • (String)


118
119
120
# File 'lib/cms_scanner/references.rb', line 118

def securityfocus_url(id)
  "https://www.securityfocus.com/bid/#{id}/"
end

#securityfocus_urlsArray<String>

Returns:

  • (Array<String>)


113
114
115
# File 'lib/cms_scanner/references.rb', line 113

def securityfocus_urls
  securityfocus_ids.reduce([]) { |acc, elem| acc << securityfocus_url(elem) }
end

#urlsString<Array>

Returns:

  • (String<Array>)


73
74
75
# File 'lib/cms_scanner/references.rb', line 73

def urls
  references[:url] || []
end

#youtube_url(id) ⇒ String

Returns:

  • (String)


128
129
130
# File 'lib/cms_scanner/references.rb', line 128

def youtube_url(id)
  "https://www.youtube.com/watch?v=#{id}"
end

#youtube_urlsArray<String>

Returns:

  • (Array<String>)


123
124
125
# File 'lib/cms_scanner/references.rb', line 123

def youtube_urls
  references[:youtube] || []
end