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
1412import { parentPort } from 'node:worker_threads' ;
15- import { resolve } from 'node:path' ;
1613import { parseFile } from './parser.js' ;
17- import { isSubpath } from './path-utils.js' ;
1814import { ParseError } from './errors.js' ;
1915
2016interface ParseRequest {
@@ -25,7 +21,6 @@ interface ParseRequest {
2521
2622type 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
3126if ( ! 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