Comments (6)
Thanks @alexzorin! This message helped identify a couple scanner bugs I had to fix.
I do have a nugget for you tho. Assuming you just want to consume all the tokens to the end of the string, you can do something like
%msgtime% H = ( %srchost% ) [ %srcipv4% ] : %srcport% F = < %srcemail% > %action% RCPT < %dstemail% > : %reason-%
Notice the %reason-%
field, basically the "-" tells the parser to consume the rest of the tokens and put them in the %reason%
field. So "sender verify failed" will be put into %reason%
in this case.
I haven't written much about it yet as I am still trying to test out a few meta characters to see how to make it easier for parsing.
Try it and let me know if it works for you.
Thanks for your help!
[edit: the - only works with Field types, and not Token types, at least not at this time. I should fix that]
from sequence.
Oh, very cool, thanks
from sequence.
Given your thoughts from the blog post about performance characteristics of regex parsers etc I think its doubtful, but do you think it would be within the realm of possibility in your scanner to do greedy consumption in the middle of a log string? Such as
# for messages ending in 'blah blah'
%time% %string-% blah blah
from sequence.
Certainly possible, though I don't think scanner is the place to do it. I try to keep the scanner purely for simple tokenization. However, we can do something in the parser.
In fact, if you have the following message and rule:
jan 14 10:15:56 testserver sudo: this is a weird log blah blah
%msgtime% %apphost% %appname% : %reason+% blah blah
Notice the "+" in the %reason% token, it tells the parser to continue adding %reason% fields until it hits the first "blah". The output is not exactly what I want yet:
%msgtime% "jan 14 10:15:56"
%apphost% "testserver"
%appname% "sudo"
%literal% ":"
%reason% "this"
%reason% "is"
%reason% "a"
%reason% "weird"
%reason% "log"
%literal% "blah"
%literal% "blah"
What I really want is to concatenate the 5 %reason% tokens into one...so stay tuned.
from sequence.
@alexzorin , I updated the parser to allow *, + and - as meta commands.
- * means consume 0 or more tokens
- + means consume 1 or more tokens
- - means consume the rest of the tokens
All three will merge the multiple tokens recognized.
So your rule can be written as as any of the following:
"%msgtime% h = ( %srchost% ) [ %srcip% ] : %srcport% f = < %srcemail% > %action% rcpt < %dstemail% > : %reason:-%",
"%msgtime% h = ( %srchost% ) [ %srcip% ] : %srcport% f = < %srcemail% > %action% rcpt < %dstemail% > : %reason:+%",
"%msgtime% h = ( %srchost% ) [ %srcip% ] : %srcport% f = < %srcemail% > %action% rcpt < %dstemail% > : %reason:*%",
Let me know if you can test it out.
thx
Jian
from sequence.
Thanks, I'll try it out on my exim rules
from sequence.
Related Issues (20)
- Readme doesn't say how to run / build HOT 6
- Sequence can't handle Chinese HOT 2
- No output to `stdout` when output file flag is empty HOT 1
- Sequences with URI's are not matched correctly HOT 1
- URI's starting with "//" are not tokenized correctly HOT 1
- '|' (pipe character) causes error during analyze HOT 2
- Path not correctly analyse HOT 1
- ipv6 address not tokenized properly HOT 2
- syslog-ng patterndb integration HOT 1
- data folder is missing in the root directory HOT 1
- Been working on sequence for the last 2 months - would love to discuss HOT 3
- Why does the html tag identify as a tag. HOT 1
- unit test failed in analyzer_test.go HOT 1
- integer with trailing dot recognized as float HOT 1
- time not recognized at end of line HOT 2
- Unknown token encountered HOT 4
- relaxing types HOT 3
- show message counts HOT 3
- iostat output - split over multiple lines, and in multi-line table HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sequence.