Commit Graph

72 Commits

Author SHA1 Message Date
Andrew Huff 85beafc23e support streaming download from instfs
closes RECNVS-61

test plan:
* create an assignment as a teacher
* while instfs is running and enabled, submit a submission to the
  assignment as a student; verify (e.g. with the `dc up` output
  in instfs) that it was stored in instfs
* click the "Download all submissions" button as the teacher
* Verify the downloaded zip contains the file you uploaded as a student

Change-Id: I5ce3cd1a983dc340181ef8602ace48d542f641a5
Reviewed-on: https://gerrit.instructure.com/143078
Tested-by: Jenkins
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
2018-03-10 21:49:17 +00:00
Simon Williams 7cb2e4c05e don't worry about deleted children in attachment gc
also restore to the right state

refs CNVS-38273

Change-Id: I461ee4b35be39ade249069a96f69f1ccf5b7dae7
Reviewed-on: https://gerrit.instructure.com/119513
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-07-18 20:03:39 +00:00
Simon Williams 0799281bfa fix attachment gc dealing with re-parenting child attachments
when we make_childless, we copy the data, so it still needs to be
deleted from the original attachment.

fixes CNVS-38273

test plan:
- run a content export, and then upload the package to your user files
- run the attachment gc
- the export attachment should be deleted (including content), but the
user file version should still exist

Change-Id: Ia41090f45a0d580183583e0680e8ca27bdc2b0d4
Reviewed-on: https://gerrit.instructure.com/119451
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-07-18 20:03:32 +00:00
Simon Williams 6fda6936e7 fix attachment garbage collection for child attachments
refs CNVS-37514

test plan:
- create two attachments, and a child attachment for one of them
- set the two roots to a created_at in the past, but not the child
- run the gc
- it should not delete the child attachment

Change-Id: I4a39b62a6de9bab4a38b95f9c0eba04908a31b1d
Reviewed-on: https://gerrit.instructure.com/119270
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-07-17 17:53:23 +00:00
Simon Williams 8bdb391f31 support dry_run in attachment gc
Change-Id: Iffef70aa6b0614b237de048f7d1919098aa08856
Reviewed-on: https://gerrit.instructure.com/115808
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-07-11 21:10:15 +00:00
Simon Williams 30a55dd505 clean up content export attachments
closes CNVS-37514

test plan:
- create some content exports, of different types
- modify the created_at date of some of the attachments
- run the cleanup script, with a date that makes sense
- the correct attachments should be deleted

Change-Id: I67d0d485a546b99bd63e8cf65e74a0de55072944
Reviewed-on: https://gerrit.instructure.com/115392
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
2017-07-11 21:10:06 +00:00
Cody Cutrer bb3f567983 write directly to zipstream
fixes CNVS-37802

Change-Id: I715f6e6c2a45c505e1f3c9e3757ea5cfce0e632f
Reviewed-on: https://gerrit.instructure.com/116890
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Pedro Fajardo <pfajardo@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
Reviewed-by: Dan Minkevitch <dan@instructure.com>
Tested-by: Jenkins
2017-06-24 23:15:36 +00:00
Simon Williams d975e1a3ea delete old folder zip attachments
closes CNVS-37152

test plan:
- have old folder export attachments
- run Attachments::GarbageCollector::FolderExports.delete_content
- make sure the s3 objects are deleted
- if you are happy, run:
  Attachments::GarbageCollector::FolderExports.delete_rows
- otherwise, run:
  Attachments::GarbageCollector::FolderExports.undelete_content

Change-Id: Ie6f094f0ffdc151f71b84b5b7a39afc3da0a4638
Reviewed-on: https://gerrit.instructure.com/113109
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-06-02 15:32:41 +00:00
Simon Williams 458463bf18 upgrade to aws v4 s3 signatures
fixes CNVS-36040

test plan:
- try file uploads against an eu-central-1 and a us-east-1 s3 bucket as
well as local uploads
- try direct-to-s3 uploads (like from the files area), proxied uploads
(add a new file from the add module item dialog), and behind-the-scenes
uploads (like generating a course export or doing a sis import)
- make sure previously uploaded files continue to work

Change-Id: Ifd55cd72e017257e807f26a11a2f0870b7f68957
Reviewed-on: https://gerrit.instructure.com/110446
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2017-05-03 20:49:57 +00:00
Landon Wilkins c7e07671c0 da licença part 8
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: I47bbff536d1c515a3d5482abc8d635efa040eeaf
Reviewed-on: https://gerrit.instructure.com/110028
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-04-27 21:33:20 +00:00
James Williams e8c3368aca fix copying attachments on local storage
also fix copy_attachment_content when the destination file
doesn't exist yet

Change-Id: I46489f7f7395061bd34560b5d471c56133cf1dca
Reviewed-on: https://gerrit.instructure.com/109231
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2017-04-20 23:41:43 +00:00
Cody Cutrer e3e288cc12 don't pass content_length to s3 attachment copies less than 5GB
also, specify the target as an Object, not just a filename
(so that it has the bucket context)

Change-Id: I9999b0502cf1f050e380a1d8fe32e5240ce7db5c
Reviewed-on: https://gerrit.instructure.com/103220
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2017-03-08 20:39:19 +00:00
Cody Cutrer 1f03606627 aws sdk v2 support for attachments
closes CNVS-33615

test plan:
 * upload and download files using S3
 * submit an assignment
 * do an SIS import with parallel
 * do a course copy
 * export and import a course
 * upload some custom css file in theme editor
 * test a canvadoc and crocodoc preview

Change-Id: I9145b39728938e7e5903d23c4a4598fc8df4ef45
Reviewed-on: https://gerrit.instructure.com/93002
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
2017-01-24 21:09:14 +00:00
John Corrigan e745f742a7 add Attachments::ScopedToUser
fixes CNVS-21854

Moves permission-based scope concatenation from
FilesController#api_index to Attachments::ScopedToUser#scope. Updates
Folder permission policy to delegate permissions for :read_as_admin &
:manage_files to its context. Add Folder.from_context_or_id to
encapsulate folder finding logic from FilesController#api_index.

test plan:
- Regression testing for API files index action.

Change-Id: I1dc855cc16a98969482a72d251848c47e300b05c
Reviewed-on: https://gerrit.instructure.com/58415
Tested-by: Jenkins
Reviewed-by: Matt Berns <mberns@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: John Corrigan <jcorrigan@instructure.com>
2015-07-27 18:40:47 +00:00
Rob Orton 3e2314cd20 don't move files to the same spot just for fun
Change-Id: Ia96983a180a67d74f4c369c3a5639069f241c46f
Reviewed-on: https://gerrit.instructure.com/57027
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2015-06-23 17:44:59 +00:00
Jeremy Stanley 0816b52529 fix sharing private eportfolios with verifier link
test plan:
 - create a private eportfolio with a file attachment
 - get the sharing link from the eportfolio dashboard
   (the thing with the long verifier in it)
 - confirm that the eportfolio, and its files, are
   visible through that link
   (a) as a different user
   (b) with no user, in a private/incognito window
 - confirm that the private eportfolio is not accessible
   by another/no user without the verifier

fixes CNVS-20092

Change-Id: I8dc14690068ebfc34f868d10597f95411f55c165
Reviewed-on: https://gerrit.instructure.com/53077
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-04-29 17:25:56 +00:00
James Williams e5cfd592a6 only use root_attachments if they are valid
test plan
 - upload a file on user 1
 - destroy the s3object
 - upload the file again on user 2
 - merge user2 into user 1
 - it should be a new root_attachment that works

Change-Id: I979932a7aa1a652b2aab4c660dcc6b6de15b8861
Reviewed-on: https://gerrit.instructure.com/50954
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2015-04-22 23:39:33 +00:00
Jeremy Stanley 70670c7d45 add custom permission maps to new verifiers
for verifiers that grant access to files that would otherwise
not be accessible (such as a file attachment in user context),
allow them to check permission on a different object instead.

in this commit, the verifier remaps file permissions for
eportfolio attachments to permissions on the eportfolio itself.

test plan:
 - create an eportfolio, and set it to public
 - attach a file to it
 - verify that another user can view the eportfolio and the
   file attachment
 - save the URL to the file attachment
 - uncheck the public eportfolio setting and save it
 - verify that the saved URL for the file attachment no longer
   works

fixes CNVS-19719

Change-Id: Ic1839f13d571d3f5f2aa692f94bd1fd1d5e485ca
Reviewed-on: https://gerrit.instructure.com/52120
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-04-17 19:04:44 +00:00
Zach Wily 892aa98958 lay groundwork for transitioning to smarter attachment verifiers
This commit adds a new form of attachment verifier. Rather than just
being the `uuid` from the attachment object, it is a signed JWT that
includes the attachment id, the viewing user id, and a viewing context.

The existing code that checks the verifier now checks to see if it's
a UUID and returns success if it is (to preserve legacy behavior). It
attempts to decode and verify the token, and verify that the user
captured in the token still has permission to :read or :download the
attachment.

The context captured in the token is currently unused, but may prove
useful for debugging or future purposes. The context is just an
asset_string for a model.

The only place generating new verifiers with this commit is the helper
ApplicationController#verified_file_download_url, which is only used by
content exports and eportfolios.

We also shoot increments to statsd when legacy and new verifiers are
used, so we can see when legacy verifier usage is low enough to disable.

Test plan:
 * Create a course export.
 * View the export at /courses/X/content_exports
 * Verify that the verifier= in the download URL is decoded correctly
   at jwt.io. It should have a user_id, an id, and a context.
 * Verify that a you can successfully download the export.
 * Use the files API and verify that urls still have the
   old-style verifier=<40-character UUID> on them, and that these
   links still work without authentication (such as an incognito tab
   or curl)

 * enable eportfolios in account settings
 * upload a file to user files
 * create an eportfolio, and attach a user file to it
 * save the eportfolio
 * confirm that the download link
   (which looks like /eportfolios/X/entries/Y/files/ZZZ)
   redirects to a file download link with a new verifier

fixes CNVS-18858
fixes CNVS-18861

Change-Id: I3db21469462dfdb8f8067f509a01a55d7cb23abd
Reviewed-on: https://gerrit.instructure.com/48637
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-02-26 17:17:30 +00:00
Cody Cutrer e470fb0bb3 fix attachment copies >= 5GB
Change-Id: Ide74ea459d7ed38acbb4503399e50448f448eea6
Reviewed-on: https://gerrit.instructure.com/39237
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-08-14 03:33:02 +00:00
Jeremy Stanley a5477474f3 use binmode for s3 download file
test plan:
 - you should be able to perform content imports on rails3
   (specifically, there should not be a "Content-length does not match",
    or, for very small imports, "(something) from ASCII-8BIT to UTF-8"
    error)

fixes CNVS-12229

Change-Id: I8a549c3760972dc028461b391c87a2fcc98ff9f4
Reviewed-on: https://gerrit.instructure.com/33186
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
2014-04-14 16:25:49 +00:00
Joseph Rodriguez 8d7622206f extract storage type responsibility out of Attachment
fixes CNVS-12045

test plan:
  - with local file storage
    * upload attachment to course and submit file
    * download attachment
  - with s3 file storage
    * upload attachment to course and submit file
    * download attachment

Change-Id: I9e3fd20a6659e53a37dae04137e2b39b0e3c3ea8
Reviewed-on: https://gerrit.instructure.com/32433
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
2014-04-02 20:56:21 +00:00