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

fix nested captured groups indexing in replace stage #3381

Merged
merged 5 commits into from
Feb 26, 2021

Conversation

adityacs
Copy link
Collaborator

@adityacs adityacs commented Feb 25, 2021

What this PR does / why we need it:
If there is a nested captured group ex: (?P<ip_user>^(?P<ip>\\S+) (?P<identd>\\S+) (?P<user>\\S+)) and log line 11.11.11.11 - frank , FindAllStringSubmatchIndex would return the matched index list [[0 19 0 19 0 11 12 13 14 19]]. There is a complete match 0-19 and other submatches 0-11, 12-13 .... This caused slice bounds out of range error in the old code when concatenating the matched entry. This PR fixes this issue.

Which issue(s) this PR fixes:
Fixes #3353

Checklist

  • Tests updated

@adityacs adityacs changed the title fixes nested captured groups indexing in replace stage fix nested captured groups indexing in replace stage Feb 25, 2021
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@slim-bean slim-bean merged commit f14ddb8 into grafana:master Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Promtail: pipeline_stage with replace stages causes panic
3 participants