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

Sets do not support pattern types. #412

Closed
0xekez opened this issue Jun 14, 2019 · 5 comments
Closed

Sets do not support pattern types. #412

0xekez opened this issue Jun 14, 2019 · 5 comments
Assignees
Labels
Area: Scripting good first issue A good place to get started working with Zeek. Type: Enhancement

Comments

@0xekez
Copy link
Contributor

0xekez commented Jun 14, 2019

Creating a set of patterns

local s: set[pattern] = {/hello/, /goodbye/};

gives an error error in pattern: bad index type (pattern).

This might just be a matter of making a change to the index type checking for tables here.

@jsiwek
Copy link
Contributor

jsiwek commented Jun 14, 2019

Don't think there's a reason why not not allow it, at least anymore. Likely would also have to update the CompHash.cc code.

@0xekez 0xekez added the good first issue A good place to get started working with Zeek. label Jul 3, 2019
@devbali devbali self-assigned this Nov 4, 2019
@devbali
Copy link
Contributor

devbali commented Nov 5, 2019

Check out this branch: https://github.com/zeek/zeek/tree/topic/dev/patterns-in-sets
I just took the PatternText(), AnywherePatternText() of the Regular Expression Objects and concatenated them to initialize a Hashkey to support single type sets using Patterns.
If this approach is fine I will add btests and open a PR

@jsiwek
Copy link
Contributor

jsiwek commented Nov 5, 2019

@devbali yes, think you've got the basic idea, with a couple pointers:

  • Completing this requires adding support to other CompositeHash methods like SingleValHash, SingleTypeKeySize, and RecoverOneVal
  • For the (de)serialization of patterns, you'll probably find that instead of "null-terminated and delimited with a space character", these are probably better to serialize as two "length of string followed by those N bytes" fields. Can look at how plain strings are handled for an example of this.

@devbali
Copy link
Contributor

devbali commented Dec 20, 2019

Just came back to this today. Opened a Pull Request, please take a look after you come back after Christmas.

@jsiwek
Copy link
Contributor

jsiwek commented Jan 6, 2020

Fixed via #714

@jsiwek jsiwek closed this as completed Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Scripting good first issue A good place to get started working with Zeek. Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants