Module: Ronin::SQL

Defined in:
lib/ronin/sql/sql.rb,
lib/ronin/sql/field.rb,
lib/ronin/sql/clause.rb,
lib/ronin/sql/fields.rb,
lib/ronin/sql/emitter.rb,
lib/ronin/sql/clauses.rb,
lib/ronin/sql/version.rb,
lib/ronin/sql/literal.rb,
lib/ronin/sql/function.rb,
lib/ronin/sql/literals.rb,
lib/ronin/sql/emittable.rb,
lib/ronin/sql/operators.rb,
lib/ronin/sql/statement.rb,
lib/ronin/sql/functions.rb,
lib/ronin/sql/injection.rb,
lib/ronin/sql/unary_expr.rb,
lib/ronin/sql/statements.rb,
lib/ronin/sql/binary_expr.rb,
lib/ronin/sql/injection_expr.rb,
lib/ronin/sql/statement_list.rb

Overview

Provides a Domain Specific Language (DSL) for crafting complex SQL and SQL Injections (SQLi).

Defined Under Namespace

Modules: Clauses, Emittable, Fields, Functions, Literals, Operators, Statements Classes: BinaryExpr, Clause, Emitter, Field, Function, Injection, InjectionExpr, Literal, Statement, StatementList, UnaryExpr

Constant Summary collapse

VERSION =

Ronin SQL version

'1.1.0'

Instance Method Summary collapse

Instance Method Details

#sql {|(statements)| ... } ⇒ StatementList

Creates a new SQL statement list.

Examples:

sql { select(1,2,3,4,id).from(users) }
# => #<Ronin::SQL::StatementList: SELECT (1,2,3,4,id) FROM users>

Yields:

  • ((statements))

    If a block is given, it will be evaluated within the statement list. If the block accepts an argument, the block will be called with the new statement list.

Yield Parameters:

Returns:


55
56
57
# File 'lib/ronin/sql/sql.rb', line 55

def sql(&block)
  StatementList.new(&block)
end

#sqli(options = {}) {|(injection)| ... } ⇒ Injection

Creates a new SQL injection (SQLi)

Examples:

sqli { self.and { 1 == 1 }.select(1,2,3,4,id).from(users) }
# => #<Ronin::SQL::Injection: 1 AND 1=1; SELECT (1,2,3,4,id) FROM users; SELECT (1,2,3,4,id) FROM users>

Parameters:

  • options (Hash) (defaults to: {})

    Additional injection options.

Options Hash (options):

  • :escape (:integer, :decimal, :string, :column)

    The type of element to escape out of.

  • :terminate (Boolean)

    Specifies whether to terminate the SQLi with a comment.

  • :place_holder (String, Symbol, Integer)

    Place-holder data.

Yields:

  • ((injection))

    If a block is given, it will be evaluated within the injection. If the block accepts an argument, the block will be called with the new injection.

Yield Parameters:

  • injection (Injection)

    The new injection.

Returns:


91
92
93
# File 'lib/ronin/sql/sql.rb', line 91

def sqli(options={},&block)
  Injection.new(options,&block)
end