summaryrefslogtreecommitdiff
path: root/www/chromium-uc/patches/extra/ungoogled-chromium/disable-download-quarantine.patch
diff options
context:
space:
mode:
Diffstat (limited to 'www/chromium-uc/patches/extra/ungoogled-chromium/disable-download-quarantine.patch')
-rw-r--r--www/chromium-uc/patches/extra/ungoogled-chromium/disable-download-quarantine.patch296
1 files changed, 296 insertions, 0 deletions
diff --git a/www/chromium-uc/patches/extra/ungoogled-chromium/disable-download-quarantine.patch b/www/chromium-uc/patches/extra/ungoogled-chromium/disable-download-quarantine.patch
new file mode 100644
index 0000000..2191bbe
--- /dev/null
+++ b/www/chromium-uc/patches/extra/ungoogled-chromium/disable-download-quarantine.patch
@@ -0,0 +1,296 @@
1# Disables file download quarantining
2
3--- components/download/internal/common/base_file.cc.orig
4+++ components/download/internal/common/base_file.cc
5@@ -23,7 +23,6 @@
6 #include "components/download/public/common/download_interrupt_reasons_utils.h"
7 #include "components/download/public/common/download_item.h"
8 #include "components/download/public/common/download_stats.h"
9-#include "components/services/quarantine/quarantine.h"
10 #include "crypto/secure_hash.h"
11
12 #if defined(OS_WIN)
13@@ -535,105 +534,6 @@ DownloadInterruptReason BaseFile::Publis
14 }
15 #endif // defined(OS_ANDROID)
16
17-namespace {
18-
19-DownloadInterruptReason QuarantineFileResultToReason(
20- quarantine::mojom::QuarantineFileResult result) {
21- switch (result) {
22- case quarantine::mojom::QuarantineFileResult::OK:
23- return DOWNLOAD_INTERRUPT_REASON_NONE;
24- case quarantine::mojom::QuarantineFileResult::VIRUS_INFECTED:
25- return DOWNLOAD_INTERRUPT_REASON_FILE_VIRUS_INFECTED;
26- case quarantine::mojom::QuarantineFileResult::SECURITY_CHECK_FAILED:
27- return DOWNLOAD_INTERRUPT_REASON_FILE_SECURITY_CHECK_FAILED;
28- case quarantine::mojom::QuarantineFileResult::BLOCKED_BY_POLICY:
29- return DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED;
30- case quarantine::mojom::QuarantineFileResult::ACCESS_DENIED:
31- return DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED;
32-
33- case quarantine::mojom::QuarantineFileResult::FILE_MISSING:
34- // Don't have a good interrupt reason here. This return code means that
35- // the file at |full_path_| went missing before QuarantineFile got to
36- // look at it. Not expected to happen, but we've seen instances where a
37- // file goes missing immediately after BaseFile closes the handle.
38- //
39- // Intentionally using a different error message than
40- // SECURITY_CHECK_FAILED in order to distinguish the two.
41- return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
42-
43- case quarantine::mojom::QuarantineFileResult::ANNOTATION_FAILED:
44- // This means that the mark-of-the-web couldn't be applied. The file is
45- // already on the file system under its final target name.
46- //
47- // Causes of failed annotations typically aren't transient. E.g. the
48- // target file system may not support extended attributes or alternate
49- // streams. We are going to allow these downloads to progress on the
50- // assumption that failures to apply MOTW can't reliably be introduced
51- // remotely.
52- return DOWNLOAD_INTERRUPT_REASON_NONE;
53- }
54- return DOWNLOAD_INTERRUPT_REASON_FILE_FAILED;
55-}
56-
57-// Given a source and a referrer, determines the "safest" URL that can be used
58-// to determine the authority of the download source. Returns an empty URL if no
59-// HTTP/S URL can be determined for the <|source_url|, |referrer_url|> pair.
60-GURL GetEffectiveAuthorityURL(const GURL& source_url,
61- const GURL& referrer_url) {
62- if (source_url.is_valid()) {
63- // http{,s} has an authority and are supported.
64- if (source_url.SchemeIsHTTPOrHTTPS())
65- return source_url;
66-
67- // If the download source is file:// ideally we should copy the MOTW from
68- // the original file, but given that Chrome/Chromium places strict
69- // restrictions on which schemes can reference file:// URLs, this code is
70- // going to assume that at this point it's okay to treat this download as
71- // being from the local system.
72- if (source_url.SchemeIsFile())
73- return source_url;
74-
75- // ftp:// has an authority.
76- if (source_url.SchemeIs(url::kFtpScheme))
77- return source_url;
78-
79- if (source_url.SchemeIs(url::kBlobScheme))
80- return url::Origin::Create(source_url).GetURL();
81- }
82-
83- if (referrer_url.is_valid() && referrer_url.SchemeIsHTTPOrHTTPS())
84- return referrer_url;
85-
86- return GURL();
87-}
88-
89-} // namespace
90-
91-void BaseFile::OnFileQuarantined(
92- bool connection_error,
93- quarantine::mojom::QuarantineFileResult result) {
94- base::UmaHistogramBoolean("Download.QuarantineService.ConnectionError",
95- connection_error);
96-
97- DCHECK(on_annotation_done_callback_);
98- quarantine_service_.reset();
99- std::move(on_annotation_done_callback_)
100- .Run(QuarantineFileResultToReason(result));
101-}
102-
103-void BaseFile::OnQuarantineServiceError(const GURL& source_url,
104- const GURL& referrer_url) {
105-#if defined(OS_WIN)
106- if (base::FeatureList::IsEnabled(quarantine::kOutOfProcessQuarantine)) {
107- OnFileQuarantined(/*connection_error=*/true,
108- quarantine::SetInternetZoneIdentifierDirectly(
109- full_path_, source_url, referrer_url));
110- return;
111- }
112-#endif // defined(OS_WIN)
113-
114- CHECK(false) << "In-process quarantine service should not have failed.";
115-}
116
117 void BaseFile::AnnotateWithSourceInformation(
118 const std::string& client_guid,
119@@ -641,32 +541,8 @@ void BaseFile::AnnotateWithSourceInforma
120 const GURL& referrer_url,
121 mojo::PendingRemote<quarantine::mojom::Quarantine> remote_quarantine,
122 OnAnnotationDoneCallback on_annotation_done_callback) {
123- GURL authority_url = GetEffectiveAuthorityURL(source_url, referrer_url);
124- if (!remote_quarantine) {
125-#if defined(OS_WIN)
126- quarantine::mojom::QuarantineFileResult result =
127- quarantine::SetInternetZoneIdentifierDirectly(full_path_, authority_url,
128- referrer_url);
129-#else
130- quarantine::mojom::QuarantineFileResult result =
131- quarantine::mojom::QuarantineFileResult::ANNOTATION_FAILED;
132-#endif
133- std::move(on_annotation_done_callback)
134- .Run(QuarantineFileResultToReason(result));
135- } else {
136- quarantine_service_.Bind(std::move(remote_quarantine));
137-
138- on_annotation_done_callback_ = std::move(on_annotation_done_callback);
139-
140- quarantine_service_.set_disconnect_handler(base::BindOnce(
141- &BaseFile::OnQuarantineServiceError, weak_factory_.GetWeakPtr(),
142- authority_url, referrer_url));
143-
144- quarantine_service_->QuarantineFile(
145- full_path_, authority_url, referrer_url, client_guid,
146- base::BindOnce(&BaseFile::OnFileQuarantined, weak_factory_.GetWeakPtr(),
147- false));
148- }
149+ std::move(on_annotation_done_callback)
150+ .Run(DOWNLOAD_INTERRUPT_REASON_NONE);
151 }
152
153 } // namespace download
154--- content/browser/BUILD.gn.orig
155+++ content/browser/BUILD.gn
156@@ -82,7 +82,6 @@ source_set("browser") {
157 "//components/permissions:permissions_common",
158 "//components/power_scheduler",
159 "//components/services/filesystem:lib",
160- "//components/services/quarantine:quarantine",
161 "//components/services/storage",
162 "//components/services/storage:filesystem_proxy_factory",
163 "//components/services/storage/dom_storage:local_storage_proto",
164--- content/browser/file_system_access/safe_move_helper.cc.orig
165+++ content/browser/file_system_access/safe_move_helper.cc
166@@ -12,7 +12,6 @@
167 #include "base/task/thread_pool.h"
168 #include "base/threading/sequenced_task_runner_handle.h"
169 #include "build/build_config.h"
170-#include "components/services/quarantine/quarantine.h"
171 #include "content/browser/file_system_access/file_system_access_error.h"
172 #include "content/public/browser/content_browser_client.h"
173 #include "content/public/common/content_client.h"
174@@ -193,20 +192,8 @@ void SafeMoveHelper::DidAfterWriteCheck(
175 // not exist anymore. In case of error, the source file URL will point to a
176 // valid filesystem location.
177 base::OnceCallback<void(base::File::Error)> result_callback;
178- if (RequireSecurityChecks()) {
179- GURL referrer_url = manager_->is_off_the_record() ? GURL() : context_.url;
180- mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote;
181- if (quarantine_connection_callback_) {
182- quarantine_connection_callback_.Run(
183- quarantine_remote.BindNewPipeAndPassReceiver());
184- }
185- result_callback = base::BindOnce(
186- &SafeMoveHelper::DidFileDoQuarantine, weak_factory_.GetWeakPtr(),
187- dest_url(), referrer_url, std::move(quarantine_remote));
188- } else {
189 result_callback = base::BindOnce(&SafeMoveHelper::DidFileSkipQuarantine,
190 weak_factory_.GetWeakPtr());
191- }
192 manager_->DoFileSystemOperation(
193 FROM_HERE, &storage::FileSystemOperationRunner::MoveFileLocal,
194 std::move(result_callback), source_url(), dest_url(), option_);
195@@ -220,7 +207,6 @@ void SafeMoveHelper::DidFileSkipQuaranti
196 void SafeMoveHelper::DidFileDoQuarantine(
197 const storage::FileSystemURL& target_url,
198 const GURL& referrer_url,
199- mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote,
200 base::File::Error result) {
201 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
202
203@@ -251,37 +237,9 @@ void SafeMoveHelper::DidFileDoQuarantine
204 referrer_url.is_valid() && referrer_url.SchemeIsHTTPOrHTTPS()
205 ? referrer_url
206 : GURL();
207-
208- if (quarantine_remote) {
209- quarantine::mojom::Quarantine* raw_quarantine = quarantine_remote.get();
210- raw_quarantine->QuarantineFile(
211- target_url.path(), authority_url, referrer_url,
212- GetContentClient()
213- ->browser()
214- ->GetApplicationClientGUIDForQuarantineCheck(),
215- mojo::WrapCallbackWithDefaultInvokeIfNotRun(
216- base::BindOnce(&SafeMoveHelper::DidAnnotateFile,
217- weak_factory_.GetWeakPtr(),
218- std::move(quarantine_remote)),
219- quarantine::mojom::QuarantineFileResult::ANNOTATION_FAILED));
220- } else {
221-#if defined(OS_WIN)
222- base::ThreadPool::PostTaskAndReplyWithResult(
223- FROM_HERE, {base::MayBlock()},
224- base::BindOnce(&quarantine::SetInternetZoneIdentifierDirectly,
225- target_url.path(), authority_url, referrer_url),
226- base::BindOnce(&SafeMoveHelper::DidAnnotateFile,
227- weak_factory_.GetWeakPtr(),
228- std::move(quarantine_remote)));
229-#else
230- DidAnnotateFile(std::move(quarantine_remote),
231- quarantine::mojom::QuarantineFileResult::ANNOTATION_FAILED);
232-#endif
233- }
234 }
235
236 void SafeMoveHelper::DidAnnotateFile(
237- mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote,
238 quarantine::mojom::QuarantineFileResult result) {
239 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
240
241--- content/browser/file_system_access/safe_move_helper.h.orig
242+++ content/browser/file_system_access/safe_move_helper.h
243@@ -58,10 +58,8 @@ class CONTENT_EXPORT SafeMoveHelper {
244 void DidFileDoQuarantine(
245 const storage::FileSystemURL& target_url,
246 const GURL& referrer_url,
247- mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote,
248 base::File::Error result);
249 void DidAnnotateFile(
250- mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote,
251 quarantine::mojom::QuarantineFileResult result);
252
253 void ComputeHashForSourceFile(HashCallback callback);
254--- content/browser/renderer_host/pepper/pepper_file_io_host.cc.orig
255+++ content/browser/renderer_host/pepper/pepper_file_io_host.cc
256@@ -456,7 +456,7 @@ void PepperFileIOHost::OnLocalFileOpened
257 ppapi::host::ReplyMessageContext reply_context,
258 const base::FilePath& path,
259 base::File::Error error_code) {
260-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
261+#if 0
262 // Quarantining a file before its contents are available is only supported on
263 // Windows and Linux.
264 if (!FileOpenForWrite(open_flags_) || error_code != base::File::FILE_OK) {
265@@ -490,7 +490,7 @@ void PepperFileIOHost::OnLocalFileOpened
266 #endif
267 }
268
269-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD)
270+#if 0
271 void PepperFileIOHost::OnLocalFileQuarantined(
272 ppapi::host::ReplyMessageContext reply_context,
273 const base::FilePath& path,
274--- content/browser/renderer_host/pepper/pepper_file_io_host.h.orig
275+++ content/browser/renderer_host/pepper/pepper_file_io_host.h
276@@ -13,7 +13,6 @@
277 #include "base/macros.h"
278 #include "base/memory/ref_counted.h"
279 #include "base/memory/weak_ptr.h"
280-#include "components/services/quarantine/public/mojom/quarantine.mojom.h"
281 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
282 #include "ipc/ipc_listener.h"
283 #include "ipc/ipc_platform_file.h"
284@@ -93,12 +92,6 @@ class PepperFileIOHost : public ppapi::h
285 const base::FilePath& path,
286 base::File::Error error_code);
287
288- void OnLocalFileQuarantined(
289- ppapi::host::ReplyMessageContext reply_context,
290- const base::FilePath& path,
291- mojo::Remote<quarantine::mojom::Quarantine> quarantine_remote,
292- quarantine::mojom::QuarantineFileResult quarantine_result);
293-
294 void SendFileOpenReply(ppapi::host::ReplyMessageContext reply_context,
295 base::File::Error error_code);
296