Skip to content

Commit 9aa514b

Browse files
fix(deno): Read cwd without a permission check in modulesIntegration
Querying read permission without a path only reports granted for a blanket --allow-read, so with a scoped flag like --allow-read=. the cwd was never found. Deno.cwd() needs no permission since Deno 2. Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
1 parent 550c807 commit 9aa514b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎packages/deno/src/integrations/modules.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { defineIntegration, dirname, join } from '@sentry/core';
44
import { collectInstalledModules } from '@sentry/server-utils';
55

66
/** Reads only with granted permission, so it never prompts. */
7-
function readFile(path?: string): string | undefined {
7+
function readFile(path: string): string | undefined {
88
try {
99
if (Deno.permissions.querySync({ name: 'read', path }).state === 'granted') {
10-
return path ? Deno.readTextFileSync(path) : Deno.cwd();
10+
return Deno.readTextFileSync(path);
1111
}
1212
} catch {
1313
// not readable
@@ -42,9 +42,9 @@ function getDenoLockModules(startDir: string): Record<string, string> {
4242

4343
function collectModules(): Record<string, string> {
4444
const entryPath = Deno.mainModule.startsWith('file:') ? fileURLToPath(Deno.mainModule) : undefined;
45-
const cwd = readFile();
45+
const cwd = Deno.cwd();
4646
const modules = collectInstalledModules({ readFile, entryPath, cwd });
47-
const startDir = (entryPath ? dirname(entryPath.replace(/\\/g, '/')) : cwd?.replace(/\\/g, '/')) || '.';
47+
const startDir = (entryPath ? dirname(entryPath.replace(/\\/g, '/')) : cwd.replace(/\\/g, '/')) || '.';
4848
// Without `node_modules`, `modules` only has declared ranges, so the exact versions from `deno.lock` win.
4949
return { ...modules, ...getDenoLockModules(startDir) };
5050
}

0 commit comments

Comments
 (0)