import { ConformancePatternRule , ErrorCode , PatternKind } from '../../third_party/tsetse/rules/conformance_pattern_rule' ; import { overridePatternConfig } from '../../third_party/tsetse/util/pattern_config' ; import { TRUSTED_SCRIPT_URL } from '../../third_party/tsetse/util/trusted_types_configuration' ; import { RuleConfiguration } from '../../rule_configuration' ; let errMsg = 'Do not assign variables to HTMLScriptElement#src, as this can lead to XSS.' ; /**
 * A Rule that looks for dynamic assignments to an HTMLScriptElement's src
 * property, and suggests using safe setters instead.
 */ export class Rule extends ConformancePatternRule { static readonly RULE_NAME = 'ban-script-src-assignments' ; constructor ( configuration = { } ) { super ( overridePatternConfig ( { errorCode : ErrorCode . CONFORMANCE_PATTERN , errorMessage : errMsg , kind : PatternKind . BANNED_PROPERTY_WRITE , values : [ 'HTMLScriptElement.prototype.src' ] , ... configuration , name : Rule . RULE_NAME , allowedTrustedType : TRUSTED_SCRIPT_URL , } ) ) ; } }