UNPKG

nehonix-uri-processor

Version:

A powerful URI processor for encoding, decoding, and analyzing URI data securely.

107 lines 4.81 kB
import { MaliciousComponentType } from "../types/v2.2.0"; import { ContextAnalysisResult, DetectedPattern, MaliciousPatternOptions, MaliciousPatternResult, MaliciousPatternType, RelatedPatternGroup } from "../services/MaliciousPatterns.service"; import NSS from "../services/NehonixSecurity.service"; export declare class NMPSUtils { private static SUSPICIOUS_PARAMETER_NAMES; static sanitizeInput: typeof NSS.sanitizeInput; constructor(sanitizeInput: typeof NSS.sanitizeInput); static isSafeHighEntropy(input: string): boolean; /** * Generates a recommendation specifically for URLs based on detected patterns */ static generateUrlRecommendation(detectedPatterns: DetectedPattern[], componentResults: Record<MaliciousComponentType, MaliciousPatternResult>): string; /** * Finds related patterns across different components that might indicate a sophisticated attack */ static findRelatedPatternGroups(patterns: DetectedPattern[]): RelatedPatternGroup[]; /** * Checks a string against a set of regex patterns for a specific attack type */ static checkPatterns(input: string, patterns: RegExp[], type: MaliciousPatternType, description: string, severity: "low" | "medium" | "high", results: DetectedPattern[], options: Required<MaliciousPatternOptions>): void; /** * Checks for suspicious parameter names in a URL */ static checkSuspiciousParameters(input: string, results: DetectedPattern[], options: Required<MaliciousPatternOptions>): void; /** * Calculates confidence level for a pattern match based on match characteristics */ static calculateConfidence(matchedValue: string, fullInput: string): "low" | "medium" | "high"; /** * Checks if a match is likely a false positive based on context */ static isLikelyFalsePositive(match: string, fullInput: string): boolean; /** * Calculates additional context score for pattern matches */ static calculateContextScore(match: RegExpExecArray, fullInput: string): number; /** * Performs contextual analysis on detected patterns to improve detection accuracy */ static performContextualAnalysis(patterns: DetectedPattern[], fullInput: string, options: MaliciousPatternOptions): ContextAnalysisResult; /** * Calculates Shannon entropy of a string to detect random or encoded content * Higher entropy often indicates encryption or encoding */ static calculateEntropy(input: string): number; /** * Detects number of potential encoding layers in a string */ static detectEncodingLayers(input: string): number; /** * Calculates statistical anomaly score based on character distribution */ static calculateAnomalyScore(input: string): number; /** * Calculates total risk score based on detected patterns */ static calculateTotalScore(patterns: DetectedPattern[], sensitivityMultiplier: number): number; /** * Determines overall confidence level based on score and pattern count */ static determineConfidence(score: number, patternCount: number): "low" | "medium" | "high"; /** * Generates appropriate recommendation based on detected patterns */ static generateRecommendation(patterns: DetectedPattern[], score: number): string; /** * Checks if content is likely HTML/JavaScript code fragment * * @param input - String to check * @returns boolean indicating if it looks like code */ static isLikelyCode(input: string): boolean; /** * Checks if a tag is in the allowed safe tags list * @param tag - The tag name to check * @returns Whether the tag is considered safe */ static isSafeTag(tag: string): boolean; /** * Creates a placeholder of specified length to preserve original string length * @param type - Type of content being replaced * @param length - Length of the original content * @returns Placeholder string of approximately the same length */ static createPlaceholder(type: string, length: number): string; /** * Checks if input appears to be a URL * @param input - String to check * @returns Whether the input looks like a URL */ static isUrlLike(input: string): boolean; /** * Specialized sanitization for URLs * @param url - URL to sanitize * @param opts - Sanitization options * @returns Sanitized URL */ sanitizeUrl(url: string, opts: any): string; /** * Handle potential redirect parameters in URLs * @param url - URL to check * @param opts - Sanitization options * @returns Sanitized URL */ handlePotentialRedirect(url: string, opts: any): string; } //# sourceMappingURL=NMPSUtils.d.ts.map