feat(security): implement path validation to prevent traversal attacks in session handling

This commit is contained in:
catlog22
2026-02-26 09:56:35 +08:00
parent 519efe9783
commit 21e3647331
8 changed files with 211 additions and 116 deletions

View File

@@ -162,8 +162,8 @@ export function parseClaudeSession(filePath: string): ParsedSession | null {
if (entry.timestamp) {
lastUpdated = entry.timestamp;
}
} catch {
// Skip invalid lines
} catch (e) {
console.warn('[claude-session-parser] Failed to parse JSON line:', e instanceof Error ? e.message : String(e));
}
}
@@ -426,8 +426,8 @@ export function parseClaudeSessionContent(content: string, filePath?: string): P
if (entry.timestamp) {
lastUpdated = entry.timestamp;
}
} catch {
// Skip invalid lines
} catch (e) {
console.warn('[claude-session-parser] Failed to parse JSON line in parseClaudeSessionContent:', e instanceof Error ? e.message : String(e));
}
}