vorax 0.4.2 → 5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README.md +4 -29
  2. data/vorax.gemspec +3 -11
  3. metadata +4 -92
  4. data/.rspec +0 -1
  5. data/Rakefile +0 -30
  6. data/lib/vorax.rb +0 -60
  7. data/lib/vorax/base_funnel.rb +0 -30
  8. data/lib/vorax/output/html_convertor.rb +0 -120
  9. data/lib/vorax/output/html_funnel.rb +0 -79
  10. data/lib/vorax/output/pagezip_convertor.rb +0 -20
  11. data/lib/vorax/output/tablezip_convertor.rb +0 -22
  12. data/lib/vorax/output/vertical_convertor.rb +0 -53
  13. data/lib/vorax/output/zip_convertor.rb +0 -117
  14. data/lib/vorax/parser/argument.rb~ +0 -125
  15. data/lib/vorax/parser/conn_string.rb +0 -104
  16. data/lib/vorax/parser/grammars/alias.rb +0 -904
  17. data/lib/vorax/parser/grammars/alias.rl +0 -138
  18. data/lib/vorax/parser/grammars/column.rb +0 -454
  19. data/lib/vorax/parser/grammars/column.rl +0 -64
  20. data/lib/vorax/parser/grammars/common.rl +0 -107
  21. data/lib/vorax/parser/grammars/declare.rb +0 -9606
  22. data/lib/vorax/parser/grammars/declare.rl +0 -160
  23. data/lib/vorax/parser/grammars/for_block.rb +0 -440
  24. data/lib/vorax/parser/grammars/for_block.rl +0 -73
  25. data/lib/vorax/parser/grammars/plsql_def.rb +0 -539
  26. data/lib/vorax/parser/grammars/plsql_def.rl +0 -73
  27. data/lib/vorax/parser/grammars/statement.rb +0 -925
  28. data/lib/vorax/parser/grammars/statement.rl +0 -83
  29. data/lib/vorax/parser/parser.rb +0 -344
  30. data/lib/vorax/parser/plsql_structure.rb +0 -222
  31. data/lib/vorax/parser/plsql_walker.rb +0 -143
  32. data/lib/vorax/parser/statement_inspector.rb~ +0 -52
  33. data/lib/vorax/parser/stmt_inspector.rb +0 -78
  34. data/lib/vorax/parser/target_ref.rb +0 -110
  35. data/lib/vorax/sqlplus.rb +0 -273
  36. data/lib/vorax/version.rb +0 -7
  37. data/lib/vorax/vorax_io.rb +0 -70
  38. data/spec/column_spec.rb +0 -40
  39. data/spec/conn_string_spec.rb +0 -53
  40. data/spec/declare_spec.rb +0 -281
  41. data/spec/pagezip_spec.rb +0 -153
  42. data/spec/parser_spec.rb +0 -352
  43. data/spec/plsql_structure_spec.rb +0 -68
  44. data/spec/spec_helper.rb +0 -13
  45. data/spec/sql/create_objects.sql +0 -69
  46. data/spec/sql/dbms_crypto.spc +0 -339
  47. data/spec/sql/dbms_stats.spc +0 -4097
  48. data/spec/sql/drop_user.sql +0 -10
  49. data/spec/sql/muci.spc +0 -26
  50. data/spec/sql/setup_user.sql +0 -22
  51. data/spec/sql/test.fnc +0 -12
  52. data/spec/sql/test.pkg +0 -83
  53. data/spec/sqlplus_spec.rb +0 -52
  54. data/spec/stmt_inspector_spec.rb +0 -96
  55. data/spec/tablezip_spec.rb +0 -111
  56. data/spec/vertical_spec.rb +0 -150
@@ -1,68 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- include Vorax
4
-
5
- describe 'plsql structure' do
6
-
7
- before(:each) do# {{{
8
- @result = ""
9
- end# }}}
10
-
11
- def compute_tree(node, level = 0)# {{{
12
- if node.is_root?
13
- @result << "*"
14
- else
15
- @result << "|" unless node.parent.is_last_sibling?
16
- @result << (' ' * (node.level - 1) * 4)
17
- @result << (node.is_last_sibling? ? "+" : "|")
18
- @result << "---"
19
- @result << (node.has_children? ? "+" : ">")
20
- end
21
-
22
- @result << " #{node.name} - #{(node.content ? node.content.end_pos : '')} -> begin=#{(node.content ? node.content.body_start_pos : '')}\n"
23
-
24
- node.children { |child| compute_tree(child, level + 1)}
25
- end# }}}
26
-
27
- it 'should work for complex plsql code' do# {{{
28
- text = File.open('spec/sql/test.pkg', 'rb') { |file| file.read }
29
- structure = Parser::PlsqlStructure.new(text)
30
- compute_tree(structure.tree)
31
- @result.should eq(<<STR
32
- * root - -> begin=
33
- |---+ test[SPEC]: 25 - 154 -> begin=0
34
- | |---> test[PROCEDURE]: 61 - 61 -> begin=0
35
- | +---> muci[FUNCTION]: 91 - 91 -> begin=0
36
- +---+ test[BODY]: 180 - 1672 -> begin=1635
37
- |---+ private_proc[PROCEDURE]: 232 - 1373 -> begin=454
38
- | |---> abc[FUNCTION]: 325 - 392 -> begin=360
39
- | |---> xyz[PROCEDURE]: 403 - 449 -> begin=424
40
- | |---+ for[FOR_BLOCK]: 485 - 1042 -> begin=530
41
- | |---> if[IF_BLOCK]: 563 - 636 -> begin=564
42
- | +---+ if[IF_BLOCK]: 645 - 1016 -> begin=646
43
- |---+ if[IF_BLOCK]: 667 - 924 -> begin=668
44
- | +---> for[FOR_BLOCK]: 691 - 858 -> begin=736
45
- +---> if[IF_BLOCK]: 935 - 1002 -> begin=936
46
- | |---> if[IF_BLOCK]: 1088 - 1167 -> begin=1089
47
- | +---> loop[LOOP_BLOCK]: 1223 - 1318 -> begin=1224
48
- |---+ test[PROCEDURE]: 1378 - 1544 -> begin=1410
49
- | +---> anonymous[BLOCK]: 1466 - 1537 -> begin=1461
50
- +---> muci[FUNCTION]: 1549 - 1632 -> begin=1603
51
- STR
52
- )
53
- end# }}}
54
-
55
- it 'should work for a function' do# {{{
56
- text = File.open('spec/sql/test.fnc', 'rb') { |file| file.read }
57
- structure = Parser::PlsqlStructure.new(text)
58
- compute_tree(structure.tree)
59
- @result.should eq(<<STR
60
- * root - -> begin=
61
- +---+ test[FUNCTION]: 18 - 134 -> begin=118
62
- +---> muci[PROCEDURE]: 78 - 115 -> begin=97
63
- STR
64
- )
65
- end# }}}
66
-
67
- end
68
-
@@ -1,13 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- $LOAD_PATH << File.expand_path('../../lib', __FILE__)
4
-
5
- # Initialize the VORAX_TEST_CSTR environment variable with
6
- # the user/pwd@db connection string, pointing to VORAX test
7
- # user, or change the below line accordingly.
8
- VORAX_CSTR = "connect #{ENV['VORAX_TEST_CSTR']}"
9
-
10
- require 'tempfile'
11
- require 'timeout'
12
- require 'vorax'
13
-
@@ -1,69 +0,0 @@
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
@@ -1,339 +0,0 @@
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
- /