Skip to content

Add validation of custom grok patterns file #18

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

Closed
Marusyk opened this issue Jul 25, 2021 · 9 comments · Fixed by #23
Closed

Add validation of custom grok patterns file #18

Marusyk opened this issue Jul 25, 2021 · 9 comments · Fixed by #23

Comments

@Marusyk
Copy link
Owner

Marusyk commented Jul 25, 2021

Context

The support of custom grok patterns was added in #15

Just add the directory with name Patterns and a file (the file name doesn't matter) with your own patterns.

Like Patterns\grok-custom-patterns:

ZIPCODE [1-9]{1}[0-9]{2}\s{0,1}[0-9]{3}

and use:

Grok grok = new Grok("%{ZIPCODE:zipcode}:%{EMAILADDRESS:email}");
var grokResult = grok.Parse($"122001:[email protected]");

IndexOutOfRangeException

There is an issue when that custom file has the wrong content.

How to reproduce

Add to the Patterns\grok-custom-patterns the following data:

pattern

How to fix

Add some validation on load of custom grok file content. It should be pattern name, space, then the regexp for that pattern

@Marusyk Marusyk added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jul 25, 2021
@ManasviGoyal
Copy link
Contributor

ManasviGoyal commented Jul 28, 2021

@Marusyk please elaborate so that i can get started

@Marusyk
Copy link
Owner Author

Marusyk commented Jul 29, 2021

@ManasviGoyal thanks for your interest. You can start whenever you want

@ManasviGoyal
Copy link
Contributor

ManasviGoyal commented Jul 29, 2021

@Marusyk how is this different from #19 ?
most of things are already added

@Marusyk
Copy link
Owner Author

Marusyk commented Jul 29, 2021

@ManasviGoyal this is about bug IndexOutOfRangeException and about adding some validation
#19 was about adding documentation to the README
Please see description of the issue carefully

@Marusyk
Copy link
Owner Author

Marusyk commented Aug 4, 2021

Hi @ManasviGoyal, are you still working on that?

@ManasviGoyal
Copy link
Contributor

Hi @ManasviGoyal, are you still working on that?

I am busy with some work this month. You can can assign it someone else. No issue with me.

@MazixM
Copy link

MazixM commented Aug 18, 2021

Hi, i would like to try to fix it. Can i?

@GioMaz
Copy link
Contributor

GioMaz commented Aug 19, 2021

Hello, I would like to contribute to this issue as well

@Marusyk
Copy link
Owner Author

Marusyk commented Aug 22, 2021

Hi @MazixM and @GioMaz,
Thanks for your interest.
You need to create a Pull Request with changes. Then we can choose the best one

Marusyk pushed a commit that referenced this issue Sep 4, 2021
* #18 custom pattern validation

* Unit test for wrong custom pattern

* Check if custom pattern is correct

* moved pattern validation inside ProcessPatternLine

* throw FormatException on wrong custom pattern load

* Check if pattern is valid

* Added const value for LoadWrongCustomPatterns

* removed unnecessary `String.Format`

Co-authored-by: Giovanni Maria Zanchetta <[email protected]>
@Marusyk Marusyk removed enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants