Challenge - 5 Problems
Deno Permissions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateWhat does the --allow-all flag do in Deno?
In Deno, what is the effect of running a script with the
--allow-all flag?Attempts:
2 left
💡 Hint
Think about what 'all permissions' means for a program.
✗ Incorrect
The
--allow-all flag in Deno grants the script full access to all permissions like file system, network, environment variables, and more, without any prompts or restrictions.❓ component_behavior
intermediateWhat happens if you run a Deno script without --allow-all and it tries to read a file?
Consider a Deno script that tries to read a file from the disk. What will happen if you run it without the
--allow-all flag or any file read permission flags?Attempts:
2 left
💡 Hint
Deno is secure by default and restricts access unless explicitly allowed.
✗ Incorrect
Without explicit permission flags like
--allow-read or --allow-all, Deno denies file system access and throws a permission error.📝 Syntax
advancedWhich command correctly runs a Deno script with all permissions?
You have a script named
app.ts. Which command runs it with all permissions enabled?Attempts:
2 left
💡 Hint
Remember the order of flags and arguments in Deno CLI commands.
✗ Incorrect
The correct syntax places flags before the script name:
deno run --allow-all app.ts. Options after the script name are treated as script arguments.🔧 Debug
advancedWhy does this Deno script fail despite using --allow-all?
You run
deno run --allow-all script.ts but the script throws a permission error when accessing environment variables. What is the likely cause?Deno
console.log(Deno.env.get('HOME'));Attempts:
2 left
💡 Hint
Some Deno APIs are behind an unstable flag even with permissions.
✗ Incorrect
Accessing environment variables requires permission and sometimes the
--unstable flag if the API is unstable. Without --unstable, even with --allow-all, some APIs may fail.❓ state_output
expertWhat is the output of this Deno script run with --allow-all?
Given the script below, what will be printed when run with
deno run --allow-all script.ts?Deno
import { readTextFileSync } from "https://deno.land/std/fs/mod.ts"; try { const data = readTextFileSync("./data.txt"); console.log(data.trim()); } catch { console.log("File not found"); }
Attempts:
2 left
💡 Hint
Consider the effect of --allow-all on file system access and the try-catch block.
✗ Incorrect
With
--allow-all, the script can read files. If data.txt exists, its trimmed content prints. If not, the catch prints "File not found". The import URL is valid and no permission error occurs.