vorax 0.1.0pre
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/.gitignore +7 -0
- data/.rspec +1 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +30 -0
- data/lib/vorax/base_funnel.rb +30 -0
- data/lib/vorax/output/html_convertor.rb +120 -0
- data/lib/vorax/output/html_funnel.rb +79 -0
- data/lib/vorax/output/pagezip_convertor.rb +20 -0
- data/lib/vorax/output/tablezip_convertor.rb +22 -0
- data/lib/vorax/output/vertical_convertor.rb +53 -0
- data/lib/vorax/output/zip_convertor.rb +117 -0
- data/lib/vorax/parser/argument.rb~ +125 -0
- data/lib/vorax/parser/body_split.rb +168 -0
- data/lib/vorax/parser/conn_string.rb +104 -0
- data/lib/vorax/parser/grammars/alias.rb +912 -0
- data/lib/vorax/parser/grammars/alias.rl +146 -0
- data/lib/vorax/parser/grammars/column.rb +454 -0
- data/lib/vorax/parser/grammars/column.rl +64 -0
- data/lib/vorax/parser/grammars/common.rl +98 -0
- data/lib/vorax/parser/grammars/package_spec.rb +1186 -0
- data/lib/vorax/parser/grammars/package_spec.rl +78 -0
- data/lib/vorax/parser/grammars/plsql_def.rb +469 -0
- data/lib/vorax/parser/grammars/plsql_def.rl +59 -0
- data/lib/vorax/parser/grammars/statement.rb +925 -0
- data/lib/vorax/parser/grammars/statement.rl +83 -0
- data/lib/vorax/parser/parser.rb +320 -0
- data/lib/vorax/parser/plsql_structure.rb +158 -0
- data/lib/vorax/parser/plsql_walker.rb +143 -0
- data/lib/vorax/parser/statement_inspector.rb~ +52 -0
- data/lib/vorax/parser/stmt_inspector.rb +78 -0
- data/lib/vorax/parser/target_ref.rb +110 -0
- data/lib/vorax/sqlplus.rb +281 -0
- data/lib/vorax/version.rb +7 -0
- data/lib/vorax/vorax_io.rb +70 -0
- data/lib/vorax.rb +60 -0
- data/spec/column_spec.rb +40 -0
- data/spec/conn_string_spec.rb +53 -0
- data/spec/package_spec_spec.rb +48 -0
- data/spec/pagezip_spec.rb +153 -0
- data/spec/parser_spec.rb +299 -0
- data/spec/plsql_structure_spec.rb +44 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/sql/create_objects.sql +69 -0
- data/spec/sql/dbms_crypto.spc +339 -0
- data/spec/sql/dbms_crypto.~spc +339 -0
- data/spec/sql/dbms_stats.spc +4097 -0
- data/spec/sql/drop_user.sql +10 -0
- data/spec/sql/muci.spc +24 -0
- data/spec/sql/setup_user.sql +22 -0
- data/spec/sql/test.pkg +67 -0
- data/spec/sqlplus_spec.rb +52 -0
- data/spec/stmt_inspector_spec.rb +84 -0
- data/spec/tablezip_spec.rb +111 -0
- data/spec/vertical_spec.rb +150 -0
- data/vorax.gemspec +21 -0
- metadata +139 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
set verify off
|
2
|
+
set feedback off
|
3
|
+
|
4
|
+
prompt Create DEPARTMENTS_ID sequence
|
5
|
+
create sequence departments_id;
|
6
|
+
|
7
|
+
prompt Create DEPARTMENTS table
|
8
|
+
create table departments (
|
9
|
+
id integer,
|
10
|
+
name varchar2(50),
|
11
|
+
description varchar2(4000)
|
12
|
+
);
|
13
|
+
|
14
|
+
alter table departments add constraint pk_departments primary key (id);
|
15
|
+
|
16
|
+
comment on table departments is 'All departments.';
|
17
|
+
comment on column departments.id is 'The department id.';
|
18
|
+
comment on column departments.name is 'The department name.';
|
19
|
+
comment on column departments.description is 'The description of this department.';
|
20
|
+
|
21
|
+
insert into departments (id, name, description)
|
22
|
+
values (departments_id.nextval, 'Bookkeeping', 'This department is responsible for:' ||
|
23
|
+
chr(10) || '- financial reporting' ||
|
24
|
+
chr(10) || '- analysis' ||
|
25
|
+
chr(10) || '- other boring tasks');
|
26
|
+
insert into departments (id, name)
|
27
|
+
values (departments_id.nextval, 'Marketing');
|
28
|
+
insert into departments (id, name)
|
29
|
+
values (departments_id.nextval, 'Deliveries');
|
30
|
+
insert into departments (id, name)
|
31
|
+
values (departments_id.nextval, 'CRM');
|
32
|
+
insert into departments (id, name)
|
33
|
+
values (departments_id.nextval, 'Legal Stuff');
|
34
|
+
insert into departments (id, name, description)
|
35
|
+
values (departments_id.nextval, 'Management', 'The bad guys department');
|
36
|
+
insert into departments (id, name)
|
37
|
+
values (departments_id.nextval, 'Cooking');
|
38
|
+
insert into departments (id, name)
|
39
|
+
values (departments_id.nextval, 'Public Relations');
|
40
|
+
insert into departments (id, name)
|
41
|
+
values (departments_id.nextval, 'Aquisitions');
|
42
|
+
insert into departments (id, name)
|
43
|
+
values (departments_id.nextval, 'Cleaning');
|
44
|
+
commit;
|
45
|
+
|
46
|
+
prompt Create EMPLOYEES_ID sequence
|
47
|
+
create sequence employees_id;
|
48
|
+
|
49
|
+
prompt Create EMPLOYEES table
|
50
|
+
create table EMPLOYEES (
|
51
|
+
id integer,
|
52
|
+
name nvarchar2(100),
|
53
|
+
salary number,
|
54
|
+
department_id integer);
|
55
|
+
|
56
|
+
alter table employees add constraint pk_employees primary key (id);
|
57
|
+
alter table employees add constraint fk_employees_departments foreign key (department_id) references departments(id);
|
58
|
+
|
59
|
+
comment on table employees is 'All employees baby.';
|
60
|
+
comment on column employees.id is 'The employee identifier.';
|
61
|
+
comment on column employees.name is 'The name of the employee.';
|
62
|
+
comment on column employees.salary is 'The employee salary.';
|
63
|
+
comment on column employees.department_id is 'The department identifier to which the employee is registered.';
|
64
|
+
|
65
|
+
insert into employees (id, name, salary, department_id) values (employees_id.nextval, 'Tic' || unistr('\0103') || ' ' || unistr('\0218') || 'erban', 570, 1);
|
66
|
+
commit;
|
67
|
+
|
68
|
+
prompt Done.
|
69
|
+
quit
|
@@ -0,0 +1,339 @@
|
|
1
|
+
CREATE OR REPLACE PACKAGE SYS.DBMS_CRYPTO AS
|
2
|
+
|
3
|
+
---------------------------------------------------------------------------
|
4
|
+
--
|
5
|
+
-- PACKAGE NOTES
|
6
|
+
--
|
7
|
+
-- DBMS_CRYPTO contains basic cryptographic functions and
|
8
|
+
-- procedures. To use correctly and securely, a general level of
|
9
|
+
-- security expertise is assumed.
|
10
|
+
--
|
11
|
+
-- VARCHAR2 datatype is not supported. Cryptographic operations
|
12
|
+
-- on this type should be prefaced with conversions to a uniform
|
13
|
+
-- character set (AL32UTF8) and conversion to RAW type.
|
14
|
+
--
|
15
|
+
-- Prior to encryption, hashing or keyed hashing, CLOB datatype is
|
16
|
+
-- converted to AL32UTF8. This allows cryptographic data to be
|
17
|
+
-- transferred and understood between databases with different
|
18
|
+
-- character sets, across character set changes and between
|
19
|
+
-- separate processes (for example, Java programs).
|
20
|
+
--
|
21
|
+
---------------------------------------------------------------------------
|
22
|
+
|
23
|
+
|
24
|
+
-------------------------- ALGORITHM CONSTANTS ----------------------------
|
25
|
+
-- The following constants refer to various types of cryptographic
|
26
|
+
-- functions available from this package. Some of the constants
|
27
|
+
-- represent modifiers to these algorithms.
|
28
|
+
---------------------------------------------------------------------------
|
29
|
+
|
30
|
+
-- Hash Functions
|
31
|
+
HASH_MD4 CONSTANT PLS_INTEGER := 1;
|
32
|
+
HASH_MD5 CONSTANT PLS_INTEGER := 2;
|
33
|
+
HASH_SH1 CONSTANT PLS_INTEGER := 3;
|
34
|
+
|
35
|
+
-- MAC Functions
|
36
|
+
HMAC_MD5 CONSTANT PLS_INTEGER := 1;
|
37
|
+
HMAC_SH1 CONSTANT PLS_INTEGER := 2;
|
38
|
+
|
39
|
+
-- Block Cipher Algorithms
|
40
|
+
ENCRYPT_DES CONSTANT PLS_INTEGER := 1; -- 0x0001
|
41
|
+
ENCRYPT_3DES_2KEY CONSTANT PLS_INTEGER := 2; -- 0x0002
|
42
|
+
ENCRYPT_3DES CONSTANT PLS_INTEGER := 3; -- 0x0003
|
43
|
+
ENCRYPT_AES CONSTANT PLS_INTEGER := 4; -- 0x0004
|
44
|
+
ENCRYPT_PBE_MD5DES CONSTANT PLS_INTEGER := 5; -- 0x0005
|
45
|
+
ENCRYPT_AES128 CONSTANT PLS_INTEGER := 6; -- 0x0006
|
46
|
+
ENCRYPT_AES192 CONSTANT PLS_INTEGER := 7; -- 0x0007
|
47
|
+
ENCRYPT_AES256 CONSTANT PLS_INTEGER := 8; -- 0x0008
|
48
|
+
|
49
|
+
-- Block Cipher Chaining Modifiers
|
50
|
+
CHAIN_CBC CONSTANT PLS_INTEGER := 256; -- 0x0100
|
51
|
+
CHAIN_CFB CONSTANT PLS_INTEGER := 512; -- 0x0200
|
52
|
+
CHAIN_ECB CONSTANT PLS_INTEGER := 768; -- 0x0300
|
53
|
+
CHAIN_OFB CONSTANT PLS_INTEGER := 1024; -- 0x0400
|
54
|
+
|
55
|
+
-- Block Cipher Padding Modifiers
|
56
|
+
PAD_PKCS5 CONSTANT PLS_INTEGER := 4096; -- 0x1000
|
57
|
+
PAD_NONE CONSTANT PLS_INTEGER := 8192; -- 0x2000
|
58
|
+
PAD_ZERO CONSTANT PLS_INTEGER := 12288; -- 0x3000
|
59
|
+
PAD_ORCL CONSTANT PLS_INTEGER := 16384; -- 0x4000
|
60
|
+
|
61
|
+
-- Stream Cipher Algorithms
|
62
|
+
ENCRYPT_RC4 CONSTANT PLS_INTEGER := 129; -- 0x0081
|
63
|
+
|
64
|
+
|
65
|
+
-- Convenience Constants for Block Ciphers
|
66
|
+
DES_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_DES
|
67
|
+
+ CHAIN_CBC
|
68
|
+
+ PAD_PKCS5;
|
69
|
+
|
70
|
+
DES3_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_3DES
|
71
|
+
+ CHAIN_CBC
|
72
|
+
+ PAD_PKCS5;
|
73
|
+
|
74
|
+
AES_CBC_PKCS5 CONSTANT PLS_INTEGER := ENCRYPT_AES
|
75
|
+
+ CHAIN_CBC
|
76
|
+
+ PAD_PKCS5;
|
77
|
+
|
78
|
+
|
79
|
+
----------------------------- EXCEPTIONS ----------------------------------
|
80
|
+
-- Invalid Cipher Suite
|
81
|
+
CipherSuiteInvalid EXCEPTION;
|
82
|
+
PRAGMA EXCEPTION_INIT(CipherSuiteInvalid, -28827);
|
83
|
+
|
84
|
+
-- Null Cipher Suite
|
85
|
+
CipherSuiteNull EXCEPTION;
|
86
|
+
PRAGMA EXCEPTION_INIT(CipherSuiteNull, -28829);
|
87
|
+
|
88
|
+
-- Key Null
|
89
|
+
KeyNull EXCEPTION;
|
90
|
+
PRAGMA EXCEPTION_INIT(KeyNull, -28239);
|
91
|
+
|
92
|
+
-- Key Bad Size
|
93
|
+
KeyBadSize EXCEPTION;
|
94
|
+
PRAGMA EXCEPTION_INIT(KeyBadSize, -28234);
|
95
|
+
|
96
|
+
-- Double Encryption
|
97
|
+
DoubleEncryption EXCEPTION;
|
98
|
+
PRAGMA EXCEPTION_INIT(DoubleEncryption, -28233);
|
99
|
+
|
100
|
+
|
101
|
+
---------------------- FUNCTIONS AND PROCEDURES ------------------------
|
102
|
+
|
103
|
+
------------------------------------------------------------------------
|
104
|
+
--
|
105
|
+
-- NAME: Encrypt
|
106
|
+
--
|
107
|
+
-- DESCRIPTION:
|
108
|
+
--
|
109
|
+
-- Encrypt plain text data using stream or block cipher with user
|
110
|
+
-- supplied key and optional iv.
|
111
|
+
--
|
112
|
+
-- PARAMETERS
|
113
|
+
--
|
114
|
+
-- plaintext - Plaintext data to be encrypted
|
115
|
+
-- crypto_type - Stream or block cipher type plus modifiers
|
116
|
+
-- key - Key to be used for encryption
|
117
|
+
-- iv - Optional IV for block ciphers. Default all zeros.
|
118
|
+
--
|
119
|
+
-- USAGE NOTES:
|
120
|
+
--
|
121
|
+
-- Block ciphers may be modified with chaining type (CBC most
|
122
|
+
-- common) and padding type (PKCS5 recommended). Of the four
|
123
|
+
-- common data formats, three have been provided: RAW, BLOB,
|
124
|
+
-- CLOB. For VARCHAR2 encryption, callers should first convert
|
125
|
+
-- to AL32UTF8 character set and then encrypt.
|
126
|
+
--
|
127
|
+
-- Encrypt(UTL_RAW.CAST_TO_RAW(CONVERT(src,'AL32UTF8')),typ,key);
|
128
|
+
--
|
129
|
+
-- As return type for encrypt is RAW, callers should consider
|
130
|
+
-- encoding it with RAWTOHEX or UTL_ENCODE.BASE64_ENCODE to make
|
131
|
+
-- it suitable for VARCHAR2 storage. These functions expand
|
132
|
+
-- data size by 2 and 4/3, respectively.
|
133
|
+
--
|
134
|
+
-- To improve readability, callers should define their own
|
135
|
+
-- package level constants to represent the ciphersuites used
|
136
|
+
-- for encryption and decryption.
|
137
|
+
--
|
138
|
+
-- For example:
|
139
|
+
--
|
140
|
+
-- DES_CBC_PKCS5 CONSTANT PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_DES
|
141
|
+
-- + DBMS_CRYPTO.CHAIN_CBC
|
142
|
+
-- + DBMS_CRYPTO.PAD_PKCS5;
|
143
|
+
--
|
144
|
+
--
|
145
|
+
-- STREAM CIPHERS (RC4) ARE NOT RECOMMENDED FOR STORED DATA ENCRYPTION.
|
146
|
+
--
|
147
|
+
--
|
148
|
+
------------------------------------------------------------------------
|
149
|
+
|
150
|
+
FUNCTION Encrypt (src IN RAW,
|
151
|
+
typ IN PLS_INTEGER,
|
152
|
+
key IN RAW,
|
153
|
+
iv IN RAW DEFAULT NULL)
|
154
|
+
RETURN RAW;
|
155
|
+
|
156
|
+
PROCEDURE Encrypt (dst IN OUT NOCOPY BLOB,
|
157
|
+
src IN BLOB,
|
158
|
+
typ IN PLS_INTEGER,
|
159
|
+
key IN RAW,
|
160
|
+
iv IN RAW DEFAULT NULL);
|
161
|
+
|
162
|
+
PROCEDURE Encrypt (dst IN OUT NOCOPY BLOB,
|
163
|
+
src IN CLOB CHARACTER SET ANY_CS,
|
164
|
+
typ IN PLS_INTEGER,
|
165
|
+
key IN RAW,
|
166
|
+
iv IN RAW DEFAULT NULL);
|
167
|
+
|
168
|
+
|
169
|
+
------------------------------------------------------------------------
|
170
|
+
--
|
171
|
+
-- NAME: Decrypt
|
172
|
+
--
|
173
|
+
-- DESCRIPTION:
|
174
|
+
--
|
175
|
+
-- Decrypt crypt text data using stream or block cipher with user
|
176
|
+
-- supplied key and optional iv.
|
177
|
+
--
|
178
|
+
-- PARAMETERS
|
179
|
+
--
|
180
|
+
-- cryptext - Crypt text data to be decrypted
|
181
|
+
-- crypto_type - Stream or block cipher type plus modifiers
|
182
|
+
-- key - Key to be used for encryption
|
183
|
+
-- iv - Optional IV for block ciphers. Default all zeros.
|
184
|
+
--
|
185
|
+
-- USAGE NOTES:
|
186
|
+
-- To retrieve original plain text data, Decrypt must be called
|
187
|
+
-- with the same cipher, modifiers, key and iv used for
|
188
|
+
-- encryption. If crypt text data was converted to hex or
|
189
|
+
-- base64 prior to storage, it must be decoded using HEXTORAW or
|
190
|
+
-- UTL_ENCODE.BASE64_DECODE prior to decryption.
|
191
|
+
--
|
192
|
+
------------------------------------------------------------------------
|
193
|
+
|
194
|
+
FUNCTION Decrypt (src IN RAW,
|
195
|
+
typ IN PLS_INTEGER,
|
196
|
+
key IN RAW,
|
197
|
+
iv IN RAW DEFAULT NULL)
|
198
|
+
RETURN RAW;
|
199
|
+
|
200
|
+
PROCEDURE Decrypt (dst IN OUT NOCOPY BLOB,
|
201
|
+
src IN BLOB,
|
202
|
+
typ IN PLS_INTEGER,
|
203
|
+
key IN RAW,
|
204
|
+
iv IN RAW DEFAULT NULL);
|
205
|
+
|
206
|
+
PROCEDURE Decrypt (dst IN OUT NOCOPY CLOB CHARACTER SET ANY_CS,
|
207
|
+
src IN BLOB,
|
208
|
+
typ IN PLS_INTEGER,
|
209
|
+
key IN RAW,
|
210
|
+
iv IN RAW DEFAULT NULL);
|
211
|
+
|
212
|
+
|
213
|
+
------------------------------------------------------------------------
|
214
|
+
--
|
215
|
+
-- NAME: Hash
|
216
|
+
--
|
217
|
+
-- DESCRIPTION:
|
218
|
+
--
|
219
|
+
-- Hash source data by cryptographic hash type.
|
220
|
+
--
|
221
|
+
-- PARAMETERS
|
222
|
+
--
|
223
|
+
-- source - Source data to be hashed
|
224
|
+
-- hash_type - Hash algorithm to be used
|
225
|
+
--
|
226
|
+
-- USAGE NOTES:
|
227
|
+
-- SHA-1 (HASH_SH1) is recommended. Consider encoding returned
|
228
|
+
-- raw value to hex or base64 prior to storage.
|
229
|
+
--
|
230
|
+
------------------------------------------------------------------------
|
231
|
+
|
232
|
+
FUNCTION Hash (src IN RAW,
|
233
|
+
typ IN PLS_INTEGER)
|
234
|
+
RETURN RAW DETERMINISTIC;
|
235
|
+
|
236
|
+
FUNCTION Hash (src IN BLOB,
|
237
|
+
typ IN PLS_INTEGER)
|
238
|
+
RETURN RAW DETERMINISTIC;
|
239
|
+
|
240
|
+
FUNCTION Hash (src IN CLOB CHARACTER SET ANY_CS,
|
241
|
+
typ IN PLS_INTEGER)
|
242
|
+
RETURN RAW DETERMINISTIC;
|
243
|
+
|
244
|
+
|
245
|
+
------------------------------------------------------------------------
|
246
|
+
--
|
247
|
+
-- NAME: Mac
|
248
|
+
--
|
249
|
+
-- DESCRIPTION:
|
250
|
+
--
|
251
|
+
-- Message Authentication Code algorithms provide keyed message
|
252
|
+
-- protection.
|
253
|
+
--
|
254
|
+
-- PARAMETERS
|
255
|
+
--
|
256
|
+
-- source - Source data to be mac-ed
|
257
|
+
-- mac_type - Mac algorithm to be used
|
258
|
+
-- key - Key to be used for mac
|
259
|
+
--
|
260
|
+
-- USAGE NOTES:
|
261
|
+
-- Callers should consider encoding returned raw value to hex or
|
262
|
+
-- base64 prior to storage.
|
263
|
+
--
|
264
|
+
------------------------------------------------------------------------
|
265
|
+
FUNCTION Mac (src IN RAW,
|
266
|
+
typ IN PLS_INTEGER,
|
267
|
+
key IN RAW)
|
268
|
+
RETURN RAW;
|
269
|
+
|
270
|
+
FUNCTION Mac (src IN BLOB,
|
271
|
+
typ IN PLS_INTEGER,
|
272
|
+
key IN RAW)
|
273
|
+
RETURN RAW;
|
274
|
+
|
275
|
+
FUNCTION Mac (src IN CLOB CHARACTER SET ANY_CS,
|
276
|
+
typ IN PLS_INTEGER,
|
277
|
+
key IN RAW)
|
278
|
+
RETURN RAW;
|
279
|
+
|
280
|
+
|
281
|
+
------------------------------------------------------------------------
|
282
|
+
--
|
283
|
+
-- NAME: RandomBytes
|
284
|
+
--
|
285
|
+
-- DESCRIPTION:
|
286
|
+
--
|
287
|
+
-- Returns a raw value containing a pseudo-random sequence of
|
288
|
+
-- bytes.
|
289
|
+
--
|
290
|
+
-- PARAMETERS
|
291
|
+
--
|
292
|
+
-- number_bytes - Number of pseudo-random bytes to be generated.
|
293
|
+
--
|
294
|
+
-- USAGE NOTES:
|
295
|
+
-- number_bytes should not exceed maximum RAW length.
|
296
|
+
--
|
297
|
+
------------------------------------------------------------------------
|
298
|
+
FUNCTION RandomBytes (number_bytes IN PLS_INTEGER)
|
299
|
+
RETURN RAW;
|
300
|
+
|
301
|
+
|
302
|
+
------------------------------------------------------------------------
|
303
|
+
--
|
304
|
+
-- NAME: RandomNumber
|
305
|
+
--
|
306
|
+
-- DESCRIPTION:
|
307
|
+
--
|
308
|
+
-- Returns a random Oracle Number.
|
309
|
+
--
|
310
|
+
-- PARAMETERS
|
311
|
+
--
|
312
|
+
-- None.
|
313
|
+
--
|
314
|
+
------------------------------------------------------------------------
|
315
|
+
FUNCTION RandomNumber
|
316
|
+
RETURN NUMBER;
|
317
|
+
|
318
|
+
|
319
|
+
------------------------------------------------------------------------
|
320
|
+
--
|
321
|
+
-- NAME: RandomInteger
|
322
|
+
--
|
323
|
+
-- DESCRIPTION:
|
324
|
+
--
|
325
|
+
-- Returns a random BINARY_INTEGER.
|
326
|
+
--
|
327
|
+
-- PARAMETERS
|
328
|
+
--
|
329
|
+
-- None.
|
330
|
+
--
|
331
|
+
------------------------------------------------------------------------
|
332
|
+
FUNCTION RandomInteger
|
333
|
+
RETURN BINARY_INTEGER;
|
334
|
+
|
335
|
+
|
336
|
+
PRAGMA RESTRICT_REFERENCES(DEFAULT, WNDS, RNDS, WNPS, RNPS);
|
337
|
+
|
338
|
+
END DBMS_CRYPTO;
|
339
|
+
/
|