Skip to content

feat: frontend middleware to block matching urls#3963

Merged
joe-elliott merged 7 commits intografana:mainfrom
javiermolinar:url-black-list
Aug 16, 2024
Merged

feat: frontend middleware to block matching urls#3963
joe-elliott merged 7 commits intografana:mainfrom
javiermolinar:url-black-list

Conversation

@javiermolinar
Copy link
Copy Markdown
Contributor

@javiermolinar javiermolinar commented Aug 14, 2024

What this PR does:
It provides a mechanism to refuse requests based on a regex blacklist. A new middleware was created and executed the first in the query pipeline. Any request that matches will return a 400 status code response.

Due to the way we build the pipeline I decided to make the new middleware as an AsyncMiddleware, that way it can be executed first in the chain. We should explore the possibility of having just one type of middleware so that they can run in any order regardless of their work.

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

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Comment thread modules/frontend/pipeline/black_list_middleware.go Outdated
Comment thread docs/sources/tempo/configuration/_index.md Outdated
Comment thread modules/frontend/pipeline/deny_list_middleware.go Outdated
func (c urlDenylistWare) validateRequest(url string) error {
for _, v := range c.denyList {
if v.MatchString(url) {
return fmt.Errorf("Invalid request %s, URL is blacklisted", url)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will likely show up in Grafana, let's try:

"Invalid request %s. This query has been identified as one that destabilizes our system. Contact your system administrator for more information"

@joe-elliott joe-elliott merged commit 3e20eb2 into grafana:main Aug 16, 2024
@javiermolinar javiermolinar deleted the url-black-list branch August 16, 2024 13:50
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.

Create a configurable list of TraceQL queries that are immediately 400'ed

2 participants