DrupalScan 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/DrupalScan +52 -0
- data/lib/DrupalScan.rb +59 -0
- metadata +47 -0
data/bin/DrupalScan
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'DrupalScan'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
opts = OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: DrupalScan <url> [--no-module-lookup]"
|
9
|
+
|
10
|
+
opts.on("-u URL", "--url URL", "URL of drupal project. Example: http://drupal.org") do |v|
|
11
|
+
if !v.match /^http/
|
12
|
+
puts opts
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
options[:url] = v
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-n", "--no-module-lookup", "Disable module lookup on drupal.org") do |v|
|
20
|
+
options[:disable_lookup] = true
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-h", "--help", "Show this help") do
|
24
|
+
puts opts
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.parse!
|
30
|
+
|
31
|
+
if !options[:url].nil?
|
32
|
+
version = DrupalScan::getVersion(options[:url])
|
33
|
+
modules = DrupalScan::enumerateModules(options[:url], (options[:disable_lookup] == true ? false : true))
|
34
|
+
|
35
|
+
# Print version
|
36
|
+
puts "Version: #{version}"
|
37
|
+
|
38
|
+
# Print modules
|
39
|
+
if modules.length <= 0
|
40
|
+
puts "No modules found"
|
41
|
+
end
|
42
|
+
|
43
|
+
for k,v in modules
|
44
|
+
puts "Found '#{k}'"
|
45
|
+
if v.kind_of?(String)
|
46
|
+
puts " -> #{v}\n\n"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts opts
|
51
|
+
exit
|
52
|
+
end
|
data/lib/DrupalScan.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
class DrupalScan
|
4
|
+
def self.getVersion(url)
|
5
|
+
begin
|
6
|
+
if url.match /\/$/
|
7
|
+
res = open("#{url}CHANGELOG.txt")
|
8
|
+
else
|
9
|
+
res = open("#{url}/CHANGELOG.txt")
|
10
|
+
end
|
11
|
+
res.readline
|
12
|
+
rescue OpenURI::HTTPError
|
13
|
+
"Not found"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.enumerateModules(url, lookup_modules = true)
|
18
|
+
modules = {}
|
19
|
+
|
20
|
+
begin
|
21
|
+
res = open(url)
|
22
|
+
rescue OpenURI::HTTPError
|
23
|
+
return {}
|
24
|
+
end
|
25
|
+
|
26
|
+
if res.status[0] == "200"
|
27
|
+
|
28
|
+
for match in res.read.scan /modules\/(.*?)\//
|
29
|
+
modules[match[0]] = true
|
30
|
+
|
31
|
+
if lookup_modules
|
32
|
+
require 'nokogiri'
|
33
|
+
|
34
|
+
lookup_res = open("http://drupal.org/project/#{match[0]}")
|
35
|
+
if lookup_res.status[0] == "200"
|
36
|
+
|
37
|
+
doc = Nokogiri::HTML lookup_res.read
|
38
|
+
description = doc.css('.node-content p')
|
39
|
+
if description.length > 0
|
40
|
+
modules[match[0]] = description[0].content
|
41
|
+
modules[match[0]] += "http://drupal.org/project/#{match[0]}"
|
42
|
+
else
|
43
|
+
modules[match[0]] = "Could not extract description from drupal.org"
|
44
|
+
end
|
45
|
+
|
46
|
+
else
|
47
|
+
modules[match[0]] = "Not found on drupal.org"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
modules
|
54
|
+
else
|
55
|
+
puts "URL not accessible (HTTP Status: #{res.status[0]})"
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: DrupalScan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Robin Verton
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-23 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Simple non-intrusive Drupal scanner
|
15
|
+
email: r.verton@gmail.com
|
16
|
+
executables:
|
17
|
+
- DrupalScan
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/DrupalScan.rb
|
22
|
+
- bin/DrupalScan
|
23
|
+
homepage: http://github.com/rverton/DrupalScan
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.24
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Simple non-intrusive Drupal scanner
|
47
|
+
test_files: []
|