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

Querier/Ingester: Fixing json expression parser bug #3928

Merged

Conversation

dannykopping
Copy link
Contributor

@dannykopping dannykopping commented Jul 1, 2021

What this PR does / why we need it:
Fixes a tight loop in the JSON expression lexer, which results from unexpected input.

Which issue(s) this PR fixes:
N/A

Special notes for your reviewer:
We discovered that a query with a JSON expression like {stream="foo"} | json key="something.["else caused our ingesters to crash (because we were searching for recent data - it'd crashed queriers if for older data).

This bug occurred because we only break out of the scan loop if a string is terminated " or a closing bracket is found ] - but we don't check for a null byte or EOF which both indicate end of input.

Checklist

  • Documentation added
  • Tests updated

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
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

Copy link
Collaborator

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

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

🎉

Danny Kopping added 2 commits July 1, 2021 13:33
@dannykopping
Copy link
Contributor Author

Note: I've pulled main and fixed the linter issue introduced in the previous commit:
https://drone.grafana.net/grafana/loki/3286/1/3

@dannykopping dannykopping merged commit 71889dc into grafana:main Jul 1, 2021
@dannykopping dannykopping deleted the dannykopping/json-parser-bug branch July 1, 2021 11:45
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.

None yet

4 participants