Skip to main content

no-angularjs-sanitization-whitelist

Disallow AngularJS sanitization whitelist mutations that expand trusted inputs.

Targeted pattern scopeโ€‹

This rule targets writes and calls that configure:

  • $compileProvider.aHrefSanitizationWhitelist(...)
  • $compileProvider.imgSrcSanitizationWhitelist(...).

What this rule reportsโ€‹

This rule reports allow-list mutations that broaden URL patterns accepted by the AngularJS sanitizer.

Why this rule existsโ€‹

Overly broad sanitizer allow-lists can permit unsafe protocols or payloads and increase XSS risk.

โŒ Incorrectโ€‹

$compileProvider.aHrefSanitizationWhitelist(/.*/);
$compileProvider.imgSrcSanitizationWhitelist(/.*/);

โœ… Correctโ€‹

// Keep default AngularJS sanitizer allow-lists.

ESLint flat config exampleโ€‹

import sdl from "eslint-plugin-sdl-2";

export default [
{
plugins: { sdl },
rules: {
"sdl/no-angularjs-sanitization-whitelist": "error",
},
},
];

When not to use itโ€‹

Disable only when a migration requires temporary allow-list expansion that is strictly bounded and reviewed.

Package documentationโ€‹

Further readingโ€‹

Rule catalog ID: R005