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

basicfuncs: add list-search function #2955

Merged
merged 7 commits into from
Dec 13, 2019
Merged

Conversation

alltilla
Copy link
Collaborator

@alltilla alltilla commented Oct 2, 2019

Returns with the index of the first match of keyword in the list.
Starts the search at start_index. 0 based. If not found, returns empty string.

New usage:

  • Literal match:
    $(list-search <pattern> ${list})
    or
    $(list-search --mode literal <pattern> ${list})
  • Prefix match: $(list-search --mode prefix <pattern> ${list})
  • Substring match: $(list-search --mode substring <pattern> ${list})
  • Glob match: $(list-search --mode glob <pattern> ${list})
  • Regex match: $(list-search --mode pcre <pattern> ${list})

Add --start-index <index> to change the start index.

Implements #2924

TODO:

  • Add starting position
  • Add backwards search
  • Support regex, glob, etc...
  • Support prefix, substring
  • Cleanup commits

Signed-off-by: Attila Szakacs attila.szakacs@balabit.com

@alltilla alltilla changed the title basicfuncs: add list-search function [WIP] basicfuncs: add list-search function Oct 2, 2019
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Build SUCCESS

1 similar comment
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Build SUCCESS

modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
modules/basicfuncs/tests/test_basicfuncs.c Outdated Show resolved Hide resolved
modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
@alltilla alltilla changed the title [WIP] basicfuncs: add list-search function basicfuncs: add list-search function Oct 4, 2019
@bazsi
Copy link
Collaborator

bazsi commented Oct 4, 2019 via email

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@alltilla
Copy link
Collaborator Author

alltilla commented Oct 4, 2019

@Kokan, @bazsi:
Yeah, this is I believe the 3rd implementation of pcre now :/
Should I do the refactor in this PR, or before/after it?

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@Kokan
Copy link
Collaborator

Kokan commented Oct 4, 2019

Because that refactor requires to change the LogMatcher that has effect on many modules/functionality; and the logic can be cut off from this change request I would do it in a different PR.
The current PR is imho okay to merge, as the list-search implementation only effects the new code.
You could resolve the "conflict" when one of them is merged.

Short: do it "later" / in parallel.

But I am fine with whatever schedule as well.

@alltilla alltilla added this to the syslog-ng-3.25 milestone Oct 8, 2019
@gaborznagy gaborznagy self-requested a review October 11, 2019 07:35
Kokan
Kokan previously approved these changes Oct 11, 2019
Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change list-search to TEMPLATE_FUNCTION

modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
modules/basicfuncs/list-funcs.c Outdated Show resolved Hide resolved
@alltilla alltilla changed the title basicfuncs: add list-search function [WIP] basicfuncs: add list-search function Oct 22, 2019
@alltilla alltilla changed the title [WIP] basicfuncs: add list-search function basicfuncs: add list-search function Nov 22, 2019
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Build SUCCESS

1 similar comment
@kira-syslogng
Copy link
Contributor

Build SUCCESS

Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the missing tf_simple_* calls and using the correct input for the scanner.

@alltilla alltilla force-pushed the list_search branch 2 times, most recently from 8c38891 to b3e1cbd Compare December 3, 2019 13:30
@kira-syslogng
Copy link
Contributor

Build SUCCESS

Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@kira-syslogng
Copy link
Contributor

Build SUCCESS

gaborznagy
gaborznagy previously approved these changes Dec 7, 2019
Copy link
Collaborator

@gaborznagy gaborznagy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides a minor improvement idea, approve!

modules/basicfuncs/list-funcs.c Show resolved Hide resolved
@bazsi
Copy link
Collaborator

bazsi commented Dec 7, 2019 via email

Usage:
 * Literal match:
     `$(list-search <pattern> ${list})`
     or
     `$(list-search --mode literal <pattern> ${list})`
 * Prefix match: `$(list-search --mode prefix <pattern> ${list})`
 * Substring match: `$(list-search --mode substring <pattern> ${list})`
 * Glob match: `$(list-search --mode glob <pattern> ${list})`
 * Regex match: `$(list-search --mode pcre <pattern> ${list})`

Add `--start-index <index>` to change the start index.

Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
It matches the beginning of the string with the pattern.

Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
It matches any part of the string with the pattern.

Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
Matches the string with shell style globbing.

Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
Matches the string with pcre style regular expression.

Signed-off-by: Attila Szakacs <attila.szakacs@balabit.com>
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@Kokan Kokan merged commit 7034af0 into syslog-ng:master Dec 13, 2019
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 this pull request may close these issues.

5 participants