Skip to content

feat(api): add query depth limit#1096

Merged
michalkrzyz merged 1 commit intomainfrom
kanstantsinbuklis-sap/issue-1063/add-query-depth-limit
Feb 16, 2026
Merged

feat(api): add query depth limit#1096
michalkrzyz merged 1 commit intomainfrom
kanstantsinbuklis-sap/issue-1063/add-query-depth-limit

Conversation

@kanstantsinbuklis-sap
Copy link
Collaborator

Description

In this PR I've added depth limit for queries to avoid DoS attacks using nested relationships

What type of PR is this? (check all applicable)

  • [+] 🍕 Feature

Related Tickets & Documents

Added tests?

  • [+] 👍 yes

Two types of requests occur in the e2e tests:

  1. with a depth exceeding the limit - in this case, we'll receive an error
  2. with a depth less than the limit - the error is nil

Added to documentation?

  • [+] 🙅 no documentation needed

)

const (
depthLimit = 10
Copy link
Collaborator

Choose a reason for hiding this comment

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

use util/config

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to util/config

dbm.TestTearDown(db)
})

When("request with large depth", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

'Request with depth exceeding limit' would be more precise

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed

})
})

When("request with normal depth", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider 'Request with allowed depth`

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed

Services model.ServiceConnection `json:"Services"`
}

err := util2.RequestWithBackoff(func() error { return client.Run(ctx, req, &respData) })
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be best to create helper e2e_common.ExecuteGqlQuery which will be extracted from: e2e_common.ExecuteGqlQueryFromFile (and used in here and in e2e_common.ExecuteGqlQueryFromFile)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created

@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1063/add-query-depth-limit branch from a89d552 to 21ac8ff Compare February 16, 2026 16:43
@kanstantsinbuklis-sap kanstantsinbuklis-sap force-pushed the kanstantsinbuklis-sap/issue-1063/add-query-depth-limit branch from 21ac8ff to c9501b7 Compare February 16, 2026 16:59
@michalkrzyz michalkrzyz merged commit 96fee4b into main Feb 16, 2026
8 checks passed
@michalkrzyz michalkrzyz deleted the kanstantsinbuklis-sap/issue-1063/add-query-depth-limit branch February 16, 2026 17:01
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.

feat(api): add query depth limit

2 participants