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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(appname): encodeURIComponent for app name #8586

Merged
merged 16 commits into from
Oct 2, 2020

Conversation

german-muzquiz
Copy link
Contributor

Since the application name is a user supplied value, and that its rules may be changed with plugins, let's encode the url value on network requests.

Copy link
Member

@kevinawoo kevinawoo left a comment

Choose a reason for hiding this comment

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

LGTM, but since it's core, I'd like to make sure others are aware of the changes, namely @christopherthielen and @maggieneterval

I hope there isn't a function that would try to parse the name from the url, that would be pretty funky if it did. I think it's unlikely since we're pretty good at passing around the app/pipeline contexts around in memory.

@christopherthielen
Copy link
Contributor

This seems like something we should do in the API code itself, not at every call site. I haven't investigated to find out if that is possible, however.

@german-muzquiz
Copy link
Contributor Author

That was my first option, but then I saw some code like this one calling the API methods with multiple uri components in one string instead of splitting them.
Probably we would need to fix those calls first before doing URI encoding in the API.

@german-muzquiz
Copy link
Contributor Author

@christopherthielen what do you think about fixing calls to API to not use more than one uri component and encode in API, vs the current implementation in the PR?

@christopherthielen
Copy link
Contributor

I think we could do something like url.split('/').map(segment => encodeUriComponent(segment)).join('/') in the API code and then remove any manual encodeUriComponent() calls that are being passed to API.one()/API.all()

@german-muzquiz
Copy link
Contributor Author

What if an application name includes / as part of its name, like myapp/db?
I think it's safer to encode in API without the split and fix the code to do API.one('slack', 'channels') instead of API.one('slack/channels')

@christopherthielen
Copy link
Contributor

I'm fairly certain that an application nameed myapp/db would break everything in spinnaker everywhere 😆

That said, I think your solution is good and we should do that instead.

@christopherthielen
Copy link
Contributor

We can also write a linter rule in https://github.com/spinnaker/deck/tree/master/packages/eslint-plugin that warns and auto-fixes this if somebody passes a string literal with a / char.

@german-muzquiz
Copy link
Contributor Author

@christopherthielen I made the changes for encoding in API service and fixed calls to not use / or encodeURIComponent. The idea of the linter rule is good but I'm not familiar with them, do you think it could be a separate PR?

Comment on lines 100 to 101
const uri = '/plugins/deck/plugin-manifest.json';
const loadPromise = API.one(uri)
const loadPromise = API.one(...uri.split('/').slice(1))
Copy link
Contributor

Choose a reason for hiding this comment

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

API.one('plugins', 'deck', 'plugin-manifest.json');
?

@christopherthielen
Copy link
Contributor

christopherthielen commented Sep 29, 2020

The idea of the linter rule is good but I'm not familiar with them, do you think it could be a separate PR?

Yes, of course.

LGTM, just a couple minor suggestions

@christopherthielen christopherthielen added the ready to merge Reviewed and ready for merge label Oct 2, 2020
erikmunson pushed a commit that referenced this pull request Oct 5, 2020
80858e7 feat(core/managed): limit artifact versions to 30 (#8623)
90a2819 feat(core/managed): put constraints in a 'skipped' state on skipped versions (#8620)
815742d feat(core/managed): scroll to selected version in sidebar, update scroll containers (#8618)
de24ef3 feat(core/managed): apply consistent sorting to resources (#8622)
3735483 fix(core/pipeline): Always enable "show revision history" in edit pipeline dialog (#8621)
abffd84 fix(core/managed): fixup some details from new layout (#8619)
f1bb04e fix(appname): encodeURIComponent for app name (#8586)
60c0c7b feat(validation): Allow app name validators to be overridden (#8584)
erikmunson pushed a commit that referenced this pull request Oct 5, 2020
f1bb04e fix(appname): encodeURIComponent for app name (#8586)
erikmunson pushed a commit that referenced this pull request Oct 5, 2020
f1bb04e fix(appname): encodeURIComponent for app name (#8586)
erikmunson pushed a commit that referenced this pull request Oct 5, 2020
f1bb04e fix(appname): encodeURIComponent for app name (#8586)
erikmunson pushed a commit that referenced this pull request Oct 5, 2020
f1bb04e fix(appname): encodeURIComponent for app name (#8586)
mergify bot pushed a commit that referenced this pull request Oct 5, 2020
…e@0.0.516 docker@0.0.60 google@0.0.21 oracle@0.0.9 tencentcloud@0.0.6 (#8624)

* chore(amazon): publish amazon@0.0.269

f1bb04e fix(appname): encodeURIComponent for app name (#8586)

* chore(azure): publish azure@0.0.255

f1bb04e fix(appname): encodeURIComponent for app name (#8586)

* chore(cloudfoundry): publish cloudfoundry@0.0.101

f1bb04e fix(appname): encodeURIComponent for app name (#8586)

* chore(core): publish core@0.0.516

80858e7 feat(core/managed): limit artifact versions to 30 (#8623)
90a2819 feat(core/managed): put constraints in a 'skipped' state on skipped versions (#8620)
815742d feat(core/managed): scroll to selected version in sidebar, update scroll containers (#8618)
de24ef3 feat(core/managed): apply consistent sorting to resources (#8622)
3735483 fix(core/pipeline): Always enable "show revision history" in edit pipeline dialog (#8621)
abffd84 fix(core/managed): fixup some details from new layout (#8619)
f1bb04e fix(appname): encodeURIComponent for app name (#8586)
60c0c7b feat(validation): Allow app name validators to be overridden (#8584)

* chore(docker): publish docker@0.0.60

f1bb04e fix(appname): encodeURIComponent for app name (#8586)

* chore(google): publish google@0.0.21

f1bb04e fix(appname): encodeURIComponent for app name (#8586)

* chore(oracle): publish oracle@0.0.9

f1bb04e fix(appname): encodeURIComponent for app name (#8586)

* chore(tencentcloud): publish tencentcloud@0.0.6

f1bb04e fix(appname): encodeURIComponent for app name (#8586)
caseyhebebrand added a commit to caseyhebebrand/deck that referenced this pull request Oct 6, 2020
mergify bot pushed a commit that referenced this pull request Oct 6, 2020
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit that referenced this pull request Oct 6, 2020
885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
mergify bot pushed a commit that referenced this pull request Oct 6, 2020
…e@0.0.517 docker@0.0.61 google@0.0.22 oracle@0.0.10 tencentcloud@0.0.7 (#8630)

* chore(amazon): publish amazon@0.0.270

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)

* chore(azure): publish azure@0.0.256

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)

* chore(cloudfoundry): publish cloudfoundry@0.0.102

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)

* chore(core): publish core@0.0.517

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)

* chore(docker): publish docker@0.0.61

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)

* chore(google): publish google@0.0.22

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)

* chore(oracle): publish oracle@0.0.10

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)

* chore(tencentcloud): publish tencentcloud@0.0.7

885cd16 Revert "fix(appname): encodeURIComponent for app name (#8586)" (#8627)
christopherthielen added a commit to christopherthielen/deck that referenced this pull request Oct 12, 2020
christopherthielen added a commit to christopherthielen/deck that referenced this pull request Jan 18, 2021
christopherthielen added a commit to christopherthielen/deck that referenced this pull request Jan 18, 2021
christopherthielen added a commit to christopherthielen/deck that referenced this pull request Jan 18, 2021
christopherthielen added a commit to christopherthielen/deck that referenced this pull request Jan 18, 2021
christopherthielen added a commit to christopherthielen/deck that referenced this pull request Jan 18, 2021
mergify bot added a commit that referenced this pull request Jan 20, 2021
Re-submittal of reverted PR #8586

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Reviewed and ready for merge target-release/1.23
Projects
None yet
4 participants