File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -194,13 +194,17 @@ 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 fs = require ( 'fs' ) ;
200+ const customPath = path . join ( workspaceDir , extraDangerFilePath ) ;
201+ // Ensure the resolved path is within workspace
202+ const resolvedPath = fs . realpathSync ( customPath ) ;
203+ if ( ! resolvedPath . startsWith ( workspaceDir ) ) {
204+ fail ( `Invalid dangerfile path: ${ extraDangerFilePath } . Must be within workspace.` ) ;
201205 return ;
202206 }
203-
207+
204208 const extraModule = require ( customPath ) ;
205209 if ( typeof extraModule !== 'function' ) {
206210 warn ( `EXTRA_DANGERFILE must export a function at ${ customPath } ` ) ;
You can’t perform that action at this time.
0 commit comments