forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conformance.textproto
385 lines (357 loc) · 11.3 KB
/
conformance.textproto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# Copyright 2016 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Conformance requirements:
# See: https://github.com/google/closure-compiler/wiki/JS-Conformance-Framework
# Disallow throwing non-Error types.
requirement: {
type: CUSTOM
java_class: "com.google.javascript.jscomp.ConformanceRules$BanThrowOfNonErrorTypes"
error_message:
"Throwing non-Error types or Error itself is not allowed; "
"throw shaka.util.Error instead."
whitelist_regexp: "test/"
whitelist_regexp: "node_modules/"
}
requirement: {
type: BANNED_CODE_PATTERN
value: "function template() { throw new Error(); }"
error_message:
"Throwing non-Error types or Error itself is not allowed; "
"throw shaka.util.Error instead."
whitelist_regexp: "test/"
whitelist_regexp: "node_modules/"
}
# Ban accessing members of unknown types.
requirement: {
type: CUSTOM
java_class:
"com.google.javascript.jscomp.ConformanceRules$"
"BanUnknownTypedClassPropsReferences"
error_message:
"Using properties of unknown types is not allowed; add an "
"explicit type to the variable."
whitelist_regexp: "demo/"
}
requirement {
type: CUSTOM
java_class: "com.google.javascript.jscomp.ConformanceRules$BanUnknownThis"
error_message:
"Failed to infer type of \"this\"; "
"please be explicit or use bind!"
# Until we can get this rule updated for ES6 static methods
# (https://github.com/google/closure-compiler/issues/2880):
whitelist_regexp: "test/test/util/canned_idb.js"
whitelist_regexp: "test/assets/assets_integration.js"
}
# Reject unresolved types.
requirement {
type: CUSTOM
java_class: "com.google.javascript.jscomp.ConformanceRules$BanUnresolvedType"
error_message: "Failed to resolve type!"
}
# Reject global variables.
requirement {
type: CUSTOM
java_class: "com.google.javascript.jscomp.ConformanceRules$BanGlobalVars"
error_message: "Global variables are not allowed!"
whitelist_regexp: "demo/"
whitelist_regexp: "test/"
whitelist_regexp: "node_modules/"
}
# Disallow using "!" on nullable numbers in boolean assignment.
# Note: we can't use the pattern "var b = !n" because it causes too many
# false positives.
requirement: {
type: BANNED_CODE_PATTERN
value:
"/** @param {boolean} b @param {?number} n */ "
"function template(b, n) { b = !n; }"
error_message:
"Using \"!\" on nullable numbers in boolean assignment "
"is not allowed; use an explicit comparison instead."
whitelist_regexp: "node_modules/"
}
requirement: {
type: BANNED_CODE_PATTERN
value:
"/** @param {*} a"
" @param {(number|string|boolean|null|undefined)} x */"
"function template(a, x) { expect(a).toEqual(x); }"
value:
"/** @param {*} a"
" @param {(number|string|boolean|null|undefined)} x */"
"function template(a, x) { expect(a).not.toEqual(x); }"
error_message: "Use expect.toBe for primitives"
}
requirement: {
type: BANNED_CODE_PATTERN
value:
"/** @param {BufferSource} a */"
"function template(a) { new Uint8Array(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Int8Array(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Uint8ClampedArray(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Unt16Array(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Int16Array(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Uint32Array(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Int32Array(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Float32Array(a) }"
value:
"/** @param {BufferSource} a */"
"function template(a) { new Float64Array(a) }"
error_message: "Use shaka.util.BufferUtils.view* instead."
whitelist_regexp: "lib/util/buffer_utils.js"
}
requirement: {
type: BANNED_CODE_PATTERN
value: "function template () { new Date().getTime() }"
error_message: "Use Date.now() instead."
}
# Disallow console logging.
requirement: {
type: BANNED_PROPERTY_CALL
value: "Console.prototype.debug"
value: "Console.prototype.log"
value: "Console.prototype.info"
value: "Console.prototype.warn"
value: "Console.prototype.error"
error_message:
"Using \"console\" is not allowed; "
"use shaka.log instead"
whitelist_regexp: "demo/"
whitelist_regexp: "lib/debug/log.js"
whitelist_regexp: "test/test/boot.js"
whitelist_regexp: "node_modules/"
whitelist_regexp: "[synthetic:es6/promise/promise]"
}
# Disallow querySelector and querySelectorAll since they aren't supported on
# Shaka Player Embedded.
requirement: {
type: BANNED_PROPERTY_CALL
value: "Element.prototype.querySelector"
value: "Document.prototype.querySelector"
value: "Element.prototype.querySelectorAll"
value: "Document.prototype.querySelectorAll"
error_message: "Use getElementsByTagName"
whitelist_regexp: "demo/"
whitelist_regexp: "ui/"
whitelist_regexp: "test/"
whitelist_regexp: "node_modules/"
}
# Disallow Element.children.
requirement: {
type: BANNED_PROPERTY
value: "Element.prototype.children"
error_message:
"Using \"Element.children\" is not allowed; "
"use Node.childNodes instead"
}
requirement: {
type: BANNED_PROPERTY
value: "DataView.prototype.buffer"
value: "TypedArray.prototype.buffer"
error_message:
"Using \"TypedArray.buffer\" is not safe since it doesn\'t "
"handle sub-arrays"
whitelist_regexp: "lib/util/buffer_utils.js"
whitelist_regexp: "lib/util/object_utils.js"
whitelist_regexp: "test/util/buffer_utils_unit.js"
}
# Disallow Element.innerHTML and outerHTML.
requirement: {
type: BANNED_PROPERTY
value: "Element.prototype.innerHTML"
value: "Element.prototype.outerHTML"
error_message:
"Using \"Element.innerHTML\" or \"Element.outerHTML\" is not "
"allowed due to security concerns; use textContent, "
"appendChild, or removeChild instead"
whitelist_regexp: "test/test/util/util.js"
}
# Disallow DOMRect.x and y.
requirement: {
type: BANNED_PROPERTY
value: "DOMRect.prototype.x"
value: "DOMRect.prototype.y"
error_message:
"DOMRect \"x\" and \"y\" are not supported on legacy Edge; "
"use \"left\" and \"top\" instead."
# The built-in set and map polyfills trigger this ban somehow.
whitelist_regexp: "synthetic:es6/"
}
# Disallow fdescribe.
requirement: {
type: BANNED_NAME
value: "fdescribe"
error_message: "Using \"fdescribe\" is not allowed"
}
# Disallow fit.
requirement: {
type: BANNED_NAME
value: "fit"
error_message: "Using \"fit\" is not allowed"
whitelist_regexp: "test/player_external.js"
}
# Disallow setInterval.
requirement: {
type: BANNED_NAME
value: "window.setInterval"
error_message:
"setInterval has several drawbacks, most of "
"all difficulty canceling and surprising behavior "
"when the device goes to sleep. Please use "
"shaka.util.Timer instead."
whitelist_regexp: "demo/"
whitelist_regexp: "test/"
}
requirement: {
type: BANNED_NAME
value: "setInterval"
error_message:
"setInterval has several drawbacks, most of "
"all difficulty canceling and surprising behavior "
"when the device goes to sleep. Please use "
"shaka.util.Timer instead."
whitelist_regexp: "demo/"
whitelist_regexp: "test/"
}
# Disallow setTimeout.
requirement: {
type: BANNED_NAME
value: "window.setTimeout"
error_message:
"setTimeout has several drawbacks, most of "
"all difficulty canceling it. Please use "
"shaka.util.Timer instead."
whitelist_regexp: "demo/"
whitelist_regexp: "test/"
whitelist_regexp: "lib/util/delayed_tick.js"
whitelist_regexp: "lib/polyfill/abort_controller.js"
}
requirement: {
type: BANNED_NAME
value: "setTimeout"
error_message:
"setTimeout has several drawbacks, most of "
"all difficulty canceling it. Please use "
"shaka.util.Timer instead."
whitelist_regexp: "demo/"
whitelist_regexp: "test/"
}
# Disallow eval, except when testing for modern JS syntax in demo
requirement: {
type: BANNED_NAME
value: "window.eval"
error_message: "Using \"eval\" is not allowed"
whitelist_regexp: "demo/demo_utils.js"
whitelist_regexp: "node_modules/google-closure-library/closure/goog/base.js"
whitelist_regexp: "test/util/functional_unit.js"
}
requirement: {
type: BANNED_NAME
value: "eval"
error_message: "Using \"eval\" is not allowed"
whitelist_regexp: "demo/demo_utils.js"
whitelist_regexp: "node_modules/google-closure-library/closure/goog/base.js"
whitelist_regexp: "test/util/functional_unit.js"
}
# Disallow ES6 methods.
requirement: {
type: BANNED_PROPERTY
value: "ArrayBuffer.prototype.slice"
error_message:
"ArrayBuffer.slice is not allowed because it "
"is not supported on Tizen 2016"
}
# Disallow the general use of fetch, which is not available on all supported
# platforms.
requirement: {
type: BANNED_NAME_CALL
value: "fetch"
value: "window.fetch"
error_message:
"Using \"fetch\" directly is not allowed; "
"use shaka.test.Util.fetch or NetworkingEngine.request "
"instead."
whitelist_regexp: "lib/net/http_fetch_plugin.js"
}
# Disallow the use of generators, which are a major performance issue. See
# https://github.com/shaka-project/shaka-player/issues/4062#issuecomment-1079428268
requirement: {
type: BANNED_CODE_PATTERN
value:
"/** @param {*} x */ "
"function *template(x) { yield x; }"
error_message:
"ES6 generators are a major performance issue! Find another solution. "
"See also https://bit.ly/3wAsoj5"
whitelist_regexp: "node_modules/"
}
# Disallow the general use of TextDecoder and TextEncoder, which is not
# available on all supported platforms.
requirement: {
type: BANNED_NAME_CALL
value: "TextDecoder"
value: "window.TextDecoder"
error_message:
"Using \"TextDecoder\" directly is not allowed; "
"because is not supported on Xbox and old browsers."
whitelist_regexp: "lib/util/string_utils.js"
}
requirement: {
type: BANNED_NAME_CALL
value: "TextEncoder"
value: "window.TextEncoder"
error_message:
"Using \"TextEncoder\" directly is not allowed; "
"because is not supported on Xbox and old browsers."
whitelist_regexp: "lib/util/string_utils.js"
}
requirement: {
type: BANNED_PROPERTY_CALL
value: "String.prototype.replaceAll"
error_message:
"Using \"String.replaceAll\" is not allowed; "
"use String.replace instead"
}
# Disallow the general use of DOMParser.parseFromString, which has security
# implications.
requirement: {
type: BANNED_PROPERTY_CALL
value: "DOMParser.prototype.parseFromString"
error_message:
"Using \"DOMParser.parseFromString\" directly is not allowed; "
"use shaka.util.XmlUtils.parseXmlString instead."
whitelist_regexp: "lib/util/xml_utils.js"
whitelist_regexp: "test/"
}
requirement: {
type: BANNED_PROPERTY_CALL
value: "Array.prototype.flat"
error_message:
"Using \"Array.flat\" is not allowed because is not supported on Tizen 3."
}