Skip to content

Commit efa4df6

Browse files
Untrusted uploads form (#3948)
i apparently cannot figure out how to take over a PR so making a new one addressed comments left on #3902 and updated wording, fixed styling/made minor changes --------- Co-authored-by: Jonathan Metzman <[email protected]> Co-authored-by: jonathanmetzman <[email protected]>
1 parent 81995e3 commit efa4df6

File tree

3 files changed

+26
-41
lines changed

3 files changed

+26
-41
lines changed

src/appengine/handlers/upload_testcase.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from clusterfuzz._internal import fuzzing
2626
from clusterfuzz._internal.base import external_users
2727
from clusterfuzz._internal.base import memoize
28+
from clusterfuzz._internal.base import task_utils
2829
from clusterfuzz._internal.base import tasks
2930
from clusterfuzz._internal.base import utils
3031
from clusterfuzz._internal.crash_analysis.stack_parsing import stack_analyzer
@@ -50,6 +51,8 @@
5051
UPLOAD_URL = '/upload-testcase/upload-oauth'
5152
MEMCACHE_TTL_IN_SECONDS = 60 * 60 # 1 hour.
5253

54+
TRUSTED_AGREEMENT_TEXT = 'This testcase is safe to run'
55+
5356

5457
def _is_uploader_allowed(email):
5558
"""Return bool on whether user is allowed to upload to any job or fuzzer."""
@@ -385,6 +388,15 @@ def do_post(self):
385388
issue_labels = request.get('issue_labels')
386389
gestures = request.get('gestures') or '[]'
387390
stacktrace = request.get('stacktrace')
391+
trusted_agreement_signed = request.get(
392+
'trustedAgreement') == TRUSTED_AGREEMENT_TEXT.strip()
393+
394+
if (not trusted_agreement_signed and
395+
task_utils.is_remotely_executing_utasks()):
396+
# Trusted agreement was not signed even though the job has privileges and
397+
# there are other jobs that don't have privileges.
398+
raise helpers.EarlyExitError(
399+
'Sign the trusted job statement or upload to a trusted job.', 400)
388400

389401
crash_data = None
390402
if job.is_external():

src/appengine/private/components/upload-testcase/upload-form-simplified.html

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@
146146
</template>
147147
</div>
148148
<div class="warning">
149-
<b>WARNING</b>: ClusterFuzz doesn't support untrusted workloads.<br>
150-
Only upload testcases that you trust enough to run on your own
151-
machine. Note that the following jobs do use the Chrome sandbox
152-
but this is not a guarantee of protection:<br>
153-
[[formatSandboxedJobs(fieldValues.sandboxedJobs)]]
149+
<span><strong>WARNING</strong>: ClusterFuzz only partially supports untrusted workloads.<br></span>
150+
ClusterFuzz supports untrusted workloads when the platform is Linux<br>
151+
If your upload does not use Linux as the platform, Clusterfuzz will treat the input testcase as trusted,
152+
and therefore run with privileged jobs. Only upload this testcase if you trust it enough to run on your own machine.<br>
153+
To confirm this testcase is trusted, you must fill out the extra field confirming so.
154154
</div>
155155
<div class="inline wide">
156156
<paper-dropdown-menu
@@ -173,6 +173,7 @@
173173
<p class="quick-mode-job narrow"> Job to be used for this testcase: {{getJobType(uploadParams.file, uploadParams.fileType, uploadParams.platform)}} </p>
174174
<div class="inline wide">
175175
<paper-input value="{{uploadParams.args}}" label="Command-line arguments (optional)" title="Additional command line flags to append when running this testcase. Only necessary if a flag that isn't part of the job definition is required."></paper-input>
176+
<paper-input value="{{uploadParams.trustedAgreement}}" label="Type in 'This testcase is safe to run' to run trusted testcases on trusted jobs."></paper-input>
176177
</div>
177178
<template is="dom-if" if="[[isAndroid(uploadParams.job)]]">
178179
<div class="inline wide">
@@ -205,7 +206,7 @@
205206
value: [
206207
'job', 'target', 'multiple', 'http', 'highEnd', 'issue',
207208
'revision', 'timeout', 'retries', 'updateIssue', 'args', 'cmd',
208-
'platform', 'gestures', 'testcaseId']
209+
'platform', 'gestures', 'testcaseId', 'trustedAgreement']
209210
},
210211
uploadParams: {
211212
type: Object,
@@ -379,18 +380,6 @@
379380
let secureJobs = new Set(this.fieldValues.sandboxedJobs);
380381
return this.fieldValues.isChromium && !secureJobs.has(job);
381382
}
382-
383-
formatSandboxedJobs(jobs) {
384-
if (!jobs) { return ''; }
385-
386-
let s = '';
387-
for (let i=0;i<jobs.length;i++) {
388-
if (i > 0) { s += ', '; }
389-
if (i == (jobs.length - 1)) { s += 'and '; }
390-
s += jobs[i]
391-
}
392-
return s;
393-
}
394383
}
395384

396385
customElements.define(UploadFormSimplified.is, UploadFormSimplified);

src/appengine/private/components/upload-testcase/upload-form.html

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@
193193
</template>
194194
</div>
195195
<div class="warning">
196-
<b>WARNING</b>: ClusterFuzz doesn't support untrusted workloads.<br>
197-
Only upload testcases that you trust enough to run on your own
198-
machine. Note that the following jobs do use the Chrome sandbox,
199-
but this is not a guarantee of protection:<br>
200-
[[formatSandboxedJobs(fieldValues.sandboxedJobs)]]
196+
<span><strong>WARNING</strong>: ClusterFuzz only partially supports untrusted workloads.<br></span>
197+
ClusterFuzz supports untrusted workloads when the platform is Linux<br>
198+
If your upload does not use Linux as the platform, Clusterfuzz will treat the input testcase as trusted,
199+
and therefore run with privileged jobs. Only upload this testcase if you trust it enough to run on your own machine.<br>
200+
To confirm this testcase is trusted, you must fill out the extra field confirming so.
201201
</div>
202202
<div class="inline narrow">
203203
<template is="dom-if" if="[[shouldShowIssueField()]]">
@@ -228,6 +228,7 @@
228228
</template>
229229
<template is="dom-if" if="[[fieldValues.isChromium]]">
230230
<paper-checkbox value="true" checked="{{uploadParams.highEnd}}">Use a multi-core bot (linux only).</paper-checkbox>
231+
<paper-input value="{{uploadParams.trustedAgreement}}" label="Type in 'This testcase is safe to run' to run trusted testcases on trusted jobs."></paper-input>
231232
</template>
232233
<br/>
233234
<paper-button class="get-link-button" slot="more-buttons" on-tap="generatePermalink">Permalink</paper-button>
@@ -254,7 +255,7 @@
254255
value: [
255256
'job', 'target', 'multiple', 'http', 'highEnd', 'issue',
256257
'revision', 'timeout', 'retries', 'updateIssue', 'args', 'cmd',
257-
'platform', 'gestures', 'testcaseId']
258+
'platform', 'gestures', 'testcaseId', 'trustedAgreement']
258259
},
259260
uploadParams: {
260261
type: Object,
@@ -387,23 +388,6 @@
387388
this.uploadParams, this.paramKeys);
388389
}
389390

390-
showWarning(job) {
391-
let secureJobs = new Set(this.fieldValues.sandboxedJobs);
392-
return this.fieldValues.isChromium && !secureJobs.has(job);
393-
}
394-
395-
formatSandboxedJobs(jobs) {
396-
if (!jobs) { return ''; }
397-
398-
let s = '';
399-
for (let i=0;i<jobs.length;i++) {
400-
if (i > 0) { s += ', '; }
401-
if (i == (jobs.length - 1)) { s += 'and '; }
402-
s += jobs[i]
403-
}
404-
return s;
405-
}
406-
407391
onmatch(key) {
408392
if (!key)
409393
return null;

0 commit comments

Comments
 (0)