-
Notifications
You must be signed in to change notification settings - Fork 45
fix(odata-service-writer): avoid double slashes when adding new odata service #3197
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
Conversation
avoid double slashes when adding new data service
🦋 Changeset detectedLatest commit: 70fc4ab The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
* @returns The input string with leading and trailing slashes removed. | ||
*/ | ||
function trimSlashes(input: string): string { | ||
while (input.startsWith('/')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be used as an attack vector? Consider a limit on string size, or use regex with same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think you would need to add a character limit anyway or Sonar would complain about DOS attack. Previously we needed to limit the '/' check.
// We remove trailing slashes (up to 10, infinite would allow DOS attack) from the host to avoid double slashes when appending the service path.
this._destinationUrl = servicePath
? destUrl.replace(
`https://${destination.Name.toLowerCase()}.dest`,
destination.Host.replace(/\/{1,10}$/, '')
)
: destination.Host;
Problem happens if we pass service like:
then double forward slash is added here:

As fix - sanitize trailing slashes before creating uri for
settings.localUri
- trimSlashes