Commit Graph

64 Commits

Author SHA1 Message Date
Cody Cutrer c302dd8bc1 RuboCop: Style/SymbolArray, Style/WordArray
[skip-stages=Flakey]

auto-corrected

Change-Id: Id187ed60c5590025e780d81b85b5212f51368f27
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279196
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-23 14:30:08 +00:00
Cody Cutrer c776b6ef3a RuboCop: Style/CommentAnnotation
[skip-stages=Flakey]

auto-corrected

Change-Id: Ic82dbc22b8e63cc5f2ccb9b561cb3b9ed6628966
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279100
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-21 00:50:46 +00:00
Cody Cutrer ff99d18138 RuboCop: Style/RedundantSelf
[skip-stages=Flakey]

auto-corrected

Change-Id: I5f26ad1f8210a74c2198b514235d5134dcd0dae1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279070
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-11-20 16:41:21 +00:00
Cody Cutrer 16bb07021f RuboCop: Style/AndOr, Style/Not
auto-corrected

Change-Id: I410fc4618aa834c62fccf8370866e115b437386a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278802
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-19 22:22:35 +00:00
Cody Cutrer 4d43809cae RuboCop: Style/PercentLiteralDelimiters
[skip-stages=Flakey]

auto-corrected, with a post-review looking for multiline strings
to convert to heredocs

Change-Id: I7f7afb11edd63415cde10866822dd2ac5ba0d8be
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278669
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-18 23:05:50 +00:00
Cody Cutrer 157f0ae5d4 RuboCop: Style/RedundantPercentQ
[skip-stages=Flakey]

auto-corrected, with post review changing multiline strings into
heredocs

Change-Id: I1d4c543c936e5bf0ff5eb8bf10348652da7036c2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278652
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-18 20:26:13 +00:00
Cody Cutrer d91263c442 RuboCop: Style/ExpandPathArguments
auto-corrected, but so many tweaks after to gemspecs it may as well
have been manual

Change-Id: I69aeb6e216894462d6d893ed4c123aa9898fc72f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278516
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-17 22:06:59 +00:00
Cody Cutrer 294d98c6fd RuboCop: Style/MutableConstant
auto-corrected

Change-Id: Ib1b3c85711578a33014ea90f0662bd46f7b2288b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278214
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 16:19:54 +00:00
Cody Cutrer 4ff10e0e7c bump sanitize
to get its no-longer-dependency on nokogumbo

the major version bump was only for dropping ruby 2.5

Change-Id: I5a03053e8c3f800a39bcaa384fb5003fa489a2e1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277905
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-10 20:46:23 +00:00
Cody Cutrer 3474d36533 RuboCop: Lint/DuplicateBranch
all manual

Change-Id: Iafce1417d95b0d590774f55c769f2abeb139ea96
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277367
Tested-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2021-11-04 20:02:10 +00:00
Cody Cutrer 685f1d9791 RuboCop: Style/Encoding
[skip-stages=Flakey]

Change-Id: I4b16b64f7abb3769bb3ff3dd6146a1be03487a83
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274547
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-27 20:52:15 +00:00
Cody Cutrer 475cec61e5 RuboCop: RSpec/ExampleWording gems
[skip-stages=Flakey]

Change-Id: I7bd5d93d0ec4a95971f7ce8fbff8e76b5bfea5a2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274249
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-24 02:14:45 +00:00
Cody Cutrer dd8fc67c41 RuboCop: Layout gems
Change-Id: Ie49d89234f4ffed27236a1713d072a00f637a253
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274064
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-22 15:35:24 +00:00
Juan Chavez 46d4ccc999 RCE able to save flexbox and grid related properties
fixes MAT-346

flag=none

Test plan 1:
- Navigate to a RCE instance.
- Set HTML content using flexbox properties
Example: flex-direction, flex-wrap, flex-flow, etc.
- Save content.
- Verify that the content was saved with the flexbox
properties.

Test plan 2:
- Navigate to a RCE instance.
- Set HTML content using grid properties
Example: grid-row, grid-column, grid-template, etc.
- Save content.
- Verify that the content was saved with the grid
properties.

Change-Id: Iff2a57ad43d8526c5f477e0575e188aaa76b4f9f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/272776
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Gary Mei <gmei@instructure.com>
Product-Review: Juan Chavez <juan.chavez@instructure.com>
2021-09-02 16:37:02 +00:00
Gary Mei 205e5420fc allow more html/css in canvas-rce
closes MAT-89

Test Plan
- Test and verify that <track>, <picture>, <map>, <area>, <ruby>,
  and <blockquote> work.
- Test and verify that the CSS properties border-radius, grid, and
  flex work.

Change-Id: Ie9cdd2fc01bcd8d703afa784c2aa0e8ff136dcc7
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/266575
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Ed Schiebel <eschiebel@instructure.com>
Product-Review: David Lyons <lyons@instructure.com>
2021-06-11 16:11:24 +00:00
Ed Schiebel c445c8a85c Strip ridiculous css values MathJax might have added
closes MAT-42
flag=new_math_equation_handling

test plan:
This is not easy to test because you really should trigger whatever MathJax does. You could copy/paste
some bad HTML from a prod quiz into the RCE html editor, or use something like this:

<div style="border: 1px dashed red;">
  <span style="clip: rect(1e+07em, -9.999e+06em, -1e+07em, -999.997em);">this is a clip</span>
  <span style="display: inline-block; overflow: hidden; vertical-align: -1.17e+05em;">this is a vertical-align</span>
</div>

but ^that is what I used to test, so maybe you should try something else.

  - have some bad CSS in your RCE html, AND some math so MathJax is loaded
  > expect the crazy clip and vertical-align css attributes are stripped
    from the offending elements.

Change-Id: Icae13dc8656d2f9918c2b5315bd10089010a8029
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/262868
Reviewed-by: Nate Armstrong <narmstrong@instructure.com>
QA-Review: Nate Armstrong <narmstrong@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-04-14 21:19:29 +00:00
Cody Cutrer 6d14259077 add frozen_string_literal comment to engines and gems
Change-Id: Ifb661509145c16937c9f1c28803687b7cec4b3a4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/261815
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2021-03-30 18:14:15 +00:00
Cody Cutrer d69aa5ab29 avoid duplicate const warning in canvas_sanitize gem
Change-Id: Ic4f8f386213e5049bd2ad94b8cb8ce5aeaeba1c3
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/260713
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
QA-Review: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
2021-03-16 15:32:25 +00:00
Cody Cutrer 62fb86ea50 raise bundler minimum requirement
because of nokogiri, we rely on multi-platform gem caching, which
only works right in bundler 2.2

Change-Id: Id207278946e849abec3418807c71e4650506a0cf
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/259142
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-02-19 22:49:02 +00:00
Cody Cutrer 160ff3c899 bump sanitize to latest
[fsc-max-nodes=12]
[fsc-timeout=60]

 * switch lots of parsing to Nokogumbo to keep things consistent
 * deep CSS sanitization is now built in, and with a proper parser (meaning
   we can drop our code to do it, and adjust some specs to account for things
   that _are_ valid)

lots of changes because gumbo parsing<->serialization cycle is slightly different:
 * better job preserving original whitespace
 * literal non-breaking space characters are converted to &nbsp; entities
 * <p> tags aren't inserted for the heck of it
 * several _other_ entities are unnecessary, and output as literal characters
 * some elements no longer have a closing tag

Change-Id: I7c5e36cbd04b8a05f64c9e0af00868dd6b00f4ce
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/256444
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-02-17 18:17:57 +00:00
Cody Cutrer d6e044ff76 add # frozen_string_literal: true for embedded gems
Change-Id: Ib49bc8939cf1706e758429e531a87c57d0231a37
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251156
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2020-10-28 22:08:40 +00:00
Alex Anderson 6bbb46cf95 Fix sandbox "allow-popups" errors
Test Plan:
Let's make sure existing sandbox attributes are properly removed.
Change a page to have the following content:
<iframe src="https://docs.google.com/document/d/1054I9jXtjHmSwFUuj60YsyQ-DloZpORzBffO3KDdv2k" width="100%" height="600" sandbox="allow-scripts allow-forms allow-same-origin"></iframe>
Save
Clicking the 'Request Access' link should open up a confirm modal.
Don't see the error message in the devtools console

flag=none

Fixes CNVS-49914

Change-Id: I261e428185c01f2800c7a89131da2161b00e16ae
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244965
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Peyton Craighill <pcraighill@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
2020-08-13 19:30:06 +00:00
Jackson Howe e4e4bb5487 Allow skype: protocol in RCE
This updates canvas_sanitize gem to allow the skype: protocol in
links in the RCE.

Fixes LS-248
flag = rce_enhancements

Test plan:
 - Open RCE (fixes for new and old RCE)
 - Switch to HTML editor
 - Add <a href="skype:whatever?call">Call whatever</a>
 - Save
 - Click the link
 - Expect browser to open Skype (may present warning first,
   depending on browser)

See http://enarion.net/programming/c-sharp/skype/html-call/ for
an explanation of the skype protocol.

Note: In both the new and old RCE, adding a skype: link via the
rich content mode, will only work if the link is skype://username
(with the slashes) - skype:username will not work, but is being
addressed in the new RCE in LS-1232.

Change-Id: I03cc1be046cf79231538bd9ae7c32fa41ba62cd1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/243978
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Clint Furse <cfurse@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
2020-07-31 20:14:02 +00:00
Alex Anderson f354762d35 Include same-origin permission on iframes
The iframe sandboxing made it so media uploads
didn't properly render after being uploaded. This
is obviously a problem, so this patchset adds
the allow-same-origin sandbox permission to
all iframes.

This effectively reverts LS-743, so that ticket
was reopened so it can be addressed at a
later date.

This will need to be warm fixed.

Test Plan:
Upload media with the new RCE.
Save it.
The media should load correctly on the page.

Refs LS-743
Fixes LS-1260

Change-Id: I130af41a369d19ec02abf18682569a88d0a18f77
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/243902
QA-Review: Robin Kuss <rkuss@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jackson Howe <jackson.howe@instructure.com>
Product-Review: Alex Anderson <raanderson@instructure.com>
2020-07-30 20:17:30 +00:00
Alex Anderson df88e1361b Sandbox the file preview iFrame
Since files are hosted on the same domain as the Canvas
instance, it has access to localStorage, cookies, and
autofill passwords. This can be used to capture user data
for nefarious purposes through XSS.

This adds a `sandbox="allow-scripts allow-forms"` attribute
to the preview iframe to disallow same-origin behaviors.

This patchset also applies sandbox rules to iframes
embedded in user-generated content. This is done
with the onChange handler.

Test Plan:
This will be a little involved, so bear with me.
Log out of Canvas. On the login page, save the raw HTML
to your computer as a .html file. In Chrome this is done
with the "Save Page As..." option.

This will create an HTML page that copies the Canvas Login.
Then, go to the Files page for a course and upload this
HTML file.

Preview the HTML file. If you have autofill passwords enabled,
the username and password fields should not be filled in.

If you don't have autofill passwords enabled, that's okay.
Instead, open the preview for the HTML file.
Then open the dev tools. In the console, change your
JavaScript context from "top" to "preview". Then, try
to execute the following JavaScript (sans quotes):
`localStorage`
If this throws an error, it's working as expected.
If it logs the `localStorage` object, then the frame
still has access to the top origin.

To test user-generated content, navigate to an RCE,
and use the Raw HTML Editor to add an iframe. Close
the Raw HTML editor, make a change in the editor,
then and open the HTML editor again. The sandbox
attributes should have been added to your iframe.

flag=none

Refs LS-743

Change-Id: I9fe5660d8592423e6435d2b7ed6804b05c74200a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/243228
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jackson Howe <jackson.howe@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Alex Anderson <raanderson@instructure.com>
2020-07-29 13:01:19 +00:00
wdransfield ebd05a98da Allow "tel:" in anchor tag href attributes
Closes PLAT-5638
flag=none

Test Plan:
- Navigate to an RCE and switch to the html view
- attempt to add an anchor tag that uses the "tel"
  protocol in the href attribute
- Switch back away from the HTML editor and verify
  the link's href attribute remains correct

Change-Id: Ib0412001163f52bf5848297232946717c85d01be
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/231231
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Alex Slaughter <aslaughter@instructure.com>
Reviewed-by: Evan Battaglia <ebattaglia@instructure.com>
QA-Review: Tucker Mcknight <tmcknight@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2020-03-30 23:13:32 +00:00
Ed Schiebel 44efa212cd Unify tinymce's and canvas_sanitize's element whitelist
the allowed list of elements removed by canvas should never get
past the RCE

closes LA-526
flag=rce_enhancements

test plan:
  - using the html view, create some content in the RCE with
    disallowed elements (like main, form, select, button, script)
  - switch out of html view and back
  > expect the disallowed elements to have been removed, changed
    to something else, or html encoded
  - not sure how to test this, but canvas should never have to
    remove any elements from content created by the RCE

Change-Id: I89c1149e8b24451fc59e9a879b13e549504e1704
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/224717
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jon Willesen <jonw+gerrit@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
2020-02-06 19:30:34 +00:00
Jeremy Stanley 8eea293018 sanitize data-item-href in rich text
test plan:
 - before checking out this patch set, put the following text in
   a wiki page:
    <a class="external_url_link" href="#"
       data-item-href="javascript:alert('hi')">XSS</a>
   (note that reproducing the issue depends on a race condition;
   the page text must be present before the domready callbacks in
   context_modules.js run)
 - check out the patch set and note that clicking the link
   takes you to about:blank instead of running javascript
 - use the wiki pages API to try to inject the text from step 1
   into a page. the data-item-href attribute should be stripped

fixes LA-499
flag=none

Change-Id: I1ce377c9a386332ae336fc4ffe7a2bf257364a11
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/224051
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2020-01-23 17:24:17 +00:00
Ryan Shaw d6676fba80 Make sure if we treat data-* as html, it can be trusted
Fixes: CORE-2938 CORE-2937 CORE-2935 CORE-2933

We have a bunch of stuff in our code where we use data-whatever
attributes to tell our javascript what to do. and a few of those treat
whatever is in data-whatever as trusted html. The problem is that users
can save whatever data-* attributes in the content they save
in a rich text editor. So if they mimic the same classnames or ids as
elements we trust, they can exploit us. 

The fix is to still allow data-* attributes EXCEPT the ones we treat
as html. By filtering those out, we can treat them as trusted html.

Refs: SEC-2166 ADMIN-2376
This partially reverts ADMIN-2376 because instead of having to load all
tinyMCE to sanitize it on the client, if we treat it the same as all of
these other ones, we can just count on data-html-tooltip-title as coming
from us.

NOTE: in the future:
1. Don’t treat the Dom as the source of truth.
2. If you do, use an attribute like x-canvaslms-trusted-whatever
   because that will not be allowed through in our html sanitizer
   so we can know if that attribute is ever there on an element, 
   we put it there and not a user or hacker.

Test plan:
* Look at the repro steps on any of the attached jiras. 
* You should not be able to reproduce it
* there is an automated test fixture for each one that has been added
  To spec/fixtures/xss/

Change-Id: Idf77ac6d80518bfe02445f94942ac5f6802772dc
Reviewed-on: https://gerrit.instructure.com/194850
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2019-05-23 22:07:50 +00:00
Brent Burgoyne e942742d8e fix stored xss vulnerability in rce html editor
fixes CORE-2311

test plan:
- create/edit any rce content (page, discussion, assignment, etc)
- click "HTML Editor"
- add this html:
  <a data-url="javascript:alert('fail')" data-method="GET">Link</a>
- save
- the alert should not show

Change-Id: Ib6bd4aca4ae69c772f37e3d0b7d73e3241bb939c
Reviewed-on: https://gerrit.instructure.com/176818
Tested-by: Jenkins
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
2019-01-04 22:26:23 +00:00
Cody Cutrer fe4e1de02d bump sanitize
Change-Id: Ib355ba40253ce1884ebe6b18e36cf51e6fe575e4
Reviewed-on: https://gerrit.instructure.com/167205
Reviewed-by: James Williams <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2018-10-05 21:16:54 +00:00
Brent Burgoyne 4f0106f39a add mark tag to rce/html whitelist
clsoes CORE-1883

test plan:
- edit a wiki page
- switch to html editor
- add <mark>test</mark>
- save the page
- the mark tag should not be stripped out

Change-Id: Ic79b5554e0254b54797f78d5d4ab7e5e6c8281bf
Reviewed-on: https://gerrit.instructure.com/164510
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
QA-Review: Brent Burgoyne <bburgoyne@instructure.com>
2018-09-14 20:14:39 +00:00
Ryan Shaw 8f583f059b allow `longdesc` attribute in RCE editor for a11y
Fixes: CORE-1556

* go to an rich content editor
* add this markup with a “longdesc” attribute to the page
  <img 
    src=“https://placekitten.com/200/300” 
    longdesc=“http://www.example.com/“ 
  />
* save it
* reload the page
* make sure the longdesc attribute is still there

Change-Id: I8c57668e3c257ae186a7ea94c40dceb87835ca33
Reviewed-on: https://gerrit.instructure.com/155020
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
QA-Review: Nathan Rogowski <nathan@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2018-06-25 19:33:43 +00:00
Brent Burgoyne b4aa4ce75f whitelist iframe allow attribute for user content
this is only a temporary fix, until we have an account setting to
manage a whitelist of domains that allow the allow attribute.

fixes CORE-1157
refs CORE-1241

test plan:
- create/edit a wiki page
- click the HTML Editor link
- add an iframe with allow="microphone; camera"
- save the wiki page, and edit again
- view the html, it should still have the allow attribute

Change-Id: Ia1bc6507e830a6a1e91060fee7016f444f850ad7
Reviewed-on: https://gerrit.instructure.com/145695
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2018-04-06 20:42:49 +00:00
Cody Cutrer 6e2e0e13fe rails 5.1: fix a bunch of after_save deprecation warnings (part 2)
Change-Id: Ic6d1c46a6fb9616f1f07373974667978a2e44898
Reviewed-on: https://gerrit.instructure.com/144401
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-03-23 01:15:47 +00:00
Simon Williams e3e94e68a1 whitelist the 'controls' attribute for 'audio' html tags
fixes gh-1159

test plan:
- try to create an audio tag with the controls attribute
- it should persist across save

Change-Id: I84ec4ce6fecacdbaff91d8d53e8dde4b7ab5c736
Reviewed-on: https://gerrit.instructure.com/133028
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2017-12-05 21:05:27 +00:00
James Williams b7ab72ceeb master courses: descriptions with file links shouldn't break
test plan:
* in a blueprint course create an assignment, discussion and
a quiz all with a link to a file in their description
* lock content for all of them
* sync to a child course
* in the child course, should be able to edit dates without
getting an error

close #CNVS-38520

Change-Id: I0eb7331094871d8e2698ee1357fa2c0c16f3bd46
Reviewed-on: https://gerrit.instructure.com/122384
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: David Mirabile <dmirabile-c@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2017-08-14 17:05:49 +00:00
Landon Wilkins c5b5cc786d da licença part 53
add consistent license headers to all source files

Change-Id: I405d2def01ad68c76533b9254983497485cd7073
Reviewed-on: https://gerrit.instructure.com/110160
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-05-01 21:06:11 +00:00
Jon Jensen be84615841 bump simplecov, fixes SD-2056
test plan:
see coverage in previous rspec/selenium builds, same numbers as before

Change-Id: I331bf5102914da00a5d350f32b74b4bc9d49c5f8
Reviewed-on: https://gerrit.instructure.com/106895
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
2017-04-04 18:06:25 +00:00
Simon Williams c328c32a92 whitelist 'playsinline' for video elements
fixes CNVS-35749

test plan:
- make sure you can create a video tag in the RCE with the 'playsinline'
attribute
- general regression test of embeding video in the RCE (directly, from
a file, any other ways to get a video tag)

Change-Id: Ib7460ea8175d768e97b9b49acea67b8199bc4edf
Reviewed-on: https://gerrit.instructure.com/105709
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Tyler Pickett <tpickett@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2017-03-23 22:45:20 +00:00
Simon Williams 5719c1d455 whitelist <abbr> in tinymce
closes CNVS-34574

test plan:
- try to create rich content with the abbr tag
- it should work

Change-Id: I28ae285524fb671fc69709732976df2edd0d5d6d
Reviewed-on: https://gerrit.instructure.com/101164
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2017-02-08 03:31:04 +00:00
Simon Williams 5f3a8938c6 prevent storing scripts in mathml href tags
fixes CNVS-34785

test plan:
- try to create a math tag with a valid link, and with a stored script
- the valid link should work, but the stored script should be stripped

Change-Id: I1bec604d673d5ece23b238e1d81a292baa68fa6f
Reviewed-on: https://gerrit.instructure.com/101202
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2017-02-06 23:50:56 +00:00
Simon Williams 359c6dea13 upgrade many canvas gems to rspec 3 syntax
as of this commit, all canvas gems should be on rspec 3.5, and pass
without deprecation warnings.

closes CNVS-34040

test plan: specs should pass without deprecation warnings

Change-Id: I556b1a4a5aeb791c6ddd50ee35b51c513e025019
Reviewed-on: https://gerrit.instructure.com/98414
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
Tested-by: Jenkins
2016-12-27 18:44:23 +00:00
Simon Williams 8b04f05d4f support <track> elements in rich content
fixes CNVS-30404

test plan:
- add a video/audio with a track tag in the html editor
- toggle back and forth between rich text and html and make sure it
stays
- save and edit and make sure it stays

Change-Id: I18418ef98ed2c03d1a4901a4bf15cf82474c6131
Reviewed-on: https://gerrit.instructure.com/85159
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2016-07-16 13:20:25 +00:00
Aaron Cannon 8f48f69d06 A11y: Allow the insertion of MathML via the HTML editor
Fixes CNVS-28473

Test plan:
- Visit a page with an editor
- Switch to the HTML view.
- Insert MathML.
- Switch to and from the RCE editor and HTML editor.
- Verify that the MathML remains unchanged.
- Insure that it is not removed or otherwise redacted on save.

Change-Id: I46d55505518f0427fa342eff175a58bdcb0c5284
Reviewed-on: https://gerrit.instructure.com/79588
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Aaron Cannon <acannon@instructure.com>
QA-Review: Pierce Arner <pierce@instructure.com>
2016-06-27 15:30:37 +00:00
Dave Gynn a5744cdf59 Permit data-* attributes in HTML content
This PR allows data-* attributes in HTML to pass the santization process.
For example, this allows integration with Embedly if the content includes
HTML such as...
<a class="embedly-card" href="http://www.instructure.com/" data-card-controls="0" data-card-type="article">Instructure</a>
...and the appropriate JS is loaded.

Test Plan:
- Edit a wiki page using the HTML editor and enter custom HTML5 code that includes data attributes
- Verify the attributes exist in the HTML when the page is rendered

Note: This is minor version upgrade to sanitize. It does not upgrade to 3.x or 4.x
which could introduce more changes.
2016-04-20 10:15:58 -07:00
Cody Cutrer f552f4fc00 simplify gem test harnesses
rely on test_all_gems.sh to output header and trailer,
and use `set -e` in each test.sh to simplify passing
through errors

Change-Id: I3ba724ad2539ddfe31195394c43f646acfc73920
Reviewed-on: https://gerrit.instructure.com/70469
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2016-01-19 17:52:58 +00:00
Matthew Minuti 77e649f505 Adding HTML5 video capability. 2015-09-11 16:50:30 -04:00
Simon Williams 72415e8460 do some cleanup on gem test runs
* add test runner for broadcast_policy and fix a couple of tests that
  had been broken by accident
* add test runner for canvas_quiz_statistics and add a reference to
  iconv to it's Gemfile to allow tests to run in ruby 2
* add a test runner for canvas_sanitize
* remove leftover cruft from running gem builds in both rails 2 and 3

Change-Id: Iab2a0986f277a82c096e1fff2dab1d3a55b91733
Reviewed-on: https://gerrit.instructure.com/54518
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2015-05-18 22:39:17 +00:00
Cody Cutrer 9834937c8c don't autorequire a bunch of gems that are rarely used
Change-Id: I09ed3686629b62849d392684d587f30cb2047013
Reviewed-on: https://gerrit.instructure.com/51853
Tested-by: Jenkins
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-04-09 18:47:50 +00:00