File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -194,13 +194,16 @@ async function checkFromExternalChecks() {
194194 if ( extraDangerFilePath ) {
195195 try {
196196 const workspaceDir = '/github/workspace' ;
197- const customPath = `${ workspaceDir } /${ extraDangerFilePath } ` ;
198197
199- if ( extraDangerFilePath . indexOf ( '..' ) !== - 1 ) {
200- fail ( `Invalid dangerfile path: ${ customPath } . Path traversal is not allowed.` ) ;
198+ const path = require ( 'path' ) ;
199+ const customPath = path . join ( workspaceDir , extraDangerFilePath ) ;
200+ // Ensure the resolved path is within workspace
201+ const resolvedPath = fs . realpathSync ( customPath ) ;
202+ if ( ! resolvedPath . startsWith ( workspaceDir ) ) {
203+ fail ( `Invalid dangerfile path: ${ extraDangerFilePath } . Must be within workspace.` ) ;
201204 return ;
202205 }
203-
206+
204207 const extraModule = require ( customPath ) ;
205208 if ( typeof extraModule !== 'function' ) {
206209 warn ( `EXTRA_DANGERFILE must export a function at ${ customPath } ` ) ;
You can’t perform that action at this time.
0 commit comments