-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reader correctly handles postgres Arrays
- Loading branch information
Showing
9 changed files
with
202 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
[b=T, i=-42, e=SSH::LOG, c=21, p=123/unknown, sn=10.0.0.0/24, a=1.2.3.4, d=3.14, t=1454444233.58016, iv=100.0, s=hurz, sc={ | ||
2, | ||
4, | ||
1, | ||
0, | ||
3 | ||
}, ss={ | ||
'BB'}, | ||
'AA', | ||
{'CC' | ||
BB, | ||
AA, | ||
CC | ||
}, se={ | ||
|
||
}, vc=[0, 20, 30], ve=[]] | ||
}, vc=[10, 20, 30], ve=[]] | ||
[b=T, i=-43, e=SSH::LOG, c=21, p=123/unknown, sn=10.0.0.0/24, a=1.2.3.4, d=3.14, t=1454444233.58016, iv=100.0, s=hurz, sc={ | ||
2, | ||
4, | ||
1, | ||
3 | ||
}, ss={ | ||
{""},", | ||
\"\{}, | ||
NULL, | ||
, | ||
" | ||
}, se={ | ||
|
||
}, vc=[10, 20, 30], ve=[]] | ||
End of data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[b=T, i=-42, e=SSH::LOG, c=21, p=123/unknown, sn=10.0.0.0/24, a=1.2.3.4, d=3.14, t=1454444233.58016, iv=100.0, s=hurz, sc={ | ||
2, | ||
4, | ||
1, | ||
3 | ||
}, ss={ | ||
BB, | ||
AA, | ||
CC | ||
}, se={ | ||
|
||
}, vc=[10, 20, 30], ve=[]] | ||
End of data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# @TEST-SERIALIZE: postgres | ||
# @TEST-EXEC: initdb postgres | ||
# @TEST-EXEC: perl -pi.bak -E "s/#port =.*/port = 7772/;" postgres/postgresql.conf | ||
# @TEST-EXEC: pg_ctl start -D postgres -l serverlog | ||
# @TEST-EXEC: sleep 5 | ||
# @TEST-EXEC: createdb -p 7772 testdb | ||
# @TEST-EXEC: psql -p 7772 testdb < dump.sql || true | ||
# @TEST-EXEC: btest-bg-run bro bro %INPUT | ||
# @TEST-EXEC: btest-bg-wait 10 || true | ||
# @TEST-EXEC: pg_ctl stop -D postgres -m fast | ||
# @TEST-EXEC: btest-diff out | ||
|
||
@TEST-START-FILE dump.sql | ||
CREATE TABLE ssh ( | ||
id integer NOT NULL, | ||
b boolean, | ||
i integer, | ||
e text, | ||
c integer, | ||
p integer, | ||
sn inet, | ||
a inet, | ||
d double precision, | ||
t double precision, | ||
iv double precision, | ||
s text, | ||
sc text, | ||
ss text, | ||
se text, | ||
vc text, | ||
ve text, | ||
f text | ||
); | ||
|
||
CREATE SEQUENCE ssh_id_seq | ||
START WITH 1 | ||
INCREMENT BY 1 | ||
NO MINVALUE | ||
NO MAXVALUE | ||
CACHE 1; | ||
|
||
ALTER SEQUENCE ssh_id_seq OWNED BY ssh.id; | ||
ALTER TABLE ONLY ssh ALTER COLUMN id SET DEFAULT nextval('ssh_id_seq'::regclass); | ||
|
||
COPY ssh (id, b, i, e, c, p, sn, a, d, t, iv, s, sc, ss, se, vc, ve, f) FROM stdin; | ||
1 t -42 SSH::LOG 21 123 10.0.0.0/24 1.2.3.4 3.14000000000000012 1454444233.58016205 100 hurz 2,4,1,3 CC,AA,BB \N 10,20,30 \N SSHTest::foo\n{ \nif (0 < SSHTest::i) \n\treturn (Foo);\nelse\n\treturn (Bar);\n\n} | ||
\. | ||
|
||
SELECT pg_catalog.setval('ssh_id_seq', 1, true); | ||
ALTER TABLE ONLY ssh | ||
ADD CONSTRAINT ssh_id_key UNIQUE (id); | ||
|
||
@TEST-END-FILE | ||
|
||
|
||
redef exit_only_after_terminate = T; | ||
|
||
global outfile: file; | ||
|
||
|
||
type InfoType: record { | ||
b: bool; | ||
i: int; | ||
e: Log::ID; | ||
c: count; | ||
p: port; | ||
sn: subnet; | ||
a: addr; | ||
d: double; | ||
t: time; | ||
iv: interval; | ||
s: string; | ||
sc: set[count]; | ||
ss: set[string]; | ||
se: set[string]; | ||
vc: vector of count; | ||
ve: vector of string; | ||
# f: function(i: count) : string; | ||
}; | ||
|
||
event line(description: Input::EventDescription, tpe: Input::Event, r: InfoType) | ||
{ | ||
print outfile, r; | ||
} | ||
|
||
event bro_init() | ||
{ | ||
outfile = open("../out"); | ||
Input::add_event([$source="select * from ssh;", $name="postgres", $fields=InfoType, $ev=line, $want_record=T, | ||
$reader=Input::READER_POSTGRESQL, $config=table(["dbname"]="testdb", ["port"]="7772")]); | ||
} | ||
|
||
event Input::end_of_data(name: string, source:string) | ||
{ | ||
print outfile, "End of data"; | ||
close(outfile); | ||
terminate(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters