Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop): resolve zip helper CodeQL alerts
M0e7003c6ffd5
diff --git a/desktop-app/src/__tests__/gfsZipStream.test.ts b/desktop-app/src/__tests__/gfsZipStream.test.tsindex b905a5854..c0baca833 100644--- a/desktop-app/src/__tests__/gfsZipStream.test.ts+++ b/desktop-app/src/__tests__/gfsZipStream.test.ts@@ -9,7 +9,7 @@*/import { afterEach, describe, expect, it, vi } from 'vitest'import { execFile } from 'node:child_process'-import { existsSync } from 'node:fs'+import { constants, existsSync } from 'node:fs'import { mkdtemp, open, readFile, readdir, rm, stat } from 'node:fs/promises'import { tmpdir } from 'node:os'import { join } from 'node:path'@@ -154,11 +154,21 @@ async function extractWithSystemUnzip(archivePath: string): Promise<Record<strinawait execFileAsync('unzip', ['-o', '-q', archivePath, '-d', target])const out: Record<string, string> = {}const walk = async (dir: string, prefix: string) => {- for (const name of await readdir(dir)) {- const full = join(dir, name)- const info = await stat(full)- if (info.isDirectory()) await walk(full, `${prefix}${name}/`)- else out[`${prefix}${name}`] = (await readFile(full)).toString('utf8')+ for (const entry of await readdir(dir, { withFileTypes: true })) {+ const full = join(dir, entry.name)+ if (entry.isDirectory()) {+ await walk(full, `${prefix}${entry.name}/`)+ } else {+ const file = await open(full, constants.O_RDONLY | constants.O_NOFOLLOW)+ try {+ // Inspect and read the same open file, so replacing its path cannot+ // change the file between the check and the read.+ expect((await file.stat()).isFile()).toBe(true)+ out[`${prefix}${entry.name}`] = await file.readFile('utf8')+ } finally {+ await file.close()+ }+ }}}await walk(target, '')diff --git a/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.ts b/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.tsindex bdd08f80f..3d45d7628 100644--- a/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.ts+++ b/desktop-app/ui/src/lib/__tests__/gfsFolderZip.test.ts@@ -1024,6 +1024,7 @@ describe('createGfsFolderZip', () => {{ resourceId: 'root', drive: 'main', name: 'Emoji' },{ deps: emojiDeps })+ expect(emojiResult.fileCount).toBe(1)const emojiName = streamEntryNames(emojiDeps.zipStreamRecord)[0]!expect(emojiName.endsWith('\uFFFD')).toBe(false)expect(new TextEncoder().encode(emojiName.slice('Emoji/'.length)).length).toBeLessThanOrEqual(