wmap 2.7.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/trust +51 -14
  3. data/bin/trusts +59 -23
  4. data/version.txt +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbbbf1b71d804f4682d5827d07aa6079a27953b04643a7479db78b2a8c68f865
4
- data.tar.gz: 471585e726794ca17d72ec92d8f9963d8c10433f5df2fb941b0ad930880f9bcb
3
+ metadata.gz: ede228cdbc1b9ce2e12369c1d5c61fba8549f8c8dc67c35ee009020cfc32c014
4
+ data.tar.gz: 06ea77a19cbbc5b2bc72aea90fefaff6c336ee1b75a8eba765730e660751426f
5
5
  SHA512:
6
- metadata.gz: 222487917ebee32bf3f1ebed8356fcd12b2c21fead45f6ade6e95e1cc714a9bff2a70bd7fea4ce70551fdc6589cc8b92b8625e45919b18a02ff972f2e43c65d4
7
- data.tar.gz: a96bec97937ec3ff93e6f65081e54608f80dd78916a7fb600fe82f7b41e0458f66890c551eb9f2987dc35e4f09d75cdeeb4068e91ce01139b73f3f4cdf7c11e3
6
+ metadata.gz: 22ce85d7d400650fb8427518c9ce79568db1143178dc60dcedbaa8683f5f4f58a461ebd4065fc078e3ff05e7cb80c7a016b08638dc793dc1150dfcce101de4fb
7
+ data.tar.gz: 3b51d6bda550f065a675409334b519be76521ab3014956b8f017e07d0be4fc33ab41d2b7ddb2e6dcc552fe9d36ce68cb8a887b0895b28470c7b553b18620a1e3
data/bin/trust CHANGED
@@ -1,38 +1,75 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "wmap"
3
- # Executable to add seed entry into ring of the trust. I.E. the trusted domain or CIDR
3
+ require "optparse"
4
4
 
5
- def print_usage
6
- puts "Program to add trust authority entry. Usage: trust [domain|CIDR]"
5
+ # program command line options
6
+ options = {:data_dir => nil, :target => nil, :verbose => false}
7
+ parser = OptionParser.new do|opts|
8
+ opts.banner = Wmap.banner
9
+ opts.on('-d', '--data_dir data_dir', 'Web Mapper local cache data directory') do |data_dir|
10
+ options[:data_dir] = data_dir;
11
+ end
12
+ opts.on('-t', '--target target', 'Web Mapper target') do |target|
13
+ options[:target] = target;
14
+ end
15
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
16
+ options[:verbose] = v;
17
+ end
18
+ opts.on('-h', '--help', 'Displays Help') do
19
+ puts opts
20
+ exit 0
21
+ end
7
22
  end
23
+ parser.parse!
8
24
 
25
+ # print program banner
9
26
  puts Wmap.banner
10
- print_usage
11
- Log_dir=File.dirname(__FILE__)+'/../logs/'
12
- Wmap.wlog("Execute the command: trust #{ARGV[0]}","trust",Log_dir+"wmap.log")
27
+ # print_usage unless options[:target]
28
+
29
+ # Preparing - check out the working logs directory
30
+ if options[:data_dir]
31
+ # Log to the instance running directory
32
+ Log_dir = Pathname.new(options[:data_dir]).join('logs')
33
+ else
34
+ # Log the command entry
35
+ Log_dir=Pathname.new(Gem.loaded_specs['wmap'].full_gem_path).join('logs')
36
+ end
37
+ Dir.mkdir(Log_dir) unless Dir.exist?(Log_dir)
38
+ Wmap.wlog("Execute the command: trust #{options[:target]}","trust",Log_dir+"wmap.log")
13
39
 
14
40
  dt=Wmap::DomainTracker.instance
15
- ct=Wmap::CidrTracker.new(:verbose=>false)
16
- abort "Incorrect program argument! Proper usage: trust [domain | netblock]" unless ARGV.length==1 && (dt.is_fqdn?(ARGV[0]) || ct.is_cidr?(ARGV[0]))
41
+ ct=Wmap::CidrTracker.new
42
+ if options[:data_dir]
43
+ dt.verbose=options[:verbose]
44
+ dt.data_dir = options[:data_dir]
45
+ dt.domains_file = dt.data_dir + "/" + "domains"
46
+ dt.load_domains_from_file(dt.domains_file)
47
+ ct.verbose=options[:verbose]
48
+ ct.data_dir = options[:data_dir]
49
+ ct.cidr_seeds = ct.data_dir + "/" + "cidrs"
50
+ ct.load_cidr_blks_from_file(ct.cidr_seeds)
51
+ end
52
+
53
+ abort "Incorrect program argument! Proper usage: trust [domain | netblock]" unless (dt.is_fqdn?(options[:target]) || ct.is_cidr?(options[:target]))
17
54
 
18
55
  puts "Start the baptizing process ..."
19
56
 
20
57
  # Add entry into the local repository
21
58
 
22
- if dt.is_domain?(ARGV[0])
23
- result=dt.add(ARGV[0])
59
+ if dt.is_domain?(options[:target])
60
+ result=dt.add(options[:target])
24
61
  unless result.nil?
25
62
  dt.save!
26
- abort "Domain #{ARGV[0]} is successfully baptized!"
63
+ abort "Domain #{options[:target]} is successfully baptized!"
27
64
  end
28
65
  end
29
66
  dt=nil
30
67
 
31
- if ct.is_cidr?(ARGV[0])
32
- result=ct.add(ARGV[0])
68
+ if ct.is_cidr?(options[:target])
69
+ result=ct.add(options[:target])
33
70
  unless result.nil?
34
71
  ct.save!
35
- abort "Net block #{ARGV[0]} is successfully baptized!"
72
+ abort "Net block #{options[:target]} is successfully baptized!"
36
73
  end
37
74
  end
38
75
  ct=nil
data/bin/trusts CHANGED
@@ -1,35 +1,71 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Executable to add seed entries into ring of the trust. I.E. the trusted domain or CIDR
3
3
  require "wmap"
4
- include Wmap::Utils
5
- def print_usage
6
- puts "Program to add trust authority entries. Usage: trust [domain|CIDR list in a file]"
4
+ require "optparse"
5
+
6
+ # program command line options
7
+ options = {:data_dir => nil, :target => nil, :verbose => false}
8
+ parser = OptionParser.new do|opts|
9
+ opts.banner = Wmap.banner
10
+ opts.on('-d', '--data_dir data_dir', 'Web Mapper local cache data directory') do |data_dir|
11
+ options[:data_dir] = data_dir;
12
+ end
13
+ opts.on('-t', '--target file', 'Web Mapper target file') do |target|
14
+ options[:target] = target;
15
+ end
16
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
17
+ options[:verbose] = v;
18
+ end
19
+ opts.on('-h', '--help', 'Displays Help') do
20
+ puts opts
21
+ exit 0
22
+ end
7
23
  end
24
+ parser.parse!
8
25
 
26
+ # print program banner
9
27
  puts Wmap.banner
10
- print_usage
11
- Log_dir=File.dirname(__FILE__)+'/../logs/'
12
- Wmap.wlog("Execute the command: trust #{ARGV[0]}","trust",Log_dir+"wmap.log")
13
28
 
14
- dt=Wmap::DomainTracker.instance
15
- ct=Wmap::CidrTracker.new(:verbose=>false)
16
- abort "Incorrect program argument! Proper usage: trust [domain | netblock]" unless ARGV.length==1 && (File.exist?(ARGV[0]))
29
+ # Preparing - check out the working logs directory
30
+ if options[:data_dir]
31
+ # Log to the instance running directory
32
+ Log_dir = Pathname.new(options[:data_dir]).join('logs')
33
+ else
34
+ # Log the command entry
35
+ Log_dir=Pathname.new(Gem.loaded_specs['wmap'].full_gem_path).join('logs')
36
+ end
37
+ Dir.mkdir(Log_dir) unless Dir.exist?(Log_dir)
38
+ Wmap.wlog("Execute the command: trust #{options[:target]}","trust",Log_dir+"wmap.log")
17
39
 
18
- puts "Start the baptizing process ..."
40
+ dt=Wmap::DomainTracker.instance
41
+ ct=Wmap::CidrTracker.new
42
+ if options[:data_dir]
43
+ dt.verbose=options[:verbose]
44
+ dt.data_dir = options[:data_dir]
45
+ dt.domains_file = dt.data_dir + "/" + "domains"
46
+ dt.load_domains_from_file(dt.domains_file)
47
+ ct.verbose=options[:verbose]
48
+ ct.data_dir = options[:data_dir]
49
+ ct.cidr_seeds = ct.data_dir + "/" + "cidrs"
50
+ ct.load_cidr_blks_from_file(ct.cidr_seeds)
51
+ end
19
52
 
20
- file_2_list(ARGV[0]).map do |target|
21
- # Add entry into the local repository
22
- if dt.is_domain?(target)
23
- result=dt.add(target)
24
- unless result.nil?
25
- dt.save!
26
- puts "Domain #{target} is successfully baptized!"
27
- end
28
- elsif ct.is_cidr?(target)
29
- result=ct.add(target)
30
- unless result.nil?
31
- ct.save!
32
- puts "Net block #{target} is successfully baptized!"
53
+ if options[:target]
54
+ puts "Start the baptizing process ..."
55
+ dt.file_2_list(options[:target]).map do |target|
56
+ # Add entry into the local repository
57
+ if dt.is_domain?(target)
58
+ result=dt.add(target)
59
+ unless result.nil?
60
+ dt.save!
61
+ puts "Domain #{target} is successfully baptized!"
62
+ end
63
+ elsif ct.is_cidr?(target)
64
+ result=ct.add(target)
65
+ unless result.nil?
66
+ ct.save!
67
+ puts "Net block #{target} is successfully baptized!"
68
+ end
33
69
  end
34
70
  end
35
71
  end
@@ -3,7 +3,7 @@
3
3
  ###############################################################################
4
4
  package = wmap
5
5
  # wmap version 2.0 == web_discovery version 1.5.3
6
- version = 2.7.1
6
+ version = 2.7.2
7
7
  date = 2020-03-09
8
8
 
9
9
  author = Sam (Yang) Li
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam (Yang) Li