@@ -325,13 +325,17 @@ func RunGraph(ctx context.Context, graphName string, graphContent []byte, opts R
325325
326326 // Priority 1 (Lowest): Config file
327327 if opts .ConfigFile != "" {
328- if _ , err := os .Stat (opts .ConfigFile ); err == nil {
329- localConfig , err := utils .LoadConfig (opts .ConfigFile )
328+ cleanConfigPath , err := utils .ValidatePath (opts .ConfigFile )
329+ if err != nil {
330+ return CreateErr (nil , err , "invalid config file path" )
331+ }
332+ if _ , err := os .Stat (cleanConfigPath ); err == nil {
333+ localConfig , err := utils .LoadConfig (cleanConfigPath )
330334 if err != nil {
331335 return CreateErr (nil , err , "failed to load config file" )
332336 }
333337
334- configName := filepath .Base (opts . ConfigFile )
338+ configName := filepath .Base (cleanConfigPath )
335339 envTracker .set (localConfig .Env , configName , true , false )
336340 inputTracker .set (localConfig .Inputs , configName , true , false )
337341 secretTracker .set (localConfig .Secrets , configName , true , true )
@@ -463,11 +467,15 @@ func RunGraph(ctx context.Context, graphName string, graphContent []byte, opts R
463467 }
464468
465469 if newCwd != "" {
470+ cleanCwd , err := utils .ValidatePath (newCwd )
471+ if err != nil {
472+ return CreateErr (nil , err , "invalid working directory path" )
473+ }
466474 originalCwd , err := os .Getwd ()
467475 if err != nil {
468476 return CreateErr (nil , err , "failed to get current working directory" )
469477 }
470- if err := os .Chdir (newCwd ); err != nil {
478+ if err := os .Chdir (cleanCwd ); err != nil {
471479 return CreateErr (nil , err , "failed to change working directory to ACT_CWD/GITHUB_WORKSPACE" )
472480 }
473481 defer func () {
@@ -1102,10 +1110,14 @@ func RunGraphFromString(ctx context.Context, graphName string, graphContent stri
11021110}
11031111
11041112func RunGraphFromFile (ctx context.Context , graphFile string , opts RunOpts , debugCb DebugCallback ) error {
1105- graphContent , err := os .ReadFile (graphFile )
1113+ cleanPath , err := utils .ValidatePath (graphFile )
1114+ if err != nil {
1115+ return CreateErr (nil , err , "invalid graph file path" )
1116+ }
1117+ graphContent , err := os .ReadFile (cleanPath )
11061118 if err != nil {
11071119 if os .IsNotExist (err ) {
1108- err = fmt .Errorf ("open %s: no such file or directory" , graphFile )
1120+ err = fmt .Errorf ("open %s: no such file or directory" , cleanPath )
11091121 }
11101122
11111123 return CreateErr (nil , err , "failed loading graph" )
0 commit comments