Skip to content

adding sri modal to codeorigin #391

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

Closed
wants to merge 15 commits into from
Closed

adding sri modal to codeorigin #391

wants to merge 15 commits into from

Conversation

jmervine
Copy link
Contributor

@jmervine jmervine commented Feb 2, 2016

Hello!

Per the discussions on gh:jquery/codeorigin.jquery.com#20 I'm adding the SRI modal as an onclick popin for each cdn file link. This is in direct support of gh:jquery/codeorigin.jquery.com#22. I've attached a screenshot of the result here:

screen shot 2016-02-01 at 6 25 35 pm

Notes:

  • I'm not 100% about the method used to include both style and script tags in the correct location. I attempted to use wp_enqueue_script and wp_enqueue_style respectively, without success. I'm new to Wordpress, so I may have been doing something incorrectly. Any direction here would be appreciated.
  • I did my best to follow the style guide. I apologies if I missed anything. I'm happy to make any updates necessary. That said, the versioned css and js files includes were added as is from their sources.

Thanks and cheers!
J

(cc @jdorfman @scottgonzalez)

@jdorfman
Copy link
Contributor

jdorfman commented Feb 2, 2016

Looks good to me

@dmethvin
Copy link
Member

dmethvin commented Feb 8, 2016

LGTM but I'll defer to @scottgonzalez who has been following this more closely and knows the setup better.

@mgol
Copy link
Member

mgol commented Feb 8, 2016

Do we want to have a page with hashes for all past versions for people that can't yet download the newest one?

@scottgonzalez
Copy link
Member

Do we want to have a page with hashes for all past versions for people that can't yet download the newest one?

The hashes are already computed for every version. I've also suggested that we expose https://code.jquery.com/resources/sri-directives.json in jquery/codeorigin.jquery.com#22 (comment)

@mgol
Copy link
Member

mgol commented Feb 8, 2016

The hashes are already computed for every version.

Where are they kept?

I've also suggested that we expose https://code.jquery.com/resources/sri-directives.json in jquery/codeorigin.jquery.com#22 (comment)

Since the goal of the SRI is to prevent injecting a rogue script in case of a CDN poisoning, putting a file listing the hashes on this very CDN doesn't sound like the best option.

@scottgonzalez
Copy link
Member

Where are they kept?

Umm...they're generated on deploy for the CDN. I'm getting the feeling you haven't looked at the related PR.

Since the goal of the SRI is to prevent injecting a rogue script in case of a CDN poisoning, putting a file listing the hashes on this very CDN doesn't sound like the best option.

And the values that every user will insert into their scripts comes directly from the CDN. I'm not sure where else these would be listed.

@mgol
Copy link
Member

mgol commented Feb 8, 2016

Umm...they're generated on deploy for the CDN. I'm getting the feeling you haven't looked at the related PR.

Yeah, sorry, I see it now.

And the values that every user will insert into their scripts comes directly from the CDN. I'm not sure where else these would be listed.

Those values are needed only for developers, end users don't download them. Hence, the CDN is not necessary for that, they may as well be kept somewhere on our sites, i.e. places that are separate from CDNs. We'd have to first switch our sites to HTTPS-only, though.

@scottgonzalez
Copy link
Member

Hence, the CDN is not necessary for that, they may as well be kept somewhere on our sites, i.e. places that are separate from CDNs. We'd have to first switch our sites to HTTPS-only, though.

I'm really not sure what setup you have in mind. It would certainly require whatever other random site you choose to have the CDN as a dependency for getting the hashes.

@mgol
Copy link
Member

mgol commented Feb 8, 2016

I'm really not sure what setup you have in mind. It would certainly require whatever other random site you choose to have the CDN as a dependency for getting the hashes.

Only for past releases; new ones are generated offline, on a computer of the person doing the release.

@scottgonzalez
Copy link
Member

Only for past releases; new ones are generated offline, on a computer of the person doing the release.

I'm not sure how you got that impression. The hash will always be generated by the production build server during deploy. Perhaps you can explain why you think this would not be the case based on the other PR.

@dmethvin
Copy link
Member

dmethvin commented Feb 9, 2016

I think the scenario that the SRI integrity hash is addressing is this one:

  • You start development for your web site and decide to use files from the CDN.
  • You calculate the integrity hash and include it in the script tags referencing the CDN.
  • If the files are later changed on the CDN, for example by an attacker, the integrity hash will not match and the code will not run.

If someone hacks jquery-1.11.1.js on the web site months after it's put down, there should be thousands if not millions of web sites with the correct hash value, they would be protected, and we'd know about the problem in short order.

That's why I'm hesitant to fix the map reference in the minified jQuery 1.9.1 file by editing it. Anyone using SRI or keeping their own hashes would notice that the file has been changed two years after it was put on the CDN.

// attach custom header and footer tags
function header_append() {
echo '
<link rel="stylesheet" href="' . get_template_directory_uri() . '/css/font-awesome.css" />
Copy link
Member

Choose a reason for hiding this comment

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

Font Awesome is already loaded on the page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw it in the themes/jquery/css directory, but not included. I'l drop this out.

@jmervine
Copy link
Contributor Author

jmervine commented Feb 9, 2016

@scottgonzalez Thanks for the feedback, comments. I'll address / answer shortly. Dealing with some other fires elsewhere at the moment.

@jmervine
Copy link
Contributor Author

@scottgonzalez I've addressed some of the low hangers. I'll get back to the rest shortly. I didn't work up the client side js/css, and have asked @jdorfman to review those parts, he or I will start addressing those parts next.

Cheers!

PS: I will most certainly squash commits once all comments have been address. :)

@jdorfman
Copy link
Contributor

we close @scottgonzalez ?

@jmervine
Copy link
Contributor Author

@scottgonzalez I believe I've addressed all open comments aside from https://github.com/jquery/jquery-wp-content/pull/391/files#r52310552, which is pending comments. Let me know if I missed anything.

Cheers!
J

cc: @jdorfman

&nbsp;&nbsp;<span>crossorigin="anonymous"&gt;&lt;/script&gt;</span>
</code>

<button class="sri-modal-copy-btn"
Copy link
Member

Choose a reason for hiding this comment

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

This button should start with a title and have the tooltip initialized so that the feature is discoverable.

@jmervine
Copy link
Contributor Author

@scottgonzalez All outstanding comments have been addressed as far as I can tell. Let me know if I missed anything or if there's anything else.

Cheers!

@jdorfman
Copy link
Contributor

jdorfman commented Mar 9, 2016

Let's :shipit:

@scottgonzalez
Copy link
Member

It's finally live :-)

Thanks for all the work.

@jdorfman
Copy link
Contributor

@scottgonzalez awesome! Thank you =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants