Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More flexible signature "event" interface #3403

Closed
ckreibich opened this issue Oct 24, 2023 Discussed in #3372 · 0 comments · Fixed by #3478
Closed

More flexible signature "event" interface #3403

ckreibich opened this issue Oct 24, 2023 Discussed in #3372 · 0 comments · Fixed by #3478

Comments

@ckreibich
Copy link
Member

Discussed in #3372

Originally posted by vpax October 12, 2023
Currently, Zeek's signature framework supports the generation of a single event:

event signature_match(state: signature_state, msg: string, data: string)

and when writing signatures, all that's specified is the msg that goes with that event:

signature my-first-sig {
    ip-proto == tcp
    dst-port == 80
    payload /.*root/
    event "Found root!"
}

We've been developing Zeek scripts that need to dispatch on the particular signature matched. Currently this requires a bunch of comparisons of msg (and these can happen in different instances of signature_match event handlers, depending on the modularity associated with the content). An extension to deal with this would be to allow the event specifier in a signature to optionally be the name of an event to generate, rather than a string to associate with it:

signature my-first-sig {
    ip-proto == tcp
    dst-port == 80
    payload /.*root/
    event my_first_sig_event
}

(the event value could instead be a string like now, in which case signature_match is generated), or perhaps:

signature my-first-sig {
    ip-proto == tcp
    dst-port == 80
    payload /.*root/
    event "Found root!"
    zeek_event my_first_sig_event
}

where the given event would have to have a common type signature (which for the second example could be the same as the signature_match event).

This seems handy and pretty straightforward to implement. Thoughts?

awelzel added a commit that referenced this issue Nov 29, 2023
This change allows to specify a per signature specific event, overriding
the default signature_match event. It further removes the message
parameter from such events if not provided in the signature.

Closes #3403
awelzel added a commit that referenced this issue Nov 29, 2023
This change allows to specify a per signature specific event, overriding
the default signature_match event. It further removes the message
parameter from such events if not provided in the signature.

Closes #3403
awelzel added a commit that referenced this issue Nov 30, 2023
This change allows to specify a per signature specific event, overriding
the default signature_match event. It further removes the message
parameter from such events if not provided in the signature.

This also tracks the message as StringValPtr directly to avoid
allocating the same StringVal for every DoAction() call.

Closes #3403
awelzel added a commit that referenced this issue Dec 4, 2023
This change allows to specify a per signature specific event, overriding
the default signature_match event. It further removes the message
parameter from such events if not provided in the signature.

This also tracks the message as StringValPtr directly to avoid
allocating the same StringVal for every DoAction() call.

Closes #3403
awelzel added a commit that referenced this issue Dec 4, 2023
This change allows to specify a per signature specific event, overriding
the default signature_match event. It further removes the message
parameter from such events if not provided in the signature.

This also tracks the message as StringValPtr directly to avoid
allocating the same StringVal for every DoAction() call.

Closes #3403
@awelzel awelzel closed this as completed in a7b077a Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants