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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch(core/url): Throw if VERDACCIO_FORWARDED_PROTO resolves to an array #4613

Merged
merged 2 commits into from
Jun 2, 2024

Conversation

Tobbe
Copy link
Contributor

@Tobbe Tobbe commented May 2, 2024

requestOptions.headers are of type IncomingHttpHeaders. This is a dictionary whose values can be string | string[] | undefined. Looking at all the keys we can see that only "set-cookie?" allows a value of type string[].

requestOptions.headers is used like this: requestOptions.headers[protoHeader]. So only if protoHeader has the value "set-cookie" can the returned value ever be an array. For all other values it's either going to be undefined or a string. So only for "set-cookie" will this code ever potentially throw this new error that is added in this PR.

So. If for some very very weird reason 馃檭 some user of Verdaccio has configured VERDACCIO_FORWARDED_PROTO to have the value "set-cookie" this is before and after this PR:

Before:
forwardedProtocolHeaderValue is an array of strings. This is passed to getWebProtocol. That function will in this case return requestOptions.protocol, which is the same behavior as if forwardedProtocolHeaderValue was undefined or an empty string. (So another option would be to just allow string arrays to be passed to getWebProtocol. Would you prefer that?)

After:
A (hopefully) helpful error is thrown, letting the user know they have most likely misconfigured their setup

Copy link
Member

@juanpicado juanpicado left a comment

Choose a reason for hiding this comment

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

LGTM

@juanpicado juanpicado merged commit 38b1e82 into verdaccio:master Jun 2, 2024
35 checks passed
@juanpicado juanpicado added this to the 5.x milestone Jun 2, 2024
@Tobbe Tobbe deleted the tobbe-core-url-throw-array branch June 3, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants