Path: blob/trunk/third_party/closure/goog/conformance_proto.txt
4185 views
# proto-file: third_party/java_src/jscomp/java/com/google/javascript/jscomp/conformance.proto1# proto-message: ConformanceConfig23# Conformance users:4#5# DO NOT COPY PASTE THESE RULES. If you do, changes to Closure can break your6# build and you also won't get new or improved rules. Instead use this file in7# your project and extend the rules to disable them or to add their allowlists.89### Platform restrictions ###1011requirement: {12rule_id: "closure:callee"13type: BANNED_PROPERTY14error_message: "Arguments.prototype.callee is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#callee"1516value: "Arguments.prototype.callee"1718allowlist_regexp: ".+/closure/goog/debug/" # legacy stack trace support, etc19# TODO(mlourenco): Fix this? Not sure if possible or not.20allowlist_regexp: ".+/closure/goog/testing/stacktrace.js"21}2223requirement: {24rule_id: "closure:throwOfNonErrorTypes"25type: CUSTOM26java_class: "com.google.javascript.jscomp.ConformanceRules$BanThrowOfNonErrorTypes"27error_message: "Only Error or Error subclass objects may be thrown. See https://google.github.io/closure-library/develop/conformance_rules.html#throwOfNonErrorTypes"28# TODO(user): Violation occurs in code generated by Emscripten.29allowlist_regexp: ".+_wasm_js_library_generated.js"30allowlist_regexp: ".+/closure/goog/storage/" # throws numbers as part of its api31allowlist_regexp: ".+/closure/goog/testing/mock.js" # throws Object in $recordAndThrow32}3334requirement: {35rule_id: "closure:globalVars"36type: CUSTOM37java_class: "com.google.javascript.jscomp.ConformanceRules$BanGlobalVars"38error_message: "Global declarations are not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#globalVars"39allowlist_regexp: ".+/closure/goog/base.js" # global 'goog'40allowlist_regexp: ".+/closure/goog/labs/testing/" # global matchers, etc41allowlist_regexp: ".+/closure/goog/locale/locale.js" # dumb api42allowlist_regexp: ".+/closure/goog/testing/" # global assert methods, etc43allowlist_regexp: ".+/closure/goog/tweak/testhelpers.js" # global values44allowlist_regexp: "^Post-" # injected '_ModuleManager_initialize'4546# Allowlist for global names47value: "CLOSURE_DEFINES" # Closure Compiler requires this to be a global var48value: "CLOSURE_UNCOMPILED_DEFINES" # Closure Compiler requires this to be a global var49value: "CLOSURE_NO_DEPS" # Closure Compiler requires this to be a global var50}5152requirement: {53rule_id: "closure:unknownThis"54type: CUSTOM55java_class: "com.google.javascript.jscomp.ConformanceRules$BanUnknownThis"56error_message: "References to \"this\" that are typed as \"unknown\" are not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#unknownThis"5758allowlist_regexp: ".+/closure/goog/base.js"59allowlist_regexp: ".+/closure/goog/debug/errorhandler.js"60allowlist_regexp: ".+/closure/goog/editor/plugins/linkbubble.js"61allowlist_regexp: ".+/closure/goog/editor/plugins/linkdialogplugin.js"62allowlist_regexp: ".+/closure/goog/functions/functions.js"63allowlist_regexp: ".+/closure/goog/memoize/memoize.js"64allowlist_regexp: ".+/closure/goog/pubsub/pubsub.js"65allowlist_regexp: ".+/closure/goog/testing/"66allowlist_regexp: ".+/closure/goog/ui/editor/bubble.js"67allowlist_regexp: ".+/closure/goog/ui/editor/toolbarcontroller.js"68# TODO(user): Violation occurs in code generated by Emscripten.69allowlist_regexp: ".+_wasm_js_library_generated.js"70}7172### Browser tech requirements ###7374# This requirement is somewhat Google-specific: open-source Closure users that75# don't use GAPI could reasonably ignore it depending on how they do messaging76# in their app.77requirement: {78rule_id: "closure:postMessage"79type: BANNED_PROPERTY_CALL80error_message: "Window.prototype.postMessage is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#postMessage"8182value: "Window.prototype.postMessage"8384# Known-safe common infrastructure.85allowlist_regexp: ".+/closure/goog/async/nexttick.js"86allowlist_regexp: ".+/closure/goog/net/xpc/nativemessagingtransport.js"87# TODO(user): make sure this gets security reviewed (b/29333525).88allowlist_regexp: ".+/closure/goog/messaging/portchannel.js"89}9091### Security: forbid DOM properties and functions which can cause XSS ###9293# These are properties and functions which might have safe wrappers under94# goog.dom.safe. Two groups: properties and functions which accept95# HTML/CSS/script-as-string, properties and function which accept URLs.9697#### DOM properties and functions which accept HTML/CSS/script-as-string #####9899requirement: {100rule_id: 'closure:eval'101# TODO(jakubvrana): Change to BANNED_NAME_CALL after cl/154708486 lands.102type: BANNED_NAME103error_message: 'eval is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#eval'104105value: 'eval'106value: 'execScript'107value: 'goog.globalEval'108109allowlist_regexp: '.+/closure/goog/base.js' # goog.module loading in uncompiled code.110allowlist_regexp: '.+/closure/goog/goog.js' # Forwards goog.globalEval111allowlist_regexp: '.+/closure/goog/debug/errorhandler.js' # wraps setTimeout and similar functions112allowlist_regexp: '.+/closure/goog/json/json.js' # used in goog.json.parse113allowlist_regexp: '.+/closure/goog/module/loader.js'114allowlist_regexp: '.+/closure/goog/module/moduleloader.js'115}116117requirement: {118rule_id: 'closure:windowEval'119type: BANNED_PROPERTY_CALL120error_message: 'window.eval is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#eval'121122value: 'Window.prototype.eval'123value: 'Window.prototype.execScript'124125allowlist_regexp: '.+/closure/goog/base.js'126# TODO(jakubvrana): To be investigated.127allowlist_regexp: '.+/closure/goog/net/xpc/nixtransport.js'128}129130requirement: {131rule_id: 'closure:stringFunctionDefinition'132type: RESTRICTED_NAME_CALL133error_message: 'Function, setTimeout, setInterval and requestAnimationFrame are not allowed with string argument. See https://google.github.io/closure-library/develop/conformance_rules.html#eval'134135value: 'Function:function()'136value: 'setTimeout:function(Function, ...?)'137value: 'setInterval:function(Function, ...?)'138value: 'requestAnimationFrame:function(Function, ...?)'139}140141requirement: {142rule_id: 'closure:windowStringFunctionDefinition'143type: RESTRICTED_METHOD_CALL144error_message: 'window.setTimeout, setInterval and requestAnimationFrame are not allowed with string argument. See https://google.github.io/closure-library/develop/conformance_rules.html#eval'145146value: 'Window.prototype.setTimeout:function(Function, ...?)'147value: 'Window.prototype.setInterval:function(Function, ...?)'148value: 'Window.prototype.requestAnimationFrame:function(Function, ...?)'149}150151requirement: {152rule_id: 'closure:innerHtml'153type: BANNED_PROPERTY_NON_CONSTANT_WRITE154error_message: 'Assignment to Element.prototype.innerHTML is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#innerHtml'155156value: 'Element.prototype.innerHTML'157158# Safe wrapper for this property.159allowlist_regexp: '.+/closure/goog/dom/safe.js'160161# Safe DOM Tree Processor and HTML sanitizer, which use it safely in order to162# have the browser parse an HTML string using an inert DOM.163allowlist_regexp: '.+/closure/goog/html/sanitizer/htmlsanitizer.js'164allowlist_regexp: '.+/closure/goog/html/sanitizer/safedomtreeprocessor.js'165# Safely used in goog.string.unescapeEntitiesUsingDom_; the string assigned to166# innerHTML is a single HTML entity.167allowlist_regexp: '.+/closure/goog/string/string.js'168# goog.soy.renderElement and renderAsElement. Safe if used with Strict Soy169# templates.170allowlist_regexp: '.+/closure/goog/soy/soy.js'171allowlist_regexp: '.+/closure/goog/dom/browserrange/ierange.js'172allowlist_regexp: '.+/closure/goog/editor/'173allowlist_regexp: '.+/closure/goog/style/style.js'174allowlist_regexp: '.+/closure/goog/testing/'175}176177requirement: {178rule_id: 'closure:outerHtml'179type: BANNED_PROPERTY_NON_CONSTANT_WRITE180error_message: 'Assignment to Element.prototype.outerHTML is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#innerHtml'181182value: 'Element.prototype.outerHTML'183184# Safe wrapper for this property.185allowlist_regexp: '.+/closure/goog/dom/safe.js'186allowlist_regexp: '.+/closure/goog/editor/'187}188189requirement: {190rule_id: 'closure:documentWrite'191type: BANNED_PROPERTY192error_message: 'Using Document.prototype.write is not allowed. Use goog.dom.safe.documentWrite instead. See https://google.github.io/closure-library/develop/conformance_rules.html#documentWrite.'193194value: 'Document.prototype.write'195value: 'Document.prototype.writeln'196197# These are safe.198allowlist_regexp: '.+/closure/goog/async/nexttick.js'199allowlist_regexp: '.+/closure/goog/base.js'200allowlist_regexp: '.+/closure/goog/dom/safe.js'201# TODO(jakubvrana): These need to be refactored.202allowlist_regexp: '.+/closure/goog/editor/icontent.js'203allowlist_regexp: '.+/closure/goog/testing/'204}205206requirement: {207rule_id: "closure:untypedScript"208type: CUSTOM209java_class: "com.google.javascript.jscomp.ConformanceRules$BanCreateElement"210error_message: "Use goog.dom functions with goog.dom.TagName.SCRIPT to create <script> elements. See https://google.github.io/closure-library/develop/conformance_rules.html#untypedElements"211212value: "script"213214allowlist_regexp: ".+/closure/goog/base.js"215}216217requirement: {218rule_id: "closure:untypedIframe"219type: CUSTOM220java_class: "com.google.javascript.jscomp.ConformanceRules$BanCreateElement"221error_message: "Use goog.dom functions with goog.dom.TagName.IFRAME to create <iframe> elements. See https://google.github.io/closure-library/develop/conformance_rules.html#untypedElements"222223value: "iframe"224225allowlist_regexp: ".+/closure/goog/async/nexttick.js"226}227228requirement: {229rule_id: "closure:untypedFrame"230type: CUSTOM231java_class: "com.google.javascript.jscomp.ConformanceRules$BanCreateElement"232error_message: "Use goog.dom functions with goog.dom.TagName.FRAME to create <frame> elements. See https://google.github.io/closure-library/develop/conformance_rules.html#untypedElements"233234value: "frame"235}236237requirement: {238rule_id: "closure:untypedObject"239type: CUSTOM240java_class: "com.google.javascript.jscomp.ConformanceRules$BanCreateElement"241error_message: "Use goog.dom functions with goog.dom.TagName.OBJECT to create <object> elements. See https://google.github.io/closure-library/develop/conformance_rules.html#untypedElements"242243value: "object"244}245246requirement: {247rule_id: "closure:untypedEmbed"248type: CUSTOM249java_class: "com.google.javascript.jscomp.ConformanceRules$BanCreateElement"250error_message: "Use goog.dom functions with goog.dom.TagName.EMBED to create <embed> elements. See https://google.github.io/closure-library/develop/conformance_rules.html#untypedElements"251252value: "embed"253}254255requirement: {256rule_id: 'closure:scriptContentProperty'257type: BANNED_PROPERTY_WRITE258error_message: 'Setting content of <script> and then appending it to the document has the same effect as calling eval(). See https://google.github.io/closure-library/develop/conformance_rules.html#scriptContent'259# We ban untyped script creation by closure:untypedScript.260report_loose_type_violations: false261262value: 'HTMLScriptElement.prototype.innerHTML'263value: 'HTMLScriptElement.prototype.text'264value: 'HTMLScriptElement.prototype.textContent'265266allowlist_regexp: '.+/closure/goog/base.js'267allowlist_regexp: '.+/closure/goog/dom/safe.js'268}269270requirement: {271rule_id: 'closure:scriptContentMethod'272type: BANNED_PROPERTY273error_message: 'Setting content of <script> and then appending it to the document has the same effect as calling eval(). See https://google.github.io/closure-library/develop/conformance_rules.html#scriptContent'274# We ban untyped script creation by closure:untypedScript.275report_loose_type_violations: false276277value: 'HTMLScriptElement.prototype.appendChild'278279allowlist_regexp: '.+/closure/goog/base.js'280}281282#### DOM properties and functions which accept URLs ####283284# One rule per property name that exists for several types (e.g. href).285# Property names that exist for a single type (e.g. manifest) all286# share a single rule.287# Types with several dangerous properties and functions have their own rule288# (e.g. Location). This rule does not include any of its properties which are289# shared with other types (e.g. Location.prototype.href).290#291# For property names that exist on several types (e.g. href), the matching292# is done for their shared super type, even if the super type itself does not293# have the property. For example, Element does not have the href property, but294# many of its subtypes have. It's also necessary to match on Element for295# properties that exist on Element's subtypes because document.createElement()296# returns Element; matching on its subtypes only would miss many writes to the297# property.298299# TODO(mlourenco): Create locationType rule banning protocol, assign()300# and replace() of Location.301302# TODO(mlourenco): Move to "hrefProperty".303requirement: {304rule_id: 'closure:locationHref'305type: BANNED_PROPERTY_NON_CONSTANT_WRITE306error_message: 'Assignment to Location.prototype.href is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#location'307308value: 'Location.prototype.href'309310allowlist_regexp: '.+/closure/goog/dom/safe.js'311312# The following allowlist entries are due to usages of .href that still313# need to be refactored or reviewed. See http://b/12014412.314allowlist_regexp: '.+/closure/goog/history/history.js'315}316317# TODO(mlourenco): Rename to "locationProperty". Add Document.location to it.318requirement: {319rule_id: 'closure:location'320type: BANNED_PROPERTY_NON_CONSTANT_WRITE321error_message: 'Assignment to Window.prototype.location is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#location'322323value: 'Window.prototype.location'324}325326# TODO(user): Rename hrefProperty.327requirement: {328rule_id: 'closure:href'329type: BANNED_PROPERTY_NON_CONSTANT_WRITE330error_message: 'Assignment to .href property of Anchor, Link, etc elements, is not allowed. See https://google.github.io/closure-library/develop/conformance_rules.html#href'331332# Many subtypes of Element have an href property.333value: 'Element.prototype.href'334# These are not subtypes of Element.335value: 'StyleSheet.prototype.href'336value: 'CSSImportRule.prototype.href'337338# Safe wrapper for this property.339allowlist_regexp: '.+/closure/goog/dom/safe.js'340# The following allowlist entries are due to usages of .href that still341# need to be refactored or reviewed. See http://b/12014412.342allowlist_regexp: '.+/closure/goog/editor/plugins/linkdialogplugin.js'343allowlist_regexp: '.+/closure/goog/testing/testrunner.js'344# This use has previously been refactored away, but had to be rolled345# back due to breakages in gmail, see http://b/13727806.346# This use may actually be safe because it only assigns to .href in347# the context of a contenteditable. To be further reviewed.348allowlist_regexp: '.+/closure/goog/editor/link.js'349}350351# TODO(mlourenco): Move src to "srcProperty", others to "otherProperties". Ban352# "src" and other properties at "Element", so that elements returned by353# document.createElement() are captured.354requirement: {355rule_id: "closure:trustedResourceUrlProperties"356type: BANNED_PROPERTY_NON_CONSTANT_WRITE357error_message: "Assignment to property requires a TrustedResourceUrl via goog.dom.safe. See https://google.github.io/closure-library/develop/conformance_rules.html#trustedResourceUrl"358report_loose_type_violations: false359360# Properties which can only be assigned to from a TrustedResourceUrl.361value: "HTMLElement.prototype.manifest"362value: 'HTMLEmbedElement.prototype.src'363value: 'HTMLFrameElement.prototype.src'364value: 'HTMLIFrameElement.prototype.src'365# For HTMLLinkElement both href and rel have to be assigned at the same time.366value: "HTMLLinkElement.prototype.rel"367# TODO(mlourenco): We probably want an "objectType" rule instead since368# there are a bunch of dangerous properties.369value: "HTMLObjectElement.prototype.data"370value: 'HTMLScriptElement.prototype.src'371# TODO(mlourenco): Ban other dangerous properties (archive, classid, etc).372373# Closure's debug loader.374allowlist_regexp: '.+/closure/goog/base.js'375# Safe wrapper for this property.376allowlist_regexp: ".+/closure/goog/dom/safe.js"377# The following allowlist entries are due to assignments from string that378# still need to be refactored or reviewed. See http://b/12014412.379allowlist_regexp: '.+/closure/goog/net/crossdomainrpc.js'380allowlist_regexp: '.+/closure/goog/net/xpc/'381allowlist_regexp: '.+/closure/goog/testing/multitestrunner.js'382allowlist_regexp: '.+/closure/goog/ui/dragdropdetector.js'383}384385requirement: {386rule_id: "closure:createDom"387type: CUSTOM388java_class: "com.google.javascript.jscomp.ConformanceRules$BanCreateDom"389error_message: "Assigning a string to a dangerous property via createDom is forbidden. See https://google.github.io/closure-library/develop/conformance_rules.html#createDom"390391value: "embed.src"392value: "frame.src"393value: "html.manifest"394value: "iframe.src"395value: "object.data"396value: "script.src"397value: "script.text"398value: "script.textContent"399value: "track.src"400value: '*.href'401value: '*.innerHTML'402value: '*.outerHTML'403404allowlist_regexp: ".+/closure/tweak/tweakui.js" # False positive - missing type on containerNodeName. MOE:strip_line405allowlist_regexp: '.+/closure/goog/tweak/tweakui.js' # False positive - missing type on containerNodeName.406407# TODO(jakubvrana): Ban this.408allowlist_regexp: '.+/closure/goog/ui/abstractspellchecker.js'409}410411#### Closure functions which use goog.html.legacyconversions ####412413# These are functions which accept a string and then use414# goog.html.legacyconversions to convert the string into SafeHtml. They415# are not XSS-safe.416#417# These rules allow projects to have compile-time errors for legacyconversions418# functions and to progressively move away from them by using the allowlist.419420421422