MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / writeSecureTempFile

Function writeSecureTempFile

src/util/secureTempFiles.ts:27–39  ·  view source on GitHub ↗
(
  directory: string,
  filename: string,
  contents: string,
)

Source from the content-addressed store, hash-verified

25}
26
27export async function writeSecureTempFile(
28 directory: string,
29 filename: string,
30 contents: string,
31): Promise<string> {
32 if (!isSimpleLeafName(filename)) {
33 throw new Error('Secure temporary file names must be simple leaf names');
34 }
35
36 const filePath = path.join(directory, filename);
37 await fs.writeFile(filePath, contents, SECURE_FILE_OPTIONS);
38 return filePath;
39}
40
41export async function removeSecureTempDirectory(directory: string): Promise<void> {
42 await fs.rm(directory, { force: true, recursive: true });

Callers 6

runPythonCodeFunction · 0.90
runPythonFunction · 0.90
executeCallMethod · 0.90
runRubyCodeFunction · 0.90
runRubyFunction · 0.90

Calls 1

isSimpleLeafNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…