ronin-code-sql 2.0.0.beta1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +15 -0
  3. data/.rubocop.yml +13 -0
  4. data/.yardopts +1 -1
  5. data/ChangeLog.md +10 -1
  6. data/Gemfile +4 -0
  7. data/README.md +26 -16
  8. data/Rakefile +1 -0
  9. data/gemspec.yml +3 -3
  10. data/lib/ronin/code/sql/binary_expr.rb +35 -2
  11. data/lib/ronin/code/sql/clause.rb +19 -8
  12. data/lib/ronin/code/sql/clauses.rb +17 -15
  13. data/lib/ronin/code/sql/emittable.rb +9 -2
  14. data/lib/ronin/code/sql/emitter.rb +65 -26
  15. data/lib/ronin/code/sql/field.rb +31 -6
  16. data/lib/ronin/code/sql/fields.rb +1 -1
  17. data/lib/ronin/code/sql/function.rb +15 -4
  18. data/lib/ronin/code/sql/functions.rb +3 -15
  19. data/lib/ronin/code/sql/injection.rb +4 -4
  20. data/lib/ronin/code/sql/injection_expr.rb +1 -1
  21. data/lib/ronin/code/sql/literal.rb +17 -2
  22. data/lib/ronin/code/sql/literals.rb +1 -1
  23. data/lib/ronin/code/sql/mixin.rb +95 -0
  24. data/lib/ronin/code/sql/operators.rb +1 -1
  25. data/lib/ronin/code/sql/statement.rb +14 -3
  26. data/lib/ronin/code/sql/statement_list.rb +1 -1
  27. data/lib/ronin/code/sql/statements.rb +1 -1
  28. data/lib/ronin/code/sql/unary_expr.rb +24 -2
  29. data/lib/ronin/code/sql/version.rb +3 -3
  30. data/lib/ronin/code/sql.rb +5 -64
  31. data/lib/ronin/code/sqli.rb +30 -0
  32. data/ronin-code-sql.gemspec +5 -5
  33. metadata +10 -51
  34. data/spec/spec_helper.rb +0 -3
  35. data/spec/sql/binary_expr_examples.rb +0 -25
  36. data/spec/sql/binary_expr_spec.rb +0 -5
  37. data/spec/sql/clause_examples.rb +0 -43
  38. data/spec/sql/clause_spec.rb +0 -31
  39. data/spec/sql/clauses_spec.rb +0 -47
  40. data/spec/sql/emittable_spec.rb +0 -41
  41. data/spec/sql/emitter_spec.rb +0 -533
  42. data/spec/sql/field_spec.rb +0 -103
  43. data/spec/sql/fields_spec.rb +0 -40
  44. data/spec/sql/function_examples.rb +0 -30
  45. data/spec/sql/function_spec.rb +0 -25
  46. data/spec/sql/functions_spec.rb +0 -113
  47. data/spec/sql/injection_expr_spec.rb +0 -98
  48. data/spec/sql/injection_spec.rb +0 -172
  49. data/spec/sql/literal_spec.rb +0 -5
  50. data/spec/sql/literals_spec.rb +0 -46
  51. data/spec/sql/operators_spec.rb +0 -44
  52. data/spec/sql/statement_examples.rb +0 -39
  53. data/spec/sql/statement_list_spec.rb +0 -48
  54. data/spec/sql/statement_spec.rb +0 -38
  55. data/spec/sql/statements_spec.rb +0 -22
  56. data/spec/sql/unary_expr_examples.rb +0 -20
  57. data/spec/sql/unary_expr_spec.rb +0 -5
  58. data/spec/sql_spec.rb +0 -18
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-code-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-01 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ronin-support
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0.beta1
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0.beta1
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +53,7 @@ files:
53
53
  - ".gitignore"
54
54
  - ".mailmap"
55
55
  - ".rspec"
56
+ - ".rubocop.yml"
56
57
  - ".ruby-version"
57
58
  - ".yardopts"
58
59
  - COPYING.txt
@@ -75,46 +76,23 @@ files:
75
76
  - lib/ronin/code/sql/injection_expr.rb
76
77
  - lib/ronin/code/sql/literal.rb
77
78
  - lib/ronin/code/sql/literals.rb
79
+ - lib/ronin/code/sql/mixin.rb
78
80
  - lib/ronin/code/sql/operators.rb
79
81
  - lib/ronin/code/sql/statement.rb
80
82
  - lib/ronin/code/sql/statement_list.rb
81
83
  - lib/ronin/code/sql/statements.rb
82
84
  - lib/ronin/code/sql/unary_expr.rb
83
85
  - lib/ronin/code/sql/version.rb
86
+ - lib/ronin/code/sqli.rb
84
87
  - ronin-code-sql.gemspec
85
- - spec/spec_helper.rb
86
- - spec/sql/binary_expr_examples.rb
87
- - spec/sql/binary_expr_spec.rb
88
- - spec/sql/clause_examples.rb
89
- - spec/sql/clause_spec.rb
90
- - spec/sql/clauses_spec.rb
91
- - spec/sql/emittable_spec.rb
92
- - spec/sql/emitter_spec.rb
93
- - spec/sql/field_spec.rb
94
- - spec/sql/fields_spec.rb
95
- - spec/sql/function_examples.rb
96
- - spec/sql/function_spec.rb
97
- - spec/sql/functions_spec.rb
98
- - spec/sql/injection_expr_spec.rb
99
- - spec/sql/injection_spec.rb
100
- - spec/sql/literal_spec.rb
101
- - spec/sql/literals_spec.rb
102
- - spec/sql/operators_spec.rb
103
- - spec/sql/statement_examples.rb
104
- - spec/sql/statement_list_spec.rb
105
- - spec/sql/statement_spec.rb
106
- - spec/sql/statements_spec.rb
107
- - spec/sql/unary_expr_examples.rb
108
- - spec/sql/unary_expr_spec.rb
109
- - spec/sql_spec.rb
110
88
  homepage: https://github.com/ronin-rb/ronin-code-sql#readme
111
89
  licenses:
112
90
  - LGPL-3.0
113
91
  metadata:
114
- documentation_uri: https://rubydoc.info/gems/ronin-code-sql
92
+ documentation_uri: https://ronin-rb.dev/docs/ronin-code-sql
115
93
  source_code_uri: https://github.com/ronin-rb/ronin-code-sql
116
94
  bug_tracker_uri: https://github.com/ronin-rb/ronin-code-sql/issues
117
- changelog_uri: https://github.com/ronin-rb/ronin-code-sql/blob/master/ChangeLog.md
95
+ changelog_uri: https://github.com/ronin-rb/ronin-code-sql/blob/main/ChangeLog.md
118
96
  rubygems_mfa_required: 'true'
119
97
  post_install_message:
120
98
  rdoc_options: []
@@ -135,23 +113,4 @@ rubygems_version: 3.3.26
135
113
  signing_key:
136
114
  specification_version: 4
137
115
  summary: A Ruby DSL for crafting SQL Injections.
138
- test_files:
139
- - spec/sql/binary_expr_spec.rb
140
- - spec/sql/clause_spec.rb
141
- - spec/sql/clauses_spec.rb
142
- - spec/sql/emittable_spec.rb
143
- - spec/sql/emitter_spec.rb
144
- - spec/sql/field_spec.rb
145
- - spec/sql/fields_spec.rb
146
- - spec/sql/function_spec.rb
147
- - spec/sql/functions_spec.rb
148
- - spec/sql/injection_expr_spec.rb
149
- - spec/sql/injection_spec.rb
150
- - spec/sql/literal_spec.rb
151
- - spec/sql/literals_spec.rb
152
- - spec/sql/operators_spec.rb
153
- - spec/sql/statement_list_spec.rb
154
- - spec/sql/statement_spec.rb
155
- - spec/sql/statements_spec.rb
156
- - spec/sql/unary_expr_spec.rb
157
- - spec/sql_spec.rb
116
+ test_files: []
data/spec/spec_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'rspec'
2
- require 'simplecov'
3
- SimpleCov.start
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/code/sql/binary_expr'
3
-
4
- shared_examples_for "BinaryExpr" do |method,operator=method|
5
- describe "##{method}" do
6
- let(:operand) { 1 }
7
- let(:expr) { subject.send(method,operand) }
8
-
9
- it "should be a BinaryExpr" do
10
- expect(expr).to be_kind_of(Ronin::Code::SQL::BinaryExpr)
11
- end
12
-
13
- it "should set the left-hand side operand" do
14
- expect(expr.left).to eq(subject)
15
- end
16
-
17
- it "should have a '#{operator}' operator" do
18
- expect(expr.operator).to eq(operator)
19
- end
20
-
21
- it "should set the right-hand side operand" do
22
- expect(expr.right).to eq(operand)
23
- end
24
- end
25
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/code/sql/binary_expr'
3
-
4
- describe Ronin::Code::SQL::BinaryExpr do
5
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for "Clause" do |method,keyword,argument_or_block=nil|
4
- describe "##{method}" do
5
- case argument_or_block
6
- when Proc
7
- before { subject.send(method,&argument_or_block) }
8
- when Array
9
- let(:arguments) { argument_or_block }
10
-
11
- before { subject.send(method,*arguments) }
12
- when NilClass
13
- before { subject.send(method) }
14
- else
15
- let(:argument) { argument_or_block }
16
-
17
- before { subject.send(method,argument) }
18
- end
19
-
20
- it "should add a #{keyword} clause" do
21
- expect(clause.keyword).to eq(keyword)
22
- end
23
-
24
- case argument_or_block
25
- when Proc
26
- it "should accept a block" do
27
- expect(clause.argument).not_to be_nil
28
- end
29
- when NilClass
30
- it "should not have an argument" do
31
- expect(clause.argument).to be_nil
32
- end
33
- when Array
34
- it "should accept an argument" do
35
- expect(clause.argument).to eq(arguments)
36
- end
37
- else
38
- it "should accept an argument" do
39
- expect(clause.argument).to eq(argument)
40
- end
41
- end
42
- end
43
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/code/sql/clause'
3
-
4
- describe Ronin::Code::SQL::Clause do
5
- describe "#initialize" do
6
- context "when given an argument" do
7
- let(:argument) { 1 }
8
-
9
- subject { described_class.new(:CLAUSE,argument) }
10
-
11
- it "should set the argument" do
12
- expect(subject.argument).to eq(argument)
13
- end
14
- end
15
-
16
- context "when given a block" do
17
- subject do
18
- described_class.new(:CLAUSE) { 1 }
19
- end
20
-
21
- it "should use the return value as the argument" do
22
- expect(subject.argument).to eq(1)
23
- end
24
-
25
- context "that accepts an argument" do
26
- it "should yield itself" do
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
- require 'sql/clause_examples'
3
- require 'ronin/code/sql/clause'
4
- require 'ronin/code/sql/clauses'
5
-
6
- describe Ronin::Code::SQL::Clauses do
7
- subject { Object.new.extend(described_class) }
8
-
9
- let(:clause) { subject.clauses.last }
10
-
11
- it { expect(subject.clauses).to be_empty }
12
-
13
- describe "#clause" do
14
- let(:keyword) { :EXEC }
15
-
16
- before { subject.clause(keyword) }
17
-
18
- it "should add an arbitrary clause" do
19
- expect(clause.keyword).to eq(keyword)
20
- end
21
- end
22
-
23
- include_examples "Clause", :from, :FROM, :table
24
- include_examples "Clause", :into, :INTO, :table
25
- include_examples "Clause", :where, :WHERE, proc { id == 1 }
26
- include_examples "Clause", :join, :JOIN, :table
27
- include_examples "Clause", :inner_join, [:INNER, :JOIN], :table
28
- include_examples "Clause", :left_join, [:LEFT, :JOIN], :table
29
- include_examples "Clause", :right_join, [:RIGHT, :JOIN], :table
30
- include_examples "Clause", :full_join, [:FULL, :JOIN], :table
31
- include_examples "Clause", :on, :ON, proc { id == 1 }
32
- include_examples "Clause", :union, :UNION, proc { select(:*).from(:table) }
33
- include_examples "Clause", :union_all, [:UNION, :ALL], proc {
34
- select(:*).from(:table)
35
- }
36
- include_examples "Clause", :group_by, [:GROUP, :BY], [:column1, :column2]
37
- include_examples "Clause", :having, :HAVING, proc { max(priv) > 100 }
38
- include_examples "Clause", :limit, :LIMIT, 100
39
- include_examples "Clause", :offset, :OFFSET, 20
40
- include_examples "Clause", :top, :TOP, 50
41
- include_examples "Clause", :into, :INTO, :table
42
- include_examples "Clause", :values, :VALUES, [1,2,3,4]
43
- include_examples "Clause", :default_values, [:DEFAULT, :VALUES]
44
- include_examples "Clause", :set, :SET, {x: 1, y: 2}
45
- include_examples "Clause", :indexed_by, [:INDEXED, :BY], :index_name
46
- include_examples "Clause", :not_indexed, [:NOT, :INDEXED]
47
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/code/sql/emittable'
3
- require 'ronin/code/sql/literal'
4
-
5
- describe Ronin::Code::SQL::Emittable do
6
- subject { Ronin::Code::SQL::Literal.new('hello') }
7
-
8
- describe "#emitter" do
9
- it "should return an Ronin::Code::SQL::Emitter" do
10
- expect(subject.emitter).to be_kind_of(Ronin::Code::SQL::Emitter)
11
- end
12
-
13
- it "should accept Emitter options" do
14
- expect(subject.emitter(case: :lower).case).to eq(:lower)
15
- end
16
- end
17
-
18
- describe "#to_sql" do
19
- it "should emit the object" do
20
- expect(subject.to_sql).to eq("'hello'")
21
- end
22
-
23
- context "when given options" do
24
- it "should pass them to #emitter" do
25
- expect(subject.to_sql(quotes: :double)).to eq('"hello"')
26
- end
27
- end
28
- end
29
-
30
- describe "#to_s" do
31
- it "should call #to_sql with no arguments" do
32
- expect(subject.to_s).to eq(subject.to_sql)
33
- end
34
- end
35
-
36
- describe "#inspect" do
37
- it "should call #to_sql with no arguments" do
38
- expect(subject.inspect).to include(subject.to_sql)
39
- end
40
- end
41
- end