Package com.google.javascript.jscomp
Class ConformanceRules.BanSettingAttributes
- java.lang.Object
-
- com.google.javascript.jscomp.ConformanceRules.AbstractRule
-
- com.google.javascript.jscomp.ConformanceRules.BanSettingAttributes
-
- All Implemented Interfaces:
CheckConformance.Rule
- Enclosing class:
- ConformanceRules
public static final class ConformanceRules.BanSettingAttributes extends ConformanceRules.AbstractRule
Can be used to ban any function likeElement#setAttribute
which takes two parameters, an attribute name and a value.The specific attribute names that are banned are specified in
BANNED_ATTRS
below.
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.ImmutableSet<java.lang.String>
BANNED_ATTRS
Security-sensitive attributes that are banned from being set.
-
Constructor Summary
Constructors Constructor Description BanSettingAttributes(AbstractCompiler compiler, com.google.javascript.jscomp.Requirement requirement)
Create a custom checker to ban a function likeElement#setAttribute
based on a conformance requirement spec.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ConformanceRules.ConformanceResult
checkConformance(NodeTraversal traversal, Node node)
-
Methods inherited from class com.google.javascript.jscomp.ConformanceRules.AbstractRule
check, report, tsIsAllowlisted
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.javascript.jscomp.CheckConformance.Rule
getPrecondition
-
-
-
-
Field Detail
-
BANNED_ATTRS
public static final com.google.common.collect.ImmutableSet<java.lang.String> BANNED_ATTRS
Security-sensitive attributes that are banned from being set.Making updates to these attributes requires a new JSCompiler release. You must test the change using a global presubmit "at head" and update any affected allowlists. See go/jscompiler-global-presubmit and go/tsjs-conformance-team-docs.
-
-
Constructor Detail
-
BanSettingAttributes
public BanSettingAttributes(AbstractCompiler compiler, com.google.javascript.jscomp.Requirement requirement) throws CheckConformance.InvalidRequirementSpec
Create a custom checker to ban a function likeElement#setAttribute
based on a conformance requirement spec.Names in
value
fields indicate the functions that should be blocked. ThrowsCheckConformance.InvalidRequirementSpec
if the requirement is malformed.
-
-
Method Detail
-
checkConformance
protected ConformanceRules.ConformanceResult checkConformance(NodeTraversal traversal, Node node)
- Specified by:
checkConformance
in classConformanceRules.AbstractRule
- Returns:
- Whether the code represented by the Node conforms to the rule.
-
-