Skip to content

remove trailing slash for overrideUrlName#216

Merged
jordiprats merged 0 commit into
armory:masterfrom
jordiprats:master
Aug 17, 2022
Merged

remove trailing slash for overrideUrlName#216
jordiprats merged 0 commit into
armory:masterfrom
jordiprats:master

Conversation

@jordiprats

@jordiprats jordiprats commented Feb 8, 2021

Copy link
Copy Markdown

Hi,
This PR is for fixing what could be also considered as a configuration mistake. If you set overrideBaseUrl to an url with a trailing slash as follows:

        apiSecurity:
          overrideBaseUrl: http://whatever.com/
        uiSecurity:
          overrideBaseUrl: http://whatever.com/

It looks like everything is fine but if you click on the source link on any pipeline you'll get this error message:

The request was rejected because the URL contained a potentially malicious String

Taking a look at the URL you'll realize there's a double slash after the hostname which leads to this error. On my PR you'll find the code needed for ignoring this final slash: It doesn't even matter if you remove it or add the final slash: the operator won't even bother updating the containers because it's just ignored

kind regards,

@jordiprats

Copy link
Copy Markdown
Author

Regading the failed build looks like it's something unrelated to the code:


Run docker login -u  -p "" registry.redhat.io
"docker login" requires at most 1 argument.
See 'docker login --help'.

Usage:  docker login [OPTIONS] [SERVER]

Log in to a Docker registry
Error: Process completed with exit code 1.

@jordiprats jordiprats changed the title remore trailing slash for overrideUrlName remove trailing slash for overrideUrlName Feb 9, 2021
var overrideUrlName_sanitized string
// ignore error, overrideBaseUrl may not be set in hal config
statusUrl, _ := t.svc.GetSpinnakerConfig().GetHalConfigPropString(ctx, overrideUrlName)
if overrideUrlName[len(overrideUrlName)-1:] == "/" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should leverage strings and do strings.HasPrefix(overrideUrlName, "/")

if strings.HasPrefix(overrideUrlName, "/") {
    overrideUrlName = overrideUrlName[:len(overrideUrlName) - 1]
}

You could drop the else and the additional variable.

@jordiprats

jordiprats commented Mar 18, 2021

Copy link
Copy Markdown
Author

Good point, although it is actually HasSuffix: tests whether the string s ends with suffix.

I have pushed an amended commit for this

@jordiprats

Copy link
Copy Markdown
Author

This change is quite straightforward and it's going to help users avoid getting stuck with this issue. Can someone take a look?

@ichi0915

Copy link
Copy Markdown
Contributor

Thank you for this, I don't have permissions to merge this until the actions have passed let me see who can help us get this merge

@ichi0915

Copy link
Copy Markdown
Contributor

@jordiprats can you help us rebasing to the latest commits in master or maybe create an empty commit just to re-run the actions and see the output.

@jordiprats

Copy link
Copy Markdown
Author

@ichi0915 sorry I messed up with this PR, I have created a new one with the change rebased: #267

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.

3 participants