Skip to content

Commit 065f72a

Browse files
authored
Merge pull request #11 from O-Labz/memory-improvements
fix(parser): remove redundant path confinement security in workers
2 parents c8ee48c + a06c0e1 commit 065f72a

2 files changed

Lines changed: 5 additions & 23 deletions

File tree

src/core/parse-pool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class ParsePool {
141141
this.recycleWorkerIfNeeded(poolWorker);
142142
resolve(response.parsed);
143143
} else {
144-
// Worker reported an error (security or parse)
144+
// Worker reported a parse error
145145
console.warn(`index.file.skipped`, {
146146
filePath: request.filePath,
147147
reason: response.kind,

src/core/parse-worker.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
/**
22
* Worker thread entry for parsing files in isolation
33
*
4-
* This worker receives file parsing requests via parentPort, validates the file path
5-
* to ensure it's within workspaceRoot (preventing directory traversal), and delegates
4+
* This worker receives file parsing requests via parentPort and delegates
65
* to the existing parseFile function. The worker reports success/failure via structured
76
* messages that can be serialized across the worker boundary.
87
*
9-
* Security: File paths MUST be validated against workspaceRoot using isSubpath to
10-
* prevent directory traversal attacks. On violation, reports security error without
11-
* crashing the worker.
8+
* Note: Path validation is not needed here as repositories are explicitly managed
9+
* through the UI and only added repositories are indexed.
1210
*/
1311

1412
import { parentPort } from 'node:worker_threads';
15-
import { resolve } from 'node:path';
1613
import { parseFile } from './parser.js';
17-
import { isSubpath } from './path-utils.js';
1814
import { ParseError } from './errors.js';
1915

2016
interface ParseRequest {
@@ -25,7 +21,6 @@ interface ParseRequest {
2521

2622
type ParseResponse =
2723
| { ok: true; parsed: any } // ParsedFile from parser.ts
28-
| { ok: false; kind: 'security'; message: string }
2924
| { ok: false; kind: 'parse'; message: string };
3025

3126
if (!parentPort) {
@@ -36,21 +31,8 @@ parentPort.on('message', async (request: ParseRequest) => {
3631
try {
3732
const { filePath, repositoryId, workspaceRoot } = request;
3833

39-
// Canonicalize and validate the file path
40-
const resolvedPath = resolve(filePath);
41-
const resolvedWorkspace = resolve(workspaceRoot);
42-
43-
if (!isSubpath(resolvedWorkspace, resolvedPath)) {
44-
const response: ParseResponse = {
45-
ok: false,
46-
kind: 'security',
47-
message: `File path '${filePath}' is outside workspace root '${workspaceRoot}'`
48-
};
49-
parentPort!.postMessage(response);
50-
return;
51-
}
52-
5334
// Parse the file using the existing parseFile function
35+
// Note: Path validation removed as repositories are explicitly managed through UI
5436
try {
5537
const parsed = await parseFile(filePath, repositoryId, workspaceRoot);
5638
const response: ParseResponse = { ok: true, parsed };

0 commit comments

Comments
 (0)