/** * Copyright (c) 2025 Ofri Peretz * Licensed under the MIT License. Use of this source code is governed by the * MIT license that can be found in the LICENSE file. */ /** * ESLint Rule: no-directive-injection * Detects directive injection vulnerabilities (CWE-96) * * Directive injection occurs when user input is used to inject malicious * directives into template systems (Angular, Vue, React, etc.). Attackers * can inject directives that execute arbitrary code or manipulate the DOM. * * False Positive Reduction: * This rule uses security utilities to reduce false positives by detecting: * - Safe directive usage patterns * - Trusted directive sources * - JSDoc annotations (@trusted-directive, @safe-template) * - Framework-specific safe patterns */ import type { TSESLint } from '@interlace/eslint-devkit'; import { type SecurityRuleOptions } from '@interlace/eslint-devkit'; type MessageIds = 'directiveInjection' | 'unsafeDirectiveName' | 'dynamicDirectiveCreation' | 'templateInjection' | 'unsafeComponentBinding' | 'userControlledTemplate' | 'dangerousInnerHTML' | 'untrustedDirectiveSource' | 'useTrustedDirectives' | 'sanitizeTemplateInput' | 'validateDirectiveNames' | 'strategyTemplateSanitization' | 'strategyContentSecurity' | 'strategyInputValidation'; export interface Options extends SecurityRuleOptions { /** Trusted directive/component names */ trustedDirectives?: string[]; /** Variables that contain user input */ userInputVariables?: string[]; /** Frameworks to check for */ frameworks?: string[]; /** Allow dynamic directives in specific contexts */ allowDynamicInComponents?: boolean; } type RuleOptions = [Options?]; export declare const noDirectiveInjection: TSESLint.RuleModule & { name: string; }; export {};