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

Implement client-side version checking #79

Merged
merged 1 commit into from
Jan 3, 2018
Merged

Conversation

siggy
Copy link
Member

@siggy siggy commented Dec 20, 2017

Previously Conduit would render an iframe, received from
versioncheck.conduit.io.

Modify the client to retrieve the latest released version, via CORS.

version check performing

version check up to date

version check update

version check error

@siggy siggy self-assigned this Dec 20, 2017
@rmars rmars added the area/web label Dec 21, 2017
return "Conduit is up to date";
} else {
return (<div>
A new version ({this.state.latest}) is available<br />
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know anything about react. What ensures that this is safe w.r.t. xss? I.e. let's say this.state.latest is "<script>alert("hi");</script>", does this syntax do the escaping to make that safe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question!

I modified my test response to be:

{
  "version": "<script>alert('hi');</script>"
}

...and got:

screen shot 2017-12-22 at 3 39 15 pm

Is that sufficient? If there's a more malicious way to craft that json, I can try it pretty quickly.

Copy link
Member

Choose a reason for hiding this comment

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

And you're correct @briansmith -- the {...} syntax has built in escaping, documented here: https://reactjs.org/docs/jsx-in-depth.html#string-literals-1

Copy link
Contributor

Choose a reason for hiding this comment

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

@siggy @klingerf Thanks! I agree that's what's wanted.

Copy link

@rmars rmars left a comment

Choose a reason for hiding this comment

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

😻 thanks for taking this on!
I haven't done as much investigation into you as this, but I was wondering whether fetch allows us to do this without adding another library?

text-decoration: none;
}
& a.button:active {
background-color: #2F80ED;
Copy link

Choose a reason for hiding this comment

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

would advise you to use the color var from styles.css since we're importing that file anyway.... also looking at that file, we have that color defined twice :/ we should probably consolidate. (though if we want to have a separate file for styles directly copied, we can)

}

loadFromServer() {
if (this.state.done) {
Copy link

Choose a reason for hiding this comment

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

variable naming nit: we've been using pendingRequests for this elsewhere, it'd be nice to use the same name

it('renders update message when versions do match', () => {
loadFromServer = setResponse(null, {responseText: "{\"version\": \"v2.3.4\"}"});

// must wrap Version in a BrowserRouter because this test case renders a Link,
Copy link

Choose a reason for hiding this comment

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

@franziskagoltz added a routerWrap function in testHelpers, maybe we can use that?

Copy link
Member Author

Choose a reason for hiding this comment

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

i could not find a way to make routerWrap work with properties, so leaving this as is.


/* from https://conduit.io/ */

& a.button {
Copy link

Choose a reason for hiding this comment

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

Since we probably want to use the same styles everywhere if we add future buttons, I'd put the a.button styles in styles.css (or create a buttons.css, if we want to just have an isolated "coped this from conduit.io styles" file)

let loadFromServer;

function setResponse(err, resp) {
return sinon.stub(Version.prototype, 'loadFromServer').callsFake(function fakeFn() {
Copy link

Choose a reason for hiding this comment

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

whoa, cool

Copy link
Member Author

Choose a reason for hiding this comment

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

yup... though removing this because fetch does what we need!

@briansmith
Copy link
Contributor

My main interest in this is the security-critical stuff, which seems to have been addressed so +1 from me.

However, I wonder where the best place to format the output really is. It seems like with the proposed change we have less flexibility than if we were to do the formatting on our own host. For example, how would we indicate in the web UI the update's urgency, e.g. a critical security update vs. a "whenever you get around to it" update? It seems like it would be good to let the server give us some free-form text to describe the urgency, at least.

@siggy
Copy link
Member Author

siggy commented Dec 23, 2017

@briansmith I agree some kind of richer free-form messaging here is a good idea. I'd like to defer it for a subsequent PR. As our version check endpoint is json (kevin's bright recommendation), we can iterate on it and add fields in a backwards compatible way. I've filed #90 to track this.

@siggy siggy force-pushed the siggy/version-check branch 2 times, most recently from 3d77b9b to b3b9478 Compare December 28, 2017 06:13
@xiaods
Copy link
Contributor

xiaods commented Dec 28, 2017

versioncheck.conduit.io/update is public domain, could you please consider enterprise-level environment, it can't directly access internet directly.

@siggy
Copy link
Member Author

siggy commented Dec 28, 2017

@xiaods fair point. i think for this initial PR we'll hit the public URL. i could imagine future versions supporting some kind of proxy setting to enable outside internet access (or something else entirely). if you have more thoughts, please summarize them in a Github issue so we can consider it for our roadmap.

Copy link

@rmars rmars left a comment

Choose a reason for hiding this comment

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

🌟 🙌 🚀 yayy! thanks for doing this!

Just had a couple small comments.

super(props);
this.loadFromServer = this.loadFromServer.bind(this);
this.handleApiError = this.handleApiError.bind(this);
this.state = {err: null, latest: null, loaded: false, pendingRequests: false,};
Copy link

Choose a reason for hiding this comment

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

extra trailing comma

.version {
padding: 0 0 0 9px;
font-size: 13px;
font-weight: 700;
Copy link

Choose a reason for hiding this comment

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

nit: --font-weight-bold

this.setState({
loaded: true,
pendingRequests: false,
err: e
Copy link

Choose a reason for hiding this comment

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

nit: in other places we do this we use "error" and I'd prefer us to be consistent

Copy link

@rmars rmars left a comment

Choose a reason for hiding this comment

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

🐑 thanks for updating!

Previously Conduit would render an iframe, received from
versioncheck.conduit.io.

Modify the client to retrieve the latest released version, via CORS.

Signed-off-by: Andrew Seigner <andrew@sig.gy>
@siggy siggy merged commit 449f306 into master Jan 3, 2018
@siggy siggy deleted the siggy/version-check branch January 3, 2018 00:07
@siggy siggy added this to the 0.1.2 milestone Jan 11, 2018
khappucino pushed a commit to Nordstrom/linkerd2 that referenced this pull request Mar 5, 2019
In preparation for further simplifications to HTTP telemetry, this
change consolidates all HTTP-specific logic under the `telemetry::http`
module.

Specifically, the following modules have been moved:
- `telemetry::event`;
- `telemetry::metrics::labels`;
- `telemetry::metrics::record`;
- `telemetry::sensors`; and
- `telemetry::sensors::http`.

This change takes pains to avoid changing any implementation details, so
some types and methods have been made public temporarily while the
interface boundaries are not well defined. This will be fixed in a
subsequent change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants