Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Issue 2123023002: [Downloads] Consolidate MOTW annotation APIs into a single API. (Closed)

Created:
4 years, 5 months ago by asanka
Modified:
4 years, 2 months ago
CC:
asanka, chromium-reviews, darin-cc_chromium.org, jam
Base URL:
https://chromium.googlesource.com/chromium/src.git@move-safe-util-to-downloads
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Downloads] Consolidate MOTW annotation APIs into a single API. Desktop platforms support various mechanisms for safely handling untrusted files downloaded from the internet. These are summarized below: * Windows: * Windows Attachment Services can submit newly downloaded content to registered AV programs. In addition, it will also annotate the file with the security zone of the source URL if necessary. Logic for invoking Attachment Services was in content/browser/safe_util_win.{h,cc} even though only content/browser/download used it. * Zone information could be added manually bypassing Attachment Services. This is useful if Attachment Services isn't available (doesn't really happen in any supported platform currently), or if the download content isn't available yet. This logic was also in content/browser/safe_util_win.cc. * Mac * Files created by Chrome/Chromium will automatically be quarantined due to the LSFileQuarantineEnabled entry. In addition, the quarantine type (whether the file was downloaded from the web or not), referrer (kLSQuarantineOriginURLKey), and source URL (kLSQuarantineDataURLKey) can be specified so that they are displayed in any UI presented to the user. Chrome also sets the "where from" metadata for the file based on the source and referrer URLs. This logic lived in content/browser/download/file_metadata_mac.{h,mm}. * Linux * While not mandatory to be used for any quarantine purpose, Chrome sets the `user.xdg.origin.url` and the non-standard `user.xdg.referrer.url` extended attributes. Logic for this lived in content/browser/download/file_metadata_linux.{h,cc}. This CL introduces a common API in content/browser/download/quarantine.h that invokes the correct platform specific implementation in quarantine_*. The QuarantineFile() function is henceforth a platform independent mechanism for annotating a downloaded file. This new API will make it easier to annotate files that are downloaded using other mechanisms (PPAPI, for example). BUG=598812 Committed: https://crrev.com/bd57338ff5d58fff3147982c3f631cbe43e86f9c Cr-Commit-Position: refs/heads/master@{#420060}

Patch Set 1 : . #

Patch Set 2 : . #

Patch Set 3 : . #

Patch Set 4 : . #

Total comments: 8

Patch Set 5 : Address comments and rebase #

Patch Set 6 : Fix mac #

Patch Set 7 : Rebase #

Patch Set 8 : Rebase #

Total comments: 6

Patch Set 9 : [win] Verify that the Zone.Identifier stream has the correct contents. #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+740 lines, -899 lines) Patch
M content/browser/BUILD.gn View 1 2 3 4 5 6 7 8 3 chunks +6 lines, -8 lines 0 comments Download
M content/browser/download/base_file.cc View 1 2 3 4 5 6 7 8 3 chunks +58 lines, -10 lines 0 comments Download
D content/browser/download/base_file_linux.cc View 1 chunk +0 lines, -23 lines 0 comments Download
D content/browser/download/base_file_mac.cc View 1 chunk +0 lines, -24 lines 0 comments Download
M content/browser/download/base_file_win.cc View 1 2 3 4 5 6 3 chunks +0 lines, -74 lines 0 comments Download
M content/browser/download/download_stats.h View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
D content/browser/download/file_metadata_linux.h View 1 chunk +0 lines, -34 lines 0 comments Download
D content/browser/download/file_metadata_linux.cc View 1 chunk +0 lines, -44 lines 0 comments Download
D content/browser/download/file_metadata_mac.h View 1 chunk +0 lines, -31 lines 0 comments Download
D content/browser/download/file_metadata_mac.mm View 1 chunk +0 lines, -169 lines 0 comments Download
D content/browser/download/file_metadata_unittest_linux.cc View 1 2 3 4 5 6 7 8 1 chunk +0 lines, -166 lines 0 comments Download
A content/browser/download/quarantine.h View 1 2 3 4 1 chunk +83 lines, -0 lines 0 comments Download
A + content/browser/download/quarantine.cc View 1 2 3 4 5 6 7 8 1 chunk +11 lines, -12 lines 0 comments Download
A + content/browser/download/quarantine_constants_linux.h View 1 2 3 4 1 chunk +8 lines, -19 lines 0 comments Download
A + content/browser/download/quarantine_linux.cc View 1 2 3 4 2 chunks +40 lines, -18 lines 0 comments Download
A + content/browser/download/quarantine_linux_unittest.cc View 1 2 3 4 5 6 7 8 6 chunks +64 lines, -50 lines 0 comments Download
A + content/browser/download/quarantine_mac.mm View 1 2 3 4 5 8 chunks +51 lines, -23 lines 0 comments Download
A + content/browser/download/quarantine_win.cc View 1 2 3 4 5 6 7 8 1 chunk +254 lines, -43 lines 3 comments Download
A content/browser/download/quarantine_win_unittest.cc View 1 2 1 chunk +126 lines, -0 lines 0 comments Download
D content/browser/safe_util_win.h View 1 1 chunk +0 lines, -53 lines 0 comments Download
D content/browser/safe_util_win.cc View 1 1 chunk +0 lines, -93 lines 0 comments Download
M content/test/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -1 line 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 4 5 6 7 8 3 chunks +34 lines, -1 line 0 comments Download

Messages

Total messages: 57 (38 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2123023002/100001
4 years, 5 months ago (2016-07-06 20:58:23 UTC) #2
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/255700)
4 years, 5 months ago (2016-07-06 23:19:53 UTC) #4
asanka
cpu: content/browser/download/quarantine_win* (also for removing content/browser/safe_util_win*) rsesek: content/browser/download/quarantine_mac* content/browser/download/quarantine_linux* svaldez: content/browser/download/base_file.cc FYI on all asvitkine: ...
4 years, 5 months ago (2016-07-08 19:17:52 UTC) #17
Robert Sesek
mac LGTM https://codereview.chromium.org/2123023002/diff/140001/content/browser/download/quarantine.h File content/browser/download/quarantine.h (right): https://codereview.chromium.org/2123023002/diff/140001/content/browser/download/quarantine.h#newcode5 content/browser/download/quarantine.h:5: #ifndef __CONTENT_BROWSER_DOWNLOAD_QUARANTINE_H_ nit: header guard shouldn't have ...
4 years, 5 months ago (2016-07-08 19:38:35 UTC) #18
svaldez
lgtm https://codereview.chromium.org/2123023002/diff/140001/content/browser/download/quarantine_constants_linux.h File content/browser/download/quarantine_constants_linux.h (right): https://codereview.chromium.org/2123023002/diff/140001/content/browser/download/quarantine_constants_linux.h#newcode1 content/browser/download/quarantine_constants_linux.h:1: // Copyright (c) 2012 The Chromium Authors. All ...
4 years, 5 months ago (2016-07-11 14:55:46 UTC) #19
svaldez
lgtm
4 years, 5 months ago (2016-07-11 14:55:46 UTC) #20
Alexei Svitkine (slow)
lgtm
4 years, 5 months ago (2016-07-11 16:46:20 UTC) #21
asanka
Thanks folks! Sorry about the delay. I'm picking this up again from out of the ...
4 years, 3 months ago (2016-09-12 15:36:38 UTC) #38
Robert Sesek
LGTM, agree that's more readable
4 years, 3 months ago (2016-09-12 21:09:10 UTC) #39
asanka
cpu: Ping?
4 years, 3 months ago (2016-09-15 21:06:49 UTC) #40
cpu_(ooo_6.6-7.5)
looking ..
4 years, 3 months ago (2016-09-20 15:38:02 UTC) #41
cpu_(ooo_6.6-7.5)
lgtm https://codereview.chromium.org/2123023002/diff/220001/content/browser/download/base_file.cc File content/browser/download/base_file.cc (right): https://codereview.chromium.org/2123023002/diff/220001/content/browser/download/base_file.cc#newcode408 content/browser/download/base_file.cc:408: // On windows the attachment service can delete ...
4 years, 3 months ago (2016-09-20 15:52:34 UTC) #42
asanka
Thanks everyone! https://codereview.chromium.org/2123023002/diff/220001/content/browser/download/base_file.cc File content/browser/download/base_file.cc (right): https://codereview.chromium.org/2123023002/diff/220001/content/browser/download/base_file.cc#newcode408 content/browser/download/base_file.cc:408: // On 2016/09/20 at 15:52:33, cpu wrote: ...
4 years, 3 months ago (2016-09-21 14:57:00 UTC) #47
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2123023002/240001
4 years, 3 months ago (2016-09-21 14:57:30 UTC) #50
commit-bot: I haz the power
Committed patchset #9 (id:240001)
4 years, 3 months ago (2016-09-21 15:04:08 UTC) #51
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/bd57338ff5d58fff3147982c3f631cbe43e86f9c Cr-Commit-Position: refs/heads/master@{#420060}
4 years, 3 months ago (2016-09-21 15:06:23 UTC) #53
brucedawson
https://codereview.chromium.org/2123023002/diff/240001/content/browser/download/quarantine_win.cc File content/browser/download/quarantine_win.cc (right): https://codereview.chromium.org/2123023002/diff/240001/content/browser/download/quarantine_win.cc#newcode108 content/browser/download/quarantine_win.cc:108: case ERROR_ACCESS_DENIED: This case is incorrect. ERROR_ACCESS_DENIED is equal ...
4 years, 2 months ago (2016-09-27 17:17:00 UTC) #55
asanka
https://codereview.chromium.org/2123023002/diff/240001/content/browser/download/quarantine_win.cc File content/browser/download/quarantine_win.cc (right): https://codereview.chromium.org/2123023002/diff/240001/content/browser/download/quarantine_win.cc#newcode108 content/browser/download/quarantine_win.cc:108: case ERROR_ACCESS_DENIED: On 2016/09/27 at 17:17:00, brucedawson wrote: > ...
4 years, 2 months ago (2016-09-27 17:26:48 UTC) #56
asanka
4 years, 2 months ago (2016-09-27 20:32:23 UTC) #57
Message was sent while issue was closed.
https://codereview.chromium.org/2123023002/diff/240001/content/browser/downlo...
File content/browser/download/quarantine_win.cc (right):

https://codereview.chromium.org/2123023002/diff/240001/content/browser/downlo...
content/browser/download/quarantine_win.cc:108: case ERROR_ACCESS_DENIED:
On 2016/09/27 at 17:26:48, asanka wrote:
> On 2016/09/27 at 17:17:00, brucedawson wrote:
> > This case is incorrect. ERROR_ACCESS_DENIED is equal to 5, and the "if
(SUCCEEDED(hr))" test already filters out all positive numbers.
> > 
> > The E_ACCESSDENIED case should be sufficient - it is the HRESULT equivalent
of ERROR_ACCESS_DENIED.
> > 
> > This was found through the experimental VC++ /analyze static analysis
builder which gave this warning:
> > 
> > src\content\browser\download\quarantine_win.cc(109) : warning C6221:
Implicit cast between semantically different integer types:  comparing HRESULT
to an integer.
> > 
> > It's harmless, but confusing. Please remove?
> 
> Thanks for catching this. I'll rework the code so that we properly catch these
cases. The SUCCEEDED(hr) test isn't quite correct.
> 
> Testing for ERROR_ACCESS_DENIED isn't a mistake. While the API is documented
to return HRESULT, it actually passes through the return value of
IOfficeAntivirus::Scan() as returned by any registered MSOfficeAntiVirus
provider. In practice we see a mix of HRESULT and system error codes, of which
ERROR_ACCESS_DENIED is pretty common. This is why the SUCCEEDED(hr) test above
is wrong.

https://codereview.chromium.org/2374793002

Powered by Google App Engine
This is Rietveld 408576698