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.
@@ -1,16 +1,10 @@
1
1
  class Zoom::SecurityProfile::UnsafeJs < Zoom::SecurityProfile
2
- def initialize(n = nil, o = nil, f = nil, b = nil, a = nil)
3
- case Zoom::ProfileManager.default_profile
4
- when /^ack(-grep)?$/
5
- f ||= "--smart-case --js"
6
- when "ag", "pt"
7
- f ||= "-S -G \"\\.js$\""
8
- when "grep"
9
- f ||= "-i --include=\"*.js\""
10
- end
2
+ def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
3
+ t = Zoom::ProfileManager.default_tool
11
4
 
12
- super(n, nil, f, b, a)
13
- @pattern = [
5
+ super(n, t, f, b, a)
6
+ @exts = ["js", "jsx", "vue"]
7
+ @regex = [
14
8
  "\\.",
15
9
  "(",
16
10
  [
@@ -19,6 +13,5 @@ class Zoom::SecurityProfile::UnsafeJs < Zoom::SecurityProfile
19
13
  ].join("|"),
20
14
  ")"
21
15
  ].join
22
- @taggable = true
23
16
  end
24
17
  end
@@ -1,62 +1,55 @@
1
1
  class Zoom::SecurityProfile::UnsafePhp < Zoom::SecurityProfile
2
- def initialize(n = nil, o = nil, f = nil, b = nil, a = nil)
3
- case Zoom::ProfileManager.default_profile
4
- when /^ack(-grep)?$/
5
- f ||= "--smart-case --php"
6
- when "ag", "pt"
7
- f ||= "-S -G \"\\.ph(p[345t]?|tml)$\""
8
- when "grep"
9
- f ||= [
10
- "-i",
11
- "--include=\"*.php\"",
12
- "--include=\"*.php[345t]\"",
13
- "--include=\"*.phtml\""
14
- ].join(" ")
15
- end
2
+ def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
3
+ t = Zoom::ProfileManager.default_tool
4
+
5
+ super(n, t, f, b, a)
6
+ @exts = ["php", "php3", "php4", "php5", "phpt", "phtml"]
16
7
 
17
- super(n, nil, f, b, a)
18
8
  # From here: https://www.eukhost.com/blog/webhosting/dangerous-php-functions-must-be-disabled/
19
9
  # OMG is anything safe?!
20
- @pattern = [
21
- "\\`",
22
- "|",
23
- "\\$_GET\\[",
24
- "|",
25
- "(^|[^\\nA-Za-z_])",
26
- "(",
27
- "(include|require)(_once)?",
28
- "|",
29
- "(",
10
+ functions = [
11
+ "apache_(child_terminate|setenv)",
12
+ "assert",
13
+ "create_function",
14
+ "define_syslog_variables",
15
+ "escapeshell(arg|cmd)",
16
+ "eval",
17
+ "fp(ut)?",
18
+ "ftp_(connect|exec|get|login|(nb_f)?put|raw(list)?)",
19
+ "highlight_file",
20
+ "ini_(alter|get_all|restore)",
21
+ "inject_code",
22
+ "mysql_pconnect",
23
+ "openlog",
24
+ "passthru",
25
+ "pcntl_exec",
26
+ "php_uname",
27
+ "phpAds_(remoteInfo|XmlRpc|xmlrpc(De|En)code)",
28
+ "popen",
29
+ "posix_(getpwuid|kill|mkfifo|set(pg|s|u)id|uname)",
30
+ "preg_replace",
31
+ "proc_(close|get_status|nice|open|terminate)",
32
+ "(shell_)?exec",
33
+ "sys(log|tem)",
34
+ "xmlrpc_entity_decode"
35
+ ]
36
+ get_params = "\\$_GET\\["
37
+ includes = "(include|require)(_once)?"
38
+ shell = "`"
39
+ start_or_not_variable = "(^|[^\\nA-Za-z_])"
40
+
41
+ @regex = [
42
+ shell,
43
+ get_params,
30
44
  [
31
- "apache_(child_terminate|setenv)",
32
- "assert",
33
- "create_function",
34
- "define_syslog_variables",
35
- "escapeshell(arg|cmd)",
36
- "eval",
37
- "fp(ut)?",
38
- "ftp_(connect|exec|get|login|(nb_f)?put|raw(list)?)",
39
- "highlight_file",
40
- "ini_(alter|get_all|restore)",
41
- "inject_code",
42
- "mysql_pconnect",
43
- "openlog",
44
- "passthru",
45
- "pcntl_exec",
46
- "php_uname",
47
- "phpAds_(remoteInfo|XmlRpc|xmlrpc(De|En)code)",
48
- "popen",
49
- "posix_(getpwuid|kill|mkfifo|set(pg|s|u)id|uname)",
50
- "preg_replace",
51
- "proc_(close|get_status|nice|open|terminate)",
52
- "(shell_)?exec",
53
- "sys(log|tem)",
54
- "xmlrpc_entity_decode"
55
- ].join("|"),
56
- ")",
57
- "\\(",
58
- ")"
59
- ].join
60
- @taggable = true
45
+ start_or_not_variable,
46
+ "(",
47
+ [
48
+ includes,
49
+ "(#{functions.join("|")})\\(",
50
+ ].join("|"),
51
+ ")"
52
+ ].join
53
+ ].join("|")
61
54
  end
62
55
  end
@@ -1,29 +1,21 @@
1
1
  class Zoom::SecurityProfile::UnsafePython < Zoom::SecurityProfile
2
- def initialize(n = nil, o = nil, f = nil, b = nil, a = nil)
3
- case Zoom::ProfileManager.default_profile
4
- when /^ack(-grep)?$/
5
- f ||= "--smart-case --python"
6
- when "ag", "pt"
7
- f ||= "-S -G \"\\.py$\""
8
- when "grep"
9
- f ||= "-i --include=\"*.py\""
10
- end
2
+ def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
3
+ t = Zoom::ProfileManager.default_tool
11
4
 
12
- super(n, nil, f, b, a)
13
- @pattern = [
14
- "(^|[^\\nA-Za-z_])",
15
- "(",
16
- [
17
- "c?[Pp]ickle\\.loads?",
18
- "eval",
19
- "exec",
20
- "os\\.(popen|system)",
21
- "subprocess\\.call",
22
- "yaml\\.load"
23
- ].join("|"),
24
- ")",
25
- "\\("
5
+ super(n, t, f, b, a)
6
+ @exts = ["py"]
7
+ functions = [
8
+ "c?[Pp]ickle\\.loads?",
9
+ "eval",
10
+ "exec",
11
+ "os\\.(popen|system)",
12
+ "subprocess\\.call",
13
+ "yaml\\.load"
14
+ ]
15
+ start_or_not_variable = "(^|[^\\nA-Za-z_])"
16
+ @regex = [
17
+ start_or_not_variable,
18
+ "(#{functions.join("|")})\\(",
26
19
  ].join
27
- @taggable = true
28
20
  end
29
21
  end
@@ -1,29 +1,21 @@
1
1
  class Zoom::SecurityProfile::UnsafeRuby < Zoom::SecurityProfile
2
- def initialize(n = nil, o = nil, f = nil, b = nil, a = nil)
3
- case Zoom::ProfileManager.default_profile
4
- when /^ack(-grep)?$/
5
- f ||= "--smart-case --ruby"
6
- when "ag", "pt"
7
- f ||= [
8
- "-S",
9
- "-G \"\\.(erb|r(ake|b|html|js|xml)|spec)$|Rakefile\""
10
- ].join(" ")
11
- when "grep"
12
- f ||= [
13
- "-i",
14
- "--include=\"*.erb\"",
15
- "--include=\"*.rake\"",
16
- "--include=\"*.rb\"",
17
- "--include=\"*.rhtml\"",
18
- "--include=\"*.rjs\"",
19
- "--include=\"*.rxml\"",
20
- "--include=\"*.spec\"",
21
- "--include=\"Rakefile\""
22
- ].join(" ")
23
- end
2
+ def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
3
+ t = Zoom::ProfileManager.default_tool
24
4
 
25
- super(n, nil, f, b, a)
26
- @pattern = [
5
+ super(n, t, f, b, a)
6
+ @exts = [
7
+ "erb",
8
+ "gemspec",
9
+ "irbrc",
10
+ "rake",
11
+ "rb",
12
+ "rhtml",
13
+ "rjs",
14
+ "rxml",
15
+ "spec"
16
+ ]
17
+ @files = ["Gemfile", "Rakefile"]
18
+ @regex = [
27
19
  "%x\\(",
28
20
  "|",
29
21
  "\\.constantize",
@@ -37,6 +29,5 @@ class Zoom::SecurityProfile::UnsafeRuby < Zoom::SecurityProfile
37
29
  ].join("|"),
38
30
  ")"
39
31
  ].join
40
- @taggable = true
41
32
  end
42
33
  end
@@ -3,32 +3,44 @@ require "scoobydoo"
3
3
 
4
4
  class Zoom::ProfileManager
5
5
  @@ranking = [
6
- ["ag", "Zoom::Profile::Ag", "-Su"],
7
- ["pt", "Zoom::Profile::Pt", "-SU --hidden"],
8
- ["ack", "Zoom::Profile::Ack", ""],
9
- ["ack-grep", "Zoom::Profile::Ack", ""],
10
- ["grep", "Zoom::Profile::Grep", "-ai"],
11
- ["find", "Zoom::Profile::Find", ""]
6
+ ["rg", "Zoom::Profile::Rg"],
7
+ ["ag", "Zoom::Profile::Ag"],
8
+ ["grep", "Zoom::Profile::Grep"],
9
+ ["pt", "Zoom::Profile::Pt"],
10
+ ["ack", "Zoom::Profile::Ack"],
11
+ ["ack-grep", "Zoom::Profile::Ack"],
12
+ ["find", "Zoom::Profile::Find"]
12
13
  ]
14
+ @@tool = nil
13
15
 
14
- def self.default_profile
15
- @@ranking.each do |op, clas, all|
16
- return op if (ScoobyDoo.where_are_you(op))
16
+ def self.class_by_tool(t)
17
+ found = @@ranking.select do |tool, clas|
18
+ t == tool
17
19
  end
20
+ return found[0][1] if (!found.empty?)
21
+ return nil
22
+ end
23
+
24
+ def self.default_class
25
+ if (@@tool && ScoobyDoo.where_are_you(@@tool))
26
+ return class_by_tool(@@tool)
27
+ end
28
+
29
+ @@ranking.each do |tool, clas|
30
+ return clas if (ScoobyDoo.where_are_you(tool))
31
+ end
32
+
18
33
  return nil # shouldn't happen
19
34
  end
20
35
 
21
36
  def self.default_profiles
22
37
  profiles = Hash.new
23
38
 
24
- @@ranking.each do |op, clas, all|
25
- if (ScoobyDoo.where_are_you(op))
26
- name = op.gsub("-grep", "")
39
+ @@ranking.each do |tool, clas|
40
+ if (ScoobyDoo.where_are_you(tool))
41
+ name = tool.gsub("-grep", "")
27
42
  obj = Zoom::Profile.profile_by_name(clas)
28
43
  profiles[name] = obj.new(name)
29
- if (!all.empty?)
30
- profiles["all"] ||= obj.new("all", name, all)
31
- end
32
44
  end
33
45
  end
34
46
 
@@ -36,7 +48,7 @@ class Zoom::ProfileManager
36
48
  case clas.to_s
37
49
  when /^Zoom::SecurityProfile.*/
38
50
  # Ignore these
39
- when /^Zoom::Profile::(Ag|Ack|Find|Grep|Pt)/
51
+ when /^Zoom::Profile::(Ag|Ack|Find|Grep|Pt|Rg)/
40
52
  # Ignore these
41
53
  else
42
54
  # Custom classes
@@ -48,6 +60,28 @@ class Zoom::ProfileManager
48
60
  return profiles
49
61
  end
50
62
 
63
+ def self.default_tool
64
+ if (@@tool && ScoobyDoo.where_are_you(@@tool))
65
+ return @@tool
66
+ end
67
+
68
+ @@ranking.each do |tool, clas|
69
+ return tool if (ScoobyDoo.where_are_you(tool))
70
+ end
71
+
72
+ return nil # shouldn't happen
73
+ end
74
+
75
+ def self.force_tool(tool = nil)
76
+ if (tool == "ack")
77
+ tool = "ack-grep" if (ScoobyDoo.where_are_you("ack-grep"))
78
+ end
79
+
80
+ tool = nil if (tool && !ScoobyDoo.where_are_you(tool))
81
+
82
+ @@tool = tool
83
+ end
84
+
51
85
  def self.security_profiles
52
86
  profiles = Array.new
53
87
  Zoom::SecurityProfile.subclasses.each do |clas|
@@ -1,7 +1,62 @@
1
- clas = Zoom::ProfileManager.default_profile.capitalize
2
- superclass = Zoom::Profile.profile_by_name("Zoom::Profile::#{clas}")
3
- class Zoom::SecurityProfile < superclass
4
- def initialize(n = nil, o = nil, f = nil, b = nil, a = nil)
5
- super(n, Zoom::ProfileManager.default_profile, f, b, a)
1
+ class Zoom::SecurityProfile < Zoom::Profile
2
+ def after(a = nil)
3
+ super
4
+ return @tool.after(a)
5
+ end
6
+
7
+ def before(b = nil)
8
+ super
9
+ return @tool.before(b)
10
+ end
11
+
12
+ def exe(header)
13
+ sync
14
+ return @tool.exe(header)
15
+ end
16
+
17
+ def flags(f = nil)
18
+ super
19
+ return @tool.flags(f)
20
+ end
21
+
22
+ def grep_like_format_flags(all = false)
23
+ super
24
+ @tool.grep_like_format_flags(all)
25
+ @format_flags = @tool.format_flags
26
+ @taggable = @tool.taggable
27
+ end
28
+
29
+ def initialize(n = nil, t = nil, f = nil, b = nil, a = nil)
30
+ clas = Zoom::ProfileManager.class_by_tool(t)
31
+ clas ||= Zoom::ProfileManager.default_class
32
+ @tool = Zoom::Profile.profile_by_name(clas).new(n)
33
+ super(n, @tool.tool, f, b, a)
34
+ end
35
+
36
+ def only_exts_and_files
37
+ @tool.exts = @exts
38
+ @tool.files = @files
39
+ return @tool.only_exts_and_files
40
+ end
41
+
42
+ def preprocess(header)
43
+ sync
44
+ return @tool.preprocess(header)
45
+ end
46
+
47
+ def sync
48
+ @tool.exts = @exts
49
+ @tool.files = @files
50
+ @tool.regex = @regex
51
+ end
52
+ private :sync
53
+
54
+ def tool(t = nil)
55
+ super
56
+ return @tool.tool(t)
57
+ end
58
+
59
+ def translate(from)
60
+ return @tool.translate(from)
6
61
  end
7
62
  end
@@ -26,7 +26,7 @@ class EditWish < Djinni::Wish
26
26
  f, found, v = args.partition(" ")
27
27
 
28
28
  case f
29
- when "class", "operator"
29
+ when "class", "tool"
30
30
  if (found.empty?)
31
31
  usage
32
32
  return
@@ -51,8 +51,8 @@ class EditWish < Djinni::Wish
51
51
  profiles[n] = profile
52
52
  when "flags"
53
53
  profile.flags(v)
54
- when "operator"
55
- profile.operator(v)
54
+ when "tool"
55
+ profile.tool(v)
56
56
  else
57
57
  usage
58
58
  return
@@ -71,7 +71,7 @@ class EditWish < Djinni::Wish
71
71
  "before" => "Prepend any ENV vars",
72
72
  "class" => "Modify the class",
73
73
  "flags" => "Specify any additional flags",
74
- "operator" => "Specify an alternative operator"
74
+ "tool" => "Specify an alternative tool"
75
75
  }
76
76
  end
77
77
 
@@ -1,5 +1,4 @@
1
1
  require "djinni"
2
- require "scoobydoo"
3
2
 
4
3
  class EditorWish < Djinni::Wish
5
4
  def aliases
@@ -11,17 +10,12 @@ class EditorWish < Djinni::Wish
11
10
  end
12
11
 
13
12
  def execute(args, djinni_env = {})
14
- if (args.include?(" "))
13
+ if (args.empty?)
15
14
  usage
16
15
  return
17
16
  end
18
17
 
19
- config = djinni_env["config"]
20
- if (ScoobyDoo.where_are_you(args))
21
- config.editor(args)
22
- else
23
- puts "Editor not found: #{args}"
24
- end
18
+ djinni_env["config"].editor(args)
25
19
  end
26
20
 
27
21
  def usage