Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { readdir, readFile, writeFile, unlink, mkdir, stat, lstat } from 'node:fs/promises';
import { join, basename, extname, resolve } from 'node:path';
import { join, basename, extname, resolve, sep } from 'node:path';
import type { Page, PageMetadata, SearchResult, SearchMatch, Graph, GraphNode, GraphEdge } from './types.js';

// 보안 상수
Expand Down Expand Up @@ -569,7 +569,8 @@ export class GraphService {
const normalizedPath = resolve(filePath);
const normalizedGraphPath = resolve(this.graphPath);

if (!normalizedPath.startsWith(normalizedGraphPath + '/') && normalizedPath !== normalizedGraphPath) {
// Windows/Unix 호환: path.sep 사용 ('/' 또는 '\')
if (!normalizedPath.startsWith(normalizedGraphPath + sep) && normalizedPath !== normalizedGraphPath) {
throw new Error(`Access denied: path outside graph directory`);
}

Expand Down