ruby-zoom 4.7.5 → 5.0.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.
- checksums.yaml +4 -4
- data/bin/z +108 -50
- data/bin/zc +108 -50
- data/bin/zf +108 -50
- data/bin/zg +108 -50
- data/bin/zl +108 -50
- data/bin/zr +108 -50
- data/lib/zoom.rb +89 -26
- data/lib/zoom/cache.rb +10 -9
- data/lib/zoom/cache/result.rb +3 -3
- data/lib/zoom/config.rb +15 -6
- data/lib/zoom/editor.rb +8 -4
- data/lib/zoom/error.rb +1 -0
- data/lib/zoom/error/regex_not_provided.rb +5 -0
- data/lib/zoom/profile.rb +62 -90
- data/lib/zoom/profile/ack.rb +35 -10
- data/lib/zoom/profile/ag.rb +21 -5
- data/lib/zoom/profile/find.rb +48 -4
- data/lib/zoom/profile/grep.rb +25 -5
- data/lib/zoom/profile/passwords.rb +5 -13
- data/lib/zoom/profile/pt.rb +21 -5
- data/lib/zoom/profile/rg.rb +51 -0
- data/lib/zoom/profile/unsafe_c.rb +32 -30
- data/lib/zoom/profile/unsafe_java.rb +15 -28
- data/lib/zoom/profile/unsafe_js.rb +5 -12
- data/lib/zoom/profile/unsafe_php.rb +48 -55
- data/lib/zoom/profile/unsafe_python.rb +16 -24
- data/lib/zoom/profile/unsafe_ruby.rb +16 -25
- data/lib/zoom/profile_manager.rb +50 -16
- data/lib/zoom/security_profile.rb +60 -5
- data/lib/zoom/wish/edit_wish.rb +4 -4
- data/lib/zoom/wish/editor_wish.rb +2 -8
- metadata +14 -12
data/lib/zoom/profile/ack.rb
CHANGED
@@ -1,30 +1,55 @@
|
|
1
1
|
class Zoom::Profile::Ack < Zoom::Profile
|
2
|
-
def
|
3
|
-
|
4
|
-
o ||= "ack"
|
5
|
-
if ((o == "ack") && ScoobyDoo.where_are_you("ack-grep"))
|
6
|
-
o = "ack-grep"
|
7
|
-
end
|
8
|
-
|
9
|
-
f ||= "--smart-case"
|
10
|
-
super(n, o, f, b, a)
|
2
|
+
def grep_like_format_flags(all = false)
|
3
|
+
super
|
11
4
|
@format_flags = [
|
12
|
-
"--follow",
|
13
5
|
"-H",
|
14
6
|
"--nobreak",
|
15
7
|
"--nocolor",
|
8
|
+
"--nogroup",
|
16
9
|
"--noheading",
|
17
10
|
"-s"
|
18
11
|
].join(" ")
|
19
12
|
@taggable = true
|
20
13
|
end
|
21
14
|
|
15
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
16
|
+
f ||= "--smart-case"
|
17
|
+
|
18
|
+
# Special case because of debian
|
19
|
+
t ||= "ack"
|
20
|
+
if ((t == "ack") && ScoobyDoo.where_are_you("ack-grep"))
|
21
|
+
t = "ack-grep"
|
22
|
+
end
|
23
|
+
|
24
|
+
super(n, t, f, b, a)
|
25
|
+
end
|
26
|
+
|
27
|
+
def only_exts
|
28
|
+
f = Array.new
|
29
|
+
@exts.each do |ext|
|
30
|
+
f.push("--type-add \"zoom:ext:#{ext}\"")
|
31
|
+
end
|
32
|
+
@files.each do |file|
|
33
|
+
f.push("--type-add \"zoom:is:#{file}\"")
|
34
|
+
end
|
35
|
+
f.push("--type zoom") if (!@exts.empty? || !@files.empty?)
|
36
|
+
return f.join(" ")
|
37
|
+
end
|
38
|
+
|
22
39
|
def translate(from)
|
23
40
|
to = Array.new
|
24
41
|
from.each do |flag, value|
|
25
42
|
case flag
|
43
|
+
when "all"
|
44
|
+
grep_like_format_flags(true)
|
45
|
+
when "follow"
|
46
|
+
to.push("--follow")
|
26
47
|
when "ignore"
|
27
48
|
value.each do |v|
|
49
|
+
# Convert GLOB to regex
|
50
|
+
v.gsub!(/\./, "\\.")
|
51
|
+
v.gsub!(/\*/, ".*")
|
52
|
+
|
28
53
|
to.push("--ignore-dir=\"#{v}\"")
|
29
54
|
to.push("--ignore-file=\"match:/#{v}/\"")
|
30
55
|
end
|
data/lib/zoom/profile/ag.rb
CHANGED
@@ -1,23 +1,39 @@
|
|
1
1
|
class Zoom::Profile::Ag < Zoom::Profile
|
2
|
-
def
|
3
|
-
|
4
|
-
o ||= "ag"
|
5
|
-
super(n, o, f, b, a)
|
2
|
+
def grep_like_format_flags(all = false)
|
3
|
+
super
|
6
4
|
@format_flags = [
|
7
|
-
"-f",
|
8
5
|
"--filename",
|
9
6
|
"--nobreak",
|
10
7
|
"--nocolor",
|
11
8
|
"--noheading",
|
9
|
+
"--numbers",
|
12
10
|
"--silent"
|
13
11
|
].join(" ")
|
12
|
+
@format_flags = "#{@format_flags} -u" if (all)
|
14
13
|
@taggable = true
|
15
14
|
end
|
16
15
|
|
16
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
17
|
+
f ||= "-S"
|
18
|
+
t ||= "ag"
|
19
|
+
super(n, t, f, b, a)
|
20
|
+
end
|
21
|
+
|
22
|
+
def only_exts_and_files
|
23
|
+
if (!@exts.empty? || !@files.empty?)
|
24
|
+
return "-G \"\.(#{@exts.join("|")})$|#{@files.join("|")}\""
|
25
|
+
end
|
26
|
+
return ""
|
27
|
+
end
|
28
|
+
|
17
29
|
def translate(from)
|
18
30
|
to = Array.new
|
19
31
|
from.each do |flag, value|
|
20
32
|
case flag
|
33
|
+
when "all"
|
34
|
+
grep_like_format_flags(true)
|
35
|
+
when "follow"
|
36
|
+
to.push("--follow")
|
21
37
|
when "ignore"
|
22
38
|
value.each do |v|
|
23
39
|
to.push("--ignore=#{v}")
|
data/lib/zoom/profile/find.rb
CHANGED
@@ -1,16 +1,60 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
1
3
|
class Zoom::Profile::Find < Zoom::Profile
|
2
|
-
def
|
4
|
+
def exe(header)
|
5
|
+
cmd = [
|
6
|
+
before,
|
7
|
+
tool,
|
8
|
+
header["paths"],
|
9
|
+
flags,
|
10
|
+
header["translated"],
|
11
|
+
header["args"],
|
12
|
+
header["regex"],
|
13
|
+
after
|
14
|
+
].join(" ").strip
|
15
|
+
|
16
|
+
if (header.has_key?("debug") && header["debug"])
|
17
|
+
puts cmd
|
18
|
+
return ""
|
19
|
+
else
|
20
|
+
return %x(#{cmd})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def grep_like_format_flags(all = false)
|
25
|
+
super
|
26
|
+
@taggable = true
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
3
30
|
a = "-print" if (a.nil? || a.empty?)
|
4
31
|
f ||= ""
|
5
|
-
|
6
|
-
super(n,
|
7
|
-
|
32
|
+
t ||= "find"
|
33
|
+
super(n, t, f, b, a)
|
34
|
+
end
|
35
|
+
|
36
|
+
def preprocess(header)
|
37
|
+
# If additional args are passed, then assume regex is actually
|
38
|
+
# an arg
|
39
|
+
if (!header["args"].empty?)
|
40
|
+
header["args"] += " #{header["regex"]}"
|
41
|
+
header["regex"] = ""
|
42
|
+
end
|
43
|
+
|
44
|
+
# If regex was provided then assume it's an iname search
|
45
|
+
if (!header["regex"].empty?)
|
46
|
+
header["regex"] = "-iname \"#{header["regex"]}\""
|
47
|
+
end
|
48
|
+
|
49
|
+
return header
|
8
50
|
end
|
9
51
|
|
10
52
|
def translate(from)
|
11
53
|
to = Array.new
|
12
54
|
from.each do |flag, value|
|
13
55
|
case flag
|
56
|
+
when "follow"
|
57
|
+
to.push("-L")
|
14
58
|
when "ignore"
|
15
59
|
value.each do |v|
|
16
60
|
to.push("-name \"#{v}\" -prune -o")
|
data/lib/zoom/profile/grep.rb
CHANGED
@@ -1,23 +1,43 @@
|
|
1
1
|
class Zoom::Profile::Grep < Zoom::Profile
|
2
|
-
def
|
3
|
-
|
4
|
-
o ||= "grep"
|
5
|
-
super(n, o, f, b, a)
|
2
|
+
def grep_like_format_flags(all = false)
|
3
|
+
super
|
6
4
|
@format_flags = [
|
7
5
|
"--color=never",
|
8
|
-
"-
|
6
|
+
"-EHInrs",
|
9
7
|
"--exclude-dir=.bzr",
|
10
8
|
"--exclude-dir=.git",
|
11
9
|
"--exclude-dir=.git-crypt",
|
12
10
|
"--exclude-dir=.svn"
|
13
11
|
].join(" ")
|
12
|
+
@format_flags = "--color=never -aEHnRs" if (all)
|
14
13
|
@taggable = true
|
15
14
|
end
|
16
15
|
|
16
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
17
|
+
f ||= "-i"
|
18
|
+
t ||= "grep"
|
19
|
+
super(n, t, f, b, a)
|
20
|
+
end
|
21
|
+
|
22
|
+
def only_exts_and_files
|
23
|
+
f = Array.new
|
24
|
+
@exts.each do |ext|
|
25
|
+
f.push("--include=\"*.#{ext}\"")
|
26
|
+
end
|
27
|
+
@files.each do |file|
|
28
|
+
f.push("--include=\"#{file}\"")
|
29
|
+
end
|
30
|
+
return f.join(" ")
|
31
|
+
end
|
32
|
+
|
17
33
|
def translate(from)
|
18
34
|
to = Array.new
|
19
35
|
from.each do |flag, value|
|
20
36
|
case flag
|
37
|
+
when "all"
|
38
|
+
grep_like_format_flags(true)
|
39
|
+
when "follow"
|
40
|
+
to.push("-R")
|
21
41
|
when "ignore"
|
22
42
|
value.each do |v|
|
23
43
|
to.push("--exclude=#{v} --exclude-dir=#{v}")
|
@@ -1,16 +1,8 @@
|
|
1
1
|
class Zoom::SecurityProfile::Passwords < Zoom::SecurityProfile
|
2
|
-
def initialize(n = nil,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
f ||= "-SU --hidden"
|
8
|
-
when "grep"
|
9
|
-
f ||= "-ai"
|
10
|
-
end
|
11
|
-
|
12
|
-
super(n, nil, f, b, a)
|
13
|
-
@pattern = "(key|pa?ss(w(o?r)?d)?)[^:=,>]? *[:=,>]"
|
14
|
-
@taggable = true
|
2
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
3
|
+
super(n, t, f, b, a)
|
4
|
+
# Don't search binary files
|
5
|
+
# grep_like_format_flags(true)
|
6
|
+
@regex = "(key|pa?ss(w(o?r)?d)?)[^:=,>]? *[:=,>]"
|
15
7
|
end
|
16
8
|
end
|
data/lib/zoom/profile/pt.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
class Zoom::Profile::Pt < Zoom::Profile
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@format_flags = "-e -f --nocolor --nogroup"
|
2
|
+
def grep_like_format_flags(all = false)
|
3
|
+
super
|
4
|
+
@format_flags = "-e --nocolor --nogroup --numbers"
|
5
|
+
@format_flags = "#{@format_flags} --hidden -U" if (all)
|
7
6
|
@taggable = true
|
8
7
|
end
|
9
8
|
|
9
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
10
|
+
f ||= "-S"
|
11
|
+
t ||= "pt"
|
12
|
+
super(n, t, f, b, a)
|
13
|
+
end
|
14
|
+
|
15
|
+
def only_exts_and_files
|
16
|
+
if (!@exts.empty? || !@files.empty?)
|
17
|
+
return "-G \"\.(#{@exts.join("|")})$|#{@files.join("|")}\""
|
18
|
+
end
|
19
|
+
return ""
|
20
|
+
end
|
21
|
+
|
10
22
|
def translate(from)
|
11
23
|
to = Array.new
|
12
24
|
from.each do |flag, value|
|
13
25
|
case flag
|
26
|
+
when "all"
|
27
|
+
grep_like_format_flags(true)
|
28
|
+
when "follow"
|
29
|
+
to.push("--follow")
|
14
30
|
when "ignore"
|
15
31
|
value.each do |v|
|
16
32
|
to.push("--ignore=#{v}")
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Zoom::Profile::Rg < Zoom::Profile
|
2
|
+
def grep_like_format_flags(all = false)
|
3
|
+
super
|
4
|
+
@format_flags = [
|
5
|
+
"--color never",
|
6
|
+
"-H",
|
7
|
+
"-n",
|
8
|
+
"--no-heading",
|
9
|
+
"--no-messages"
|
10
|
+
].join(" ")
|
11
|
+
@format_flags = "#{@format_flags} -uuu" if (all)
|
12
|
+
@taggable = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
16
|
+
f ||= "-S"
|
17
|
+
t ||= "rg"
|
18
|
+
super(n, t, f, b, a)
|
19
|
+
end
|
20
|
+
|
21
|
+
def only_exts_and_files
|
22
|
+
f = Array.new
|
23
|
+
@exts.each do |ext|
|
24
|
+
f.push("--type-add \"zoom:*.#{ext}\"")
|
25
|
+
end
|
26
|
+
@files.each do |file|
|
27
|
+
f.push("--type-add \"zoom:#{file}\"")
|
28
|
+
end
|
29
|
+
f.push("-t zoom") if (!@exts.empty? || !@files.empty?)
|
30
|
+
return f.join(" ")
|
31
|
+
end
|
32
|
+
|
33
|
+
def translate(from)
|
34
|
+
to = Array.new
|
35
|
+
from.each do |flag, value|
|
36
|
+
case flag
|
37
|
+
when "all"
|
38
|
+
grep_like_format_flags(true)
|
39
|
+
when "follow"
|
40
|
+
to.push("--follow")
|
41
|
+
when "ignore"
|
42
|
+
value.each do |v|
|
43
|
+
to.push("--iglob=\"!#{v}\"")
|
44
|
+
end
|
45
|
+
when "word-regexp"
|
46
|
+
to.push("-w")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
return to.join(" ")
|
50
|
+
end
|
51
|
+
end
|
@@ -1,35 +1,37 @@
|
|
1
1
|
class Zoom::SecurityProfile::UnsafeC < Zoom::SecurityProfile
|
2
|
-
def initialize(n = nil,
|
3
|
-
|
4
|
-
when /^ack(-grep)?$/
|
5
|
-
f ||= "--smart-case --cc --cpp"
|
6
|
-
when "ag", "pt"
|
7
|
-
f ||= "-S -G \"\\.(c(c|pp)?|h(pp)?)$\""
|
8
|
-
when "grep"
|
9
|
-
f ||= [
|
10
|
-
"-i",
|
11
|
-
"--include=\"*.[ch]\"",
|
12
|
-
"--include=\"*.[ch]pp\"",
|
13
|
-
"--include=\"*.cc\""
|
14
|
-
].join(" ")
|
15
|
-
end
|
2
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
3
|
+
t = Zoom::ProfileManager.default_tool
|
16
4
|
|
17
|
-
super(n,
|
18
|
-
@
|
19
|
-
"
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"
|
31
|
-
"
|
5
|
+
super(n, t, f, b, a)
|
6
|
+
@exts = [
|
7
|
+
"C",
|
8
|
+
"c",
|
9
|
+
"cc",
|
10
|
+
"cpp",
|
11
|
+
"cxx",
|
12
|
+
"H",
|
13
|
+
"h",
|
14
|
+
"hh",
|
15
|
+
"hpp",
|
16
|
+
"hxx",
|
17
|
+
"m",
|
18
|
+
"tpp",
|
19
|
+
"xs"
|
20
|
+
]
|
21
|
+
functions = [
|
22
|
+
"_splitpath",
|
23
|
+
"ato[fil]",
|
24
|
+
"gets",
|
25
|
+
"makepath",
|
26
|
+
"popen",
|
27
|
+
"(sn?)?scanf",
|
28
|
+
"str(cat|cpy|len)",
|
29
|
+
"v?sprintf"
|
30
|
+
]
|
31
|
+
start_or_not_variable = "(^|[^\\nA-Za-z_])"
|
32
|
+
@regex = [
|
33
|
+
start_or_not_variable,
|
34
|
+
"(#{functions.join("|")})\\(",
|
32
35
|
].join
|
33
|
-
@taggable = true
|
34
36
|
end
|
35
37
|
end
|
@@ -1,32 +1,19 @@
|
|
1
1
|
class Zoom::SecurityProfile::UnsafeJava < Zoom::SecurityProfile
|
2
|
-
def initialize(n = nil,
|
3
|
-
|
4
|
-
when /^ack(-grep)?$/
|
5
|
-
f ||= "--smart-case --java"
|
6
|
-
when "ag", "pt"
|
7
|
-
f ||= "-S -G \"\\.(java|properties)$\""
|
8
|
-
when "grep"
|
9
|
-
f ||= [
|
10
|
-
"-i",
|
11
|
-
"--include=\"*.java\"",
|
12
|
-
"--include=\"*.properties\""
|
13
|
-
].join(" ")
|
14
|
-
end
|
2
|
+
def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
|
3
|
+
t = Zoom::ProfileManager.default_tool
|
15
4
|
|
16
|
-
super(n,
|
17
|
-
@
|
18
|
-
|
19
|
-
"
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
")",
|
28
|
-
|
29
|
-
].join
|
30
|
-
@taggable = true
|
5
|
+
super(n, t, f, b, a)
|
6
|
+
@exts = ["java", "properties"]
|
7
|
+
functions = [
|
8
|
+
"\\.exec",
|
9
|
+
"\\.getRuntime",
|
10
|
+
"readObject",
|
11
|
+
"Runtime"
|
12
|
+
]
|
13
|
+
imports = "(sun\\.misc\\.)?Unsafe"
|
14
|
+
@regex = [
|
15
|
+
imports,
|
16
|
+
"(#{functions.join("|")})\\(",
|
17
|
+
].join("|")
|
31
18
|
end
|
32
19
|
end
|