Commit Graph

19 Commits

Author SHA1 Message Date
Jeremy Stanley a3cf4748cc check size of actual zip contents against quota
because the zip central directory can lie

test plan:
 1. Create a huge file (say a gigabyte) where every byte is the
    same.
 2. Zip it. The repeating data will be compressed. The ZIP will
    be tiny but will uncompress to a huge file.
 3. Edit the zip file binary. Open it with a hex editor and
    change the file size in the directory. Make the file
    appear to be small enough to fit into the course quota.
    (The zip file format is documented at
    http://www.pkware.com/documents/casestudies/APPNOTE.TXT
    or ask the committer for help)
 4. Try to import the zip file into a course (migrations/
    import zip file into folder)
 5. You should receive a quota error.

fixes CNVS-10722

Change-Id: Ib1bd1c432ef900f0c6c61ebe6eab2881f8515104
Reviewed-on: https://gerrit.instructure.com/29704
Reviewed-by: Mark Severson <markse@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Nathan Rogowski <nathan@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-06 19:29:27 +00:00
Jeremy Stanley 1e29a97ee0 rubyzip 1.0.0 upgrade
test plan: zip functionality should continue to work, including:
 * course exports and imports
 * zip file uploads
 * zip submissions

also, the selenium dependency on rubyzip 1.0.0 is resolved
and we're making progress toward > 4GB exports

Change-Id: I58c5b0644b1e7fbb289821c9c0901f00750988de
Reviewed-on: https://gerrit.instructure.com/25474
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
2013-11-22 19:23:34 +00:00
Cody Cutrer d935ab98b1 deprecate Setting.get_cached
now that we have SIGHUP, we were changing everything to it anyway,
so just let caching in-proc be the default

Change-Id: Id1b44722522ac9693b17695da7107c99a359d5ac
Reviewed-on: https://gerrit.instructure.com/25020
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-10 00:42:52 +00:00
James Williams c5fce200b0 don't submit imported/unzipped attachments to scribd
test plan:
* ensure scribd documents are rendered automatically
 when uploading single files to a course

* ensure scribd documents are not rendered automatically
when uploading a zip file full of documents to a course

* ensure scribd documents are not rendered automatically
when files are imported with a content migration package

* ensure scribd documents that were not rendered
automatically will be rendered on demand
(i.e., the first time they'll view with google docs
if available, or a "processing, try again" message
otherwise; later page loads should view the
document in scribd once it's done rendering)

fixes #CNVS-8078

Change-Id: Ibe821783e45dfa32b9bfdeb23b125237b45e9890
Reviewed-on: https://gerrit.instructure.com/24404
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-09-18 19:03:17 +00:00
Cody Cutrer 9a21afc90f backport fix for ruby bug
fixes CNVS-6947

test plan:
 * upload a file whose name begins with ~
 * download a zip of the folder the file is in
 * it should work

Change-Id: I828095b2dffe96805df5dc4921cfdce7c38af287
Reviewed-on: https://gerrit.instructure.com/22414
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-07-17 20:31:29 +00:00
Cody Cutrer 70781c4131 Kernel#returning is deprecated
Change-Id: I3efbab986f887525dc8ac178f1457a7b05aee0e8
Reviewed-on: https://gerrit.instructure.com/18535
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-03-12 13:44:03 -06:00
Jeremy Stanley 255e9d94b1 ruby 1.9: don't choke on course import with '~' filename
work around the issue where creating a temp file whose basename
starts with '~' fails on ruby 1.9

ruby issue: https://bugs.ruby-lang.org/issues/7547

test plan: try to import the course linked in the ticket

fixes #CNVS-2922

Change-Id: Iafbbae05c90dbef22e73e6311379e3aeee0a5f32
Reviewed-on: https://gerrit.instructure.com/16796
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2013-01-21 14:16:11 -07:00
Ethan Vizitei f1814d7762 Prevent malicious zip uploads
refs #11857

don't allow zip files with more than
100000 files to get attached

don't allow zip files that add enough
data (with a minimum file size of 512)
to go over the context quota

also refactor unzip_attachment.rb a
bit as long as we're in there because
it's a bit dense and monolithic.  There
is still much that could be done there,
but it's not one enormous method anymore.

TEST PLAN:
  1) login as any user with permissions
  to upload files.

  2) attempt to upload a zip archive with
  more than the configured max number of
  files inside of it (currently 100,000)

  3) you should get an error preventing
  this action from occuring and no
  new attachments should have been made
  to that context

  4) navigate to some context where the
  attachment quota is known.

  5) attempt to upload a zip archive to
  that context with enough size to exceed
  that quota.

  6) you should get an error preventing
  any of the new attachments from being
  attached to that context.

Change-Id: I35ce673e96fb98728cb36cfd27538fd802a249f2
Reviewed-on: https://gerrit.instructure.com/15671
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Clare Hetherington <clare@instructure.com>
2012-11-30 08:35:02 -07:00
Cameron Matheson b5f566f1f6 crocodoc integration
Adds support for optionally viewing documents with Crocodoc.

closes #9865

Test plan:
  * configure the crocodoc plugin
  * add an assignment that allows file uploads
  * make a submission for that assignment with a pdf or doc or ppt
    - on the 'submission details' page, opening a preview of the
      assignment should display it in crocodoc
    - speedgrader should display the submission in crocodoc too
  * make a submission with odt or rtf
    - the submission should be displayed with scribd or google docs
  * if you disable the crocodoc plugin, submissions could continue being
    previewed in google docs or scribd

Change-Id: I7dd2547f8e2d907c98ebe894a7f1ee9d58f1e030
Reviewed-on: https://gerrit.instructure.com/13668
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-09-21 12:57:02 -06:00
Jeremy Stanley 5b8524b14a Batch file notifications; closes #9012
Test plan:
(We need two users here because Canvas doesn't notify you about
files you upload yourself.  We'll call them Student and Teacher
here, but they don't actually have to be these things.)

 * As Student, enable notifications for new files in Profile.
 * As Teacher, upload a file.
 * Within an hour or so (everything about notifications occurs
   in low-priority background tasks), Student should receive
   a notification for the file.
 * As Teacher, upload multiple files.
 * Student should eventually receive a notification that
   X number of files were added.

Note that files are batched over a five-minute period; that is,
if a file is added to a course within five minutes of a previous
file, it will be counted in the same batch.

Change-Id: I09b5f497cae1d726b7aaf85824e98e69e45b0c1b
Reviewed-on: https://gerrit.instructure.com/12346
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2012-07-20 14:45:12 -06:00
Zach Wily accee8cc6b make zip file processing asynchronous
also fix/enable zip file uploads in group and user contexts -- they were
partially enabled, but broken. This required generalizing
UnzipAttachment to work for any context, not just courses, though that
was mostly just a matter of renaming things.

The zip file uploads in accounts are still not enabled, as the accounts
file section is not implemented yet, though it's referenced in the
routes file.

fixes #5913
fixes #5728
fixes #5463
fixes #5012

test plan:
  * upload a zip file to a course, to a group, and to a user's files. in
    each case, try uploading the zip both through the button in the file
    browser, and by dragging a zip file into the file browser (in a
    capable web browser)

Change-Id: I6c648ef677d2bd61ae41a2b8fe0f89be43d63375
Reviewed-on: https://gerrit.instructure.com/7402
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-02-29 14:04:53 -07:00
Zach Wily def5121fa7 try harder not to create scribd jobs for non-scribdable files
Somehow the after_attachment_saved callback in Attachment was getting called
on non-scribdable attachments with a workflow_state of 'processing'. We were
previously only skipping non-scribdable attachments if the workflow_state was
'pending_upload'. Now we will skip scribd processing for any non-scribdable
attachment, no matter it's state.

Also changed UnzipAttachment to only create a scribd job if there are any
scribdable attachments.

test plan:
 * Since we're not sure how the attachments originally got in the state
   described above, it's hard to describe repro steps. However, if you upload
   some images, they should not get scribd jobs created for them.

Change-Id: I7381af3f0928c2decf4f224834780cc90fbbc103
Reviewed-on: https://gerrit.instructure.com/8028
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-01-12 11:09:06 -07:00
Brian Palmer 3eadad2198 set max_attempts to 1 for submit_to_scribd
Change-Id: I02bd7189bf0d6a2c670cf1b6f4f301cf71a97a45
Reviewed-on: https://gerrit.instructure.com/6130
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2011-10-15 08:06:00 -06:00
Jacob Fugal 1a761c2d1f explicit utc db times in update_all
update_all's update hash doesn't have any magic performed on bare Time
objects; it assumes any Time object it's given is already in UTC. using
a TimeWithZone object (regardless of timezone), which Fixnum#ago and
friends happen to return, is still fine.

Change-Id: I297b2a3211b896b5225ebcfaaee3c1eb56e55fb6
Reviewed-on: https://gerrit.instructure.com/5351
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2011-08-30 16:46:25 -06:00
Brian Palmer b4d0163f2c fix race condition with unzipped files' tmp files
the tmp file was getting closed before FileInContext does its thing.

Change-Id: Ib2145552e18f9162c0ae87e5626bb5c6a12a3a0b
Reviewed-on: https://gerrit.instructure.com/4772
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
2011-08-26 16:18:01 -06:00
Brian Palmer b5e23ca1d0 safer regex of filenames to ignore in zips
Change-Id: I6aeba3c649999daf63b28d508d9861aa6e439444
Reviewed-on: https://gerrit.instructure.com/4771
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2011-07-22 13:57:42 -06:00
Brian Palmer 92feb2bcdb replace ActiveRecord::Base calls with subclass calls where it makes sense
This was already a small issue if the job queue was on a different
database driver than the main database, and it'll become more important
as more AR connections are introduced.

Change-Id: I204becadd32bb935df096e8c937a04bb6962f0b2
Reviewed-on: https://gerrit.instructure.com/4601
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2011-07-18 13:56:08 -06:00
Brian Palmer dac5bdf0ce handle repeated qti imports of the same filename better, closes #4411
Change-Id: I61d67d5005b9073e5c937611014f0929e45562d1
Reviewed-on: https://gerrit.instructure.com/3367
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2011-04-29 12:33:31 -06:00
Brian Whitmer 8b8173dcc9 Initial commit.
closes #6988138
2011-01-31 18:57:29 -07:00