thieve 0.2.3 → 0.3.0

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/thieve +13 -3
  3. data/lib/thieve.rb +18 -16
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3ce17721ffd5395450d38f1aaa0bdf0859c0a23
4
- data.tar.gz: 77079a0a8f8dad30201d31016b4eb9f0e3a1f35d
3
+ metadata.gz: c60bd1bbcf6c73e7494c032d3b770810bc0b3344
4
+ data.tar.gz: a8a1f1d9b24c06b3500b7334e0e9de77475c3e4e
5
5
  SHA512:
6
- metadata.gz: d6e6f0ff52ff6b598d951448492f66e9570ff3d9e412c6c6d5bf6fe88250f6c77a23a074c2c0ac51da640c26d546c2dce35f48bc0155454b440908bf84f4c5ac
7
- data.tar.gz: 977c35f9138c99eb9bf8704dfef8f9f0f695549f4e327423f0dac5efb1520d2546b603056c734ba792c9311eb2d68c69ee27b2107b91f2ae373e3acb88e93018
6
+ metadata.gz: bb088f7cc57316042955e1d4c58f4b1e515e668c82939f5cf7830b77ce5eda90eeca1a2bbfc725f5ea7008d4133741c9b7a4cefa15fbebb8a8d5156a95b40cef
7
+ data.tar.gz: e4a33545425fc352078a1f11adab1b604420e9a018d9bc49b8fc64da9536d1645fc53210e31c2f3c8f895141e57aa46042ab528b1ece840429f14f02e92e1c4c
data/bin/thieve CHANGED
@@ -17,6 +17,7 @@ end
17
17
 
18
18
  def parse(args)
19
19
  options = Hash.new
20
+ options["binaries"] = false
20
21
  options["export"] = nil
21
22
  options["ignore"] = Array.new
22
23
  options["private"] = false
@@ -33,12 +34,20 @@ def parse(args)
33
34
 
34
35
  opts.on("", "DESCRIPTION")
35
36
 
36
- info.scan(/\S.{0,76}\S(?=\s|$)|\S+/).each do |line|
37
+ info.scan(/\S.{0,66}\S(?=\s|$)|\S+/).each do |line|
37
38
  opts.on(" #{line}")
38
39
  end
39
40
 
40
41
  opts.on("", "OPTIONS")
41
42
 
43
+ opts.on(
44
+ "-b",
45
+ "--binaries",
46
+ "Search binary files (may take a long time)"
47
+ ) do
48
+ options["binaries"] = true
49
+ end
50
+
42
51
  opts.on(
43
52
  "-e",
44
53
  "--export=DIRECTORY",
@@ -67,7 +76,8 @@ def parse(args)
67
76
  opts.on(
68
77
  "-p",
69
78
  "--private-only",
70
- "Only export/show private keys and matching certificates"
79
+ "Only export/show private keys and matching",
80
+ "certificates"
71
81
  ) do
72
82
  options["private"] = true
73
83
  end
@@ -123,7 +133,7 @@ options = parse(ARGV)
123
133
  begin
124
134
  thieve = Thieve.new(!Hilighter.disable?)
125
135
  options["dirs"].each do |dir|
126
- thieve.steal_from(dir, options["ignore"])
136
+ thieve.steal_from(dir, options["ignore"], options["binaries"])
127
137
  end
128
138
  thieve.find_matches
129
139
 
data/lib/thieve.rb CHANGED
@@ -181,6 +181,10 @@ class Thieve
181
181
  raise Thieve::Error::ExecutableNotFound.new("gpg")
182
182
  end
183
183
 
184
+ if (ScoobyDoo.where_are_you("grep").nil?)
185
+ raise Thieve::Error::ExecutableNotFound.new("grep")
186
+ end
187
+
184
188
  @@hilight = hilight
185
189
  @loot = Hash.new
186
190
  @private = false
@@ -190,28 +194,26 @@ class Thieve
190
194
  @private = priv
191
195
  end
192
196
 
193
- def steal_from(filename, ignores = Array.new)
194
- file = Pathname.new(filename).expand_path
197
+ def steal_from(filename, ignores = Array.new, binaries = false)
198
+ cmd = ["\\grep"]
199
+ cmd.push("-a") if (binaries)
195
200
 
196
- skip = ignores.any? do |ignore|
197
- file.to_s.match(%r{#{ignore}})
201
+ ignores.each do |ignore|
202
+ cmd.push("--exclude-dir \"#{ignore}\"")
203
+ cmd.push("--exclude \"*#{ignore}*\"")
198
204
  end
199
- return @loot if (skip)
200
205
 
201
- if (file.directory?)
202
- files = Dir[File.join(file, "**", "*")].reject do |f|
203
- Pathname.new(f).directory? || Pathname.new(f).symlink?
204
- end
206
+ cmd.push("-I") if (!binaries)
207
+ cmd.push("-lRs -- \"-----BEGIN\" #{filename}")
205
208
 
206
- files.each do |f|
207
- skip = ignores.any? do |ignore|
208
- f.to_s.match(%r{#{ignore}})
209
- end
210
- next if (skip)
209
+ %x(#{cmd.join(" ")}).each_line do |f|
210
+ file = Pathname.new(f.strip).expand_path
211
211
 
212
- extract_from(Pathname.new(f).expand_path)
212
+ skip = ignores.any? do |ignore|
213
+ file.to_s.match(%r{#{ignore}})
213
214
  end
214
- else
215
+ next if (skip)
216
+
215
217
  extract_from(file)
216
218
  end
217
219
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thieve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake