@felixgeelhaar/cclint
Version:
Catch CLAUDE.md drift before Claude misbehaves. Lints CLAUDE.md, skills, subagents, and hooks for Claude Code projects.
60 lines • 2.27 kB
TypeScript
/**
* Security utility for validating file paths to prevent directory traversal attacks
*/
export declare class PathValidator {
private readonly allowedExtensions;
private readonly maxPathLength;
private readonly forbiddenPatterns;
constructor(allowedExtensions?: string[], maxPathLength?: number);
/**
* Validate a file path for security issues
* @param filePath The path to validate
* @param basePath Optional base path to restrict access within
* @returns Normalized, safe path
* @throws Error if path is invalid or unsafe
*/
validatePath(filePath: string, basePath?: string): string;
/**
* Check if a file has an allowed extension
* @param filePath The path to check
* @returns True if extension is allowed
*/
hasAllowedExtension(filePath: string): boolean;
/**
* Validate that a path exists and is a file (not a directory)
* @param filePath The path to check
* @returns True if path exists and is a file
*/
isValidFile(filePath: string): boolean;
/**
* Validate that a path exists and is a directory
* @param dirPath The path to check
* @returns True if path exists and is a directory
*/
isValidDirectory(dirPath: string): boolean;
/**
* Resolve a path to its real (symlink-followed) location.
*
* `realpathSync` throws when the target does not exist, which is legitimate
* for paths that are about to be created. To stay robust we resolve the
* deepest existing ancestor and re-append the not-yet-existing tail, so the
* returned path reflects any symlinks in the existing portion.
*
* @param targetPath Absolute path to resolve
* @returns The real, symlink-followed absolute path
*/
private resolveRealPath;
/**
* Get the file extension from a path
* @param filePath The path to extract extension from
* @returns The file extension including the dot
*/
private getExtension;
/**
* Sanitize a filename to remove potentially dangerous characters
* @param filename The filename to sanitize
* @returns Sanitized filename
*/
sanitizeFilename(filename: string): string;
}
//# sourceMappingURL=PathValidator.d.ts.map