@ordojs/security
Version:
Security package for OrdoJS with XSS, CSRF, and injection protection
96 lines • 2.78 kB
TypeScript
/**
* XSS vulnerability detection and analysis
*/
/**
* Types of XSS vulnerabilities
*/
export declare enum XssVulnerabilityType {
REFLECTED = "reflected",
STORED = "stored",
DOM_BASED = "dom-based",
TEMPLATE_INJECTION = "template-injection"
}
/**
* Severity levels for vulnerabilities
*/
export declare enum VulnerabilitySeverity {
LOW = "low",
MEDIUM = "medium",
HIGH = "high",
CRITICAL = "critical"
}
/**
* XSS vulnerability detection result
*/
export interface XssVulnerability {
type: XssVulnerabilityType;
severity: VulnerabilitySeverity;
description: string;
location: string;
payload: string;
recommendation: string;
}
/**
* XSS vulnerability detector
*/
export declare class XssVulnerabilityDetector {
private patterns;
private dangerousAttributes;
/**
* Create a new XSS vulnerability detector
*/
constructor();
/**
* Scan content for potential XSS vulnerabilities
* @param content Content to scan
* @param location Location identifier for the content
* @returns Array of detected vulnerabilities
*/
scanContent(content: string, location?: string): XssVulnerability[];
/**
* Check if a string contains potential XSS payload
* @param input Input string to check
* @returns True if potential XSS is detected
*/
containsXss(input: string): boolean;
/**
* Analyze template for potential injection vulnerabilities
* @param template Template string
* @param variables Variables used in template
* @returns Array of vulnerabilities
*/
analyzeTemplate(template: string, variables?: Record<string, unknown>): XssVulnerability[];
/**
* Determine the type of XSS vulnerability based on the payload
* @param payload The detected payload
* @returns Vulnerability type
*/
private determineVulnerabilityType;
/**
* Determine the severity of a vulnerability based on the payload
* @param payload The detected payload
* @returns Vulnerability severity
*/
private determineSeverity;
/**
* Get recommendation for fixing a vulnerability
* @param payload The detected payload
* @returns Recommendation string
*/
private getRecommendation;
/**
* Add a custom XSS pattern to detect
* @param pattern Regular expression pattern
*/
addPattern(pattern: RegExp): void;
/**
* Add a custom dangerous attribute to detect
* @param attribute Attribute name
*/
addDangerousAttribute(attribute: string): void;
}
/**
* Default XSS vulnerability detector instance
*/
export declare const defaultXssDetector: XssVulnerabilityDetector;
//# sourceMappingURL=vulnerability-detector.d.ts.map