MCPcopy Create free account
hub / github.com/github/gh-aw / isSafeScriptName

Function isSafeScriptName

pkg/workflow/safe_scripts.go:81–85  ·  view source on GitHub ↗

isSafeScriptName returns true if the script name is safe for use as a filename component. It rejects names that contain path separators or ".." sequences that could lead to path traversal when the generated filename is passed to require() at runtime.

(name string)

Source from the content-addressed store, hash-verified

79// It rejects names that contain path separators or ".." sequences that could lead to
80// path traversal when the generated filename is passed to require() at runtime.
81func isSafeScriptName(name string) bool {
82 return !strings.Contains(name, "/") &&
83 !strings.Contains(name, "\\") &&
84 !strings.Contains(name, "..")
85}
86
87// buildCustomSafeOutputScriptsJSON builds a JSON mapping of custom safe output script names to their
88// .cjs filenames, for use in the GH_AW_SAFE_OUTPUT_SCRIPTS env var of the handler manager step.

Callers 2

TestIsSafeScriptNameFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsSafeScriptNameFunction · 0.68