ronin-sql 0.2.4 → 1.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.
- data/.document +4 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/COPYING.txt +623 -288
- data/{History.txt → ChangeLog.md} +33 -35
- data/Gemfile +25 -0
- data/README.md +110 -0
- data/Rakefile +30 -20
- data/bin/ronin-sql +18 -5
- data/gemspec.yml +16 -0
- data/lib/ronin/formatting/extensions/sql.rb +4 -3
- data/lib/ronin/formatting/extensions/sql/string.rb +83 -10
- data/lib/ronin/formatting/sql.rb +4 -3
- data/lib/ronin/sql.rb +5 -12
- data/lib/ronin/{code/sql/create_index.rb → sql/binary_expr.rb} +25 -18
- data/lib/ronin/sql/clause.rb +72 -0
- data/lib/ronin/sql/clauses.rb +297 -0
- data/lib/ronin/sql/emittable.rb +84 -0
- data/lib/ronin/sql/emitter.rb +375 -0
- data/lib/ronin/sql/field.rb +106 -0
- data/lib/ronin/{code/sql/as.rb → sql/fields.rb} +36 -17
- data/lib/ronin/{code/sql/binary_expr.rb → sql/function.rb} +27 -27
- data/lib/ronin/sql/functions.rb +989 -0
- data/lib/ronin/sql/injection.rb +125 -157
- data/lib/ronin/{code/sql/default_values_clause.rb → sql/literal.rb} +13 -11
- data/lib/ronin/sql/literals.rb +72 -0
- data/lib/ronin/sql/operators.rb +332 -0
- data/lib/ronin/sql/sql.rb +86 -0
- data/lib/ronin/sql/statement.rb +70 -0
- data/lib/ronin/sql/statement_list.rb +110 -0
- data/lib/ronin/sql/statements.rb +115 -0
- data/lib/ronin/{code/sql/desc.rb → sql/unary_expr.rb} +11 -11
- data/lib/ronin/sql/version.rb +5 -4
- data/ronin-sql.gemspec +61 -0
- data/spec/formatting/sql/string_spec.rb +172 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/sql/binary_expr.rb +5 -0
- data/spec/sql/binary_expr_examples.rb +25 -0
- data/spec/sql/clause_examples.rb +43 -0
- data/spec/sql/clause_spec.rb +31 -0
- data/spec/sql/clauses_spec.rb +43 -0
- data/spec/sql/emittable_spec.rb +41 -0
- data/spec/sql/emitter_spec.rb +472 -0
- data/spec/sql/field_spec.rb +103 -0
- data/spec/sql/fields_spec.rb +40 -0
- data/spec/sql/function_examples.rb +30 -0
- data/spec/sql/function_spec.rb +25 -0
- data/spec/sql/functions_spec.rb +110 -0
- data/spec/sql/injection_spec.rb +233 -0
- data/spec/sql/literal_spec.rb +5 -0
- data/spec/sql/literals_spec.rb +46 -0
- data/spec/sql/operators_spec.rb +44 -0
- data/spec/sql/sql_spec.rb +18 -0
- data/spec/sql/statement_examples.rb +39 -0
- data/spec/sql/statement_list_spec.rb +48 -0
- data/spec/sql/statement_sql.rb +38 -0
- data/spec/sql/statements_spec.rb +22 -0
- data/spec/sql/unary_expr.rb +5 -0
- data/spec/sql/unary_expr_examples.rb +20 -0
- metadata +116 -217
- data.tar.gz.sig +0 -0
- data/Manifest.txt +0 -108
- data/README.txt +0 -112
- data/lib/ronin/code/sql.rb +0 -22
- data/lib/ronin/code/sql/add_column_clause.rb +0 -42
- data/lib/ronin/code/sql/alter_table.rb +0 -52
- data/lib/ronin/code/sql/asc.rb +0 -36
- data/lib/ronin/code/sql/between.rb +0 -66
- data/lib/ronin/code/sql/clause.rb +0 -35
- data/lib/ronin/code/sql/code.rb +0 -35
- data/lib/ronin/code/sql/common_dialect.rb +0 -66
- data/lib/ronin/code/sql/create.rb +0 -74
- data/lib/ronin/code/sql/create_table.rb +0 -44
- data/lib/ronin/code/sql/create_view.rb +0 -41
- data/lib/ronin/code/sql/delete.rb +0 -52
- data/lib/ronin/code/sql/dialect.rb +0 -282
- data/lib/ronin/code/sql/drop.rb +0 -55
- data/lib/ronin/code/sql/drop_index.rb +0 -41
- data/lib/ronin/code/sql/drop_table.rb +0 -41
- data/lib/ronin/code/sql/drop_view.rb +0 -41
- data/lib/ronin/code/sql/emittable.rb +0 -100
- data/lib/ronin/code/sql/exceptions.rb +0 -24
- data/lib/ronin/code/sql/exceptions/unknown_clause.rb +0 -29
- data/lib/ronin/code/sql/exceptions/unknown_dialect.rb +0 -29
- data/lib/ronin/code/sql/exceptions/unknown_statement.rb +0 -29
- data/lib/ronin/code/sql/expr.rb +0 -102
- data/lib/ronin/code/sql/field.rb +0 -101
- data/lib/ronin/code/sql/fields_clause.rb +0 -46
- data/lib/ronin/code/sql/from_clause.rb +0 -42
- data/lib/ronin/code/sql/function.rb +0 -53
- data/lib/ronin/code/sql/group_by_clause.rb +0 -46
- data/lib/ronin/code/sql/having_clause.rb +0 -46
- data/lib/ronin/code/sql/in.rb +0 -47
- data/lib/ronin/code/sql/injected_statement.rb +0 -100
- data/lib/ronin/code/sql/injection.rb +0 -203
- data/lib/ronin/code/sql/insert.rb +0 -54
- data/lib/ronin/code/sql/intersect_clause.rb +0 -42
- data/lib/ronin/code/sql/join_clause.rb +0 -123
- data/lib/ronin/code/sql/like.rb +0 -73
- data/lib/ronin/code/sql/limit_clause.rb +0 -42
- data/lib/ronin/code/sql/modifier.rb +0 -48
- data/lib/ronin/code/sql/offset_clause.rb +0 -42
- data/lib/ronin/code/sql/on_clause.rb +0 -55
- data/lib/ronin/code/sql/order_by_clause.rb +0 -42
- data/lib/ronin/code/sql/program.rb +0 -225
- data/lib/ronin/code/sql/rename_to_clause.rb +0 -42
- data/lib/ronin/code/sql/replace.rb +0 -54
- data/lib/ronin/code/sql/select.rb +0 -103
- data/lib/ronin/code/sql/set_clause.rb +0 -42
- data/lib/ronin/code/sql/statement.rb +0 -180
- data/lib/ronin/code/sql/token.rb +0 -62
- data/lib/ronin/code/sql/unary_expr.rb +0 -47
- data/lib/ronin/code/sql/union_all_clause.rb +0 -42
- data/lib/ronin/code/sql/union_clause.rb +0 -42
- data/lib/ronin/code/sql/update.rb +0 -52
- data/lib/ronin/code/sql/values_clause.rb +0 -46
- data/lib/ronin/code/sql/where_clause.rb +0 -42
- data/lib/ronin/sql/error.rb +0 -26
- data/lib/ronin/sql/error/error.rb +0 -62
- data/lib/ronin/sql/error/extensions.rb +0 -22
- data/lib/ronin/sql/error/extensions/string.rb +0 -77
- data/lib/ronin/sql/error/message.rb +0 -62
- data/lib/ronin/sql/error/pattern.rb +0 -104
- data/lib/ronin/sql/error/patterns.rb +0 -99
- data/lib/ronin/sql/extensions.rb +0 -22
- data/lib/ronin/sql/extensions/uri.rb +0 -22
- data/lib/ronin/sql/extensions/uri/http.rb +0 -107
- data/spec/code/sql/common_dialect_spec.rb +0 -205
- data/spec/code/sql/create_examples.rb +0 -19
- data/spec/code/sql/create_index_spec.rb +0 -25
- data/spec/code/sql/create_table_spec.rb +0 -27
- data/spec/code/sql/create_view_spec.rb +0 -16
- data/spec/code/sql/delete_spec.rb +0 -14
- data/spec/code/sql/drop_examples.rb +0 -10
- data/spec/code/sql/drop_index_spec.rb +0 -16
- data/spec/code/sql/drop_table_spec.rb +0 -16
- data/spec/code/sql/drop_view_spec.rb +0 -16
- data/spec/code/sql/has_default_values_clause_examples.rb +0 -10
- data/spec/code/sql/has_fields_clause_examples.rb +0 -15
- data/spec/code/sql/has_from_clause_examples.rb +0 -13
- data/spec/code/sql/has_values_clause_examples.rb +0 -15
- data/spec/code/sql/has_where_clause_examples.rb +0 -15
- data/spec/code/sql/insert_spec.rb +0 -21
- data/spec/code/sql/replace_spec.rb +0 -21
- data/spec/code/sql/select_spec.rb +0 -105
- data/spec/code/sql/update_spec.rb +0 -26
- data/spec/helpers/code.rb +0 -14
- data/spec/sql/error_spec.rb +0 -24
- data/spec/sql/extensions/uri/http_spec.rb +0 -34
- data/spec/sql_spec.rb +0 -9
- data/tasks/spec.rb +0 -10
- data/tasks/yard.rb +0 -13
- metadata.gz.sig +0 -0
data/lib/ronin/code/sql/drop.rb
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'ronin/code/sql/statement'
|
|
23
|
-
|
|
24
|
-
module Ronin
|
|
25
|
-
module Code
|
|
26
|
-
module SQL
|
|
27
|
-
class Drop < Statement
|
|
28
|
-
|
|
29
|
-
def initialize(dialect,type,name=nil,options={},&block)
|
|
30
|
-
@type = type
|
|
31
|
-
@name = name
|
|
32
|
-
@if_exists = options[:if_exists]
|
|
33
|
-
|
|
34
|
-
super(dialect,&block)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def if_exists
|
|
38
|
-
@if_exists = true
|
|
39
|
-
return self
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def emit
|
|
43
|
-
tokens = emit_token('DROP')
|
|
44
|
-
tokens += emit_token(@type)
|
|
45
|
-
|
|
46
|
-
tokens += emit_token('IF EXISTS') if @if_exists
|
|
47
|
-
tokens += emit_value(@name)
|
|
48
|
-
|
|
49
|
-
return tokens
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'ronin/code/sql/drop'
|
|
23
|
-
|
|
24
|
-
module Ronin
|
|
25
|
-
module Code
|
|
26
|
-
module SQL
|
|
27
|
-
class DropIndex < Drop
|
|
28
|
-
|
|
29
|
-
def initialize(dialect,index=nil,options={},&block)
|
|
30
|
-
super(dialect,'INDEX',index,options,&block)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def index(name=nil)
|
|
34
|
-
@name = name if name
|
|
35
|
-
return @name
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'ronin/code/sql/drop'
|
|
23
|
-
|
|
24
|
-
module Ronin
|
|
25
|
-
module Code
|
|
26
|
-
module SQL
|
|
27
|
-
class DropTable < Drop
|
|
28
|
-
|
|
29
|
-
def initialize(dialect,table=nil,options={},&block)
|
|
30
|
-
super(dialect,'TABLE',table,options,&block)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def table(name=nil)
|
|
34
|
-
@name = name if name
|
|
35
|
-
return @name
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'ronin/code/sql/drop'
|
|
23
|
-
|
|
24
|
-
module Ronin
|
|
25
|
-
module Code
|
|
26
|
-
module SQL
|
|
27
|
-
class DropView < Drop
|
|
28
|
-
|
|
29
|
-
def initialize(dialect,view=nil,options={},&block)
|
|
30
|
-
super(dialect,'VIEW',view,options,&block)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def view(name=nil)
|
|
34
|
-
@name = name if name
|
|
35
|
-
return @name
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'ronin/code/emittable'
|
|
23
|
-
|
|
24
|
-
module Ronin
|
|
25
|
-
module Code
|
|
26
|
-
module SQL
|
|
27
|
-
module Emittable
|
|
28
|
-
include Code::Emittable
|
|
29
|
-
|
|
30
|
-
protected
|
|
31
|
-
|
|
32
|
-
def emit_token(value)
|
|
33
|
-
value.to_s.split(/\s/).map { |word| Token.new(word) }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def emit_value(value)
|
|
37
|
-
if value.kind_of?(Statement)
|
|
38
|
-
tokens = []
|
|
39
|
-
|
|
40
|
-
tokens << Token.open_paren
|
|
41
|
-
tokens += value.emit
|
|
42
|
-
tokens << Token.close_paren
|
|
43
|
-
|
|
44
|
-
return tokens
|
|
45
|
-
else
|
|
46
|
-
return super(value)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def emit_values(values)
|
|
51
|
-
tokens = []
|
|
52
|
-
|
|
53
|
-
values.each { |value| tokens += emit_value(value) }
|
|
54
|
-
|
|
55
|
-
return tokens
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
# Emits the comma separated list of the specified _values_.
|
|
60
|
-
#
|
|
61
|
-
def emit_list(values)
|
|
62
|
-
tokens = []
|
|
63
|
-
|
|
64
|
-
(values.length - 1).times do |index|
|
|
65
|
-
tokens << emit_value(values[index])
|
|
66
|
-
tokens << Token.new(',')
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
tokens << emit_value(values.last)
|
|
70
|
-
return tokens
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
# Emits the specified SQL _row_.
|
|
75
|
-
#
|
|
76
|
-
def emit_row(row)
|
|
77
|
-
case row.length
|
|
78
|
-
when 0
|
|
79
|
-
return []
|
|
80
|
-
when 1
|
|
81
|
-
return emit_list(row)
|
|
82
|
-
else
|
|
83
|
-
return [Token.new('(')] + emit_list(row) + [Token.new(')')]
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
#
|
|
88
|
-
# Emits the specified _statement_.
|
|
89
|
-
#
|
|
90
|
-
def emit_statement(statement)
|
|
91
|
-
if statement.kind_of?(Statement)
|
|
92
|
-
return statement.emit
|
|
93
|
-
else
|
|
94
|
-
return statement
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'ronin/code/sql/exceptions/unknown_dialect'
|
|
23
|
-
require 'ronin/code/sql/exceptions/unknown_statement'
|
|
24
|
-
require 'ronin/code/sql/exceptions/unknown_clause'
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
module Ronin
|
|
23
|
-
module Code
|
|
24
|
-
module SQL
|
|
25
|
-
class UnknownClause < RuntimeError
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
module Ronin
|
|
23
|
-
module Code
|
|
24
|
-
module SQL
|
|
25
|
-
class UnknownDialect < RuntimeError
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
module Ronin
|
|
23
|
-
module Code
|
|
24
|
-
module SQL
|
|
25
|
-
class UnknownStatement < RuntimeError
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
data/lib/ronin/code/sql/expr.rb
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Ronin SQL - A Ronin library providing support for SQL related security
|
|
3
|
-
# tasks.
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2007-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
-
#
|
|
7
|
-
# This program is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with this program; if not, write to the Free Software
|
|
19
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'ronin/code/sql/emittable'
|
|
23
|
-
require 'ronin/extensions/meta'
|
|
24
|
-
|
|
25
|
-
module Ronin
|
|
26
|
-
module Code
|
|
27
|
-
module SQL
|
|
28
|
-
class Expr
|
|
29
|
-
|
|
30
|
-
include Emittable
|
|
31
|
-
|
|
32
|
-
def in?(*range)
|
|
33
|
-
In.new(self,*range)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def ===(*range)
|
|
37
|
-
in?(*range)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def not_in?(*range)
|
|
41
|
-
in?(*range).not!
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
protected
|
|
45
|
-
|
|
46
|
-
def self.binary_op(op,*names)
|
|
47
|
-
names.each do |name|
|
|
48
|
-
class_def(name) do |expr|
|
|
49
|
-
BinaryExpr.new(op,self,expr)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
return self
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
binary_op '=', '==', :equals?
|
|
57
|
-
binary_op '!=', :not_equals?
|
|
58
|
-
binary_op '<>', '<=>', :different?
|
|
59
|
-
binary_op '>', '>', :greater?
|
|
60
|
-
binary_op '>=', '>=', :greater_equal?
|
|
61
|
-
binary_op '<', '<', :less?
|
|
62
|
-
binary_op '<=', '<=', :less_equal?
|
|
63
|
-
binary_op 'IS', :is?
|
|
64
|
-
binary_op 'IS NOT', :is_not?
|
|
65
|
-
binary_op 'AS', :as
|
|
66
|
-
binary_op 'CAST', :cast
|
|
67
|
-
binary_op 'OR', :or
|
|
68
|
-
binary_op 'XOR', :xor
|
|
69
|
-
binary_op 'AND', :and
|
|
70
|
-
|
|
71
|
-
def self.like_op(op,*names)
|
|
72
|
-
names.each do |name|
|
|
73
|
-
class_def(name) do |expr,escape|
|
|
74
|
-
Like.new(op,self,expr,escape)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
return self
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
like_op 'LIKE', :like
|
|
82
|
-
like_op 'GLOB', :glob
|
|
83
|
-
like_op 'REGEXP', :regexp
|
|
84
|
-
like_op 'MATCH', :match
|
|
85
|
-
|
|
86
|
-
def self.unary_op(op,*names)
|
|
87
|
-
names.each do |name|
|
|
88
|
-
class_def(name) do
|
|
89
|
-
UnaryExpr.new(op,self)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
return self
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
unary_op 'NOT', :not!
|
|
97
|
-
unary_op 'EXISTS', :exists?
|
|
98
|
-
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|