Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to safely execute a command in a sandboxed environment.
Agentic AI
sandbox.execute([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing commands that can harm the system like 'rm -rf /'.
Trying to run shutdown or format commands.
✗ Incorrect
The command 'ls -la' lists files and is safe to run in a sandbox. Other commands are dangerous and should not be executed.
2fill in blank
mediumComplete the code to restrict the sandbox to only allow read operations.
Agentic AI
sandbox.set_permissions([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'read-write' which allows modifying files.
Using 'execute-only' which allows running code.
✗ Incorrect
Setting permissions to 'read-only' ensures the sandbox can only read files, preventing dangerous write or execute operations.
3fill in blank
hardFix the error in the sandbox initialization to prevent dangerous code execution.
Agentic AI
sandbox = Sandbox([1]=False)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Disabling network instead of file write permissions.
Disabling logging or debug which do not affect safety.
✗ Incorrect
Setting 'allow_file_write=False' disables file writing in the sandbox, preventing dangerous modifications.
4fill in blank
hardFill both blanks to create a sandbox that limits CPU and memory usage.
Agentic AI
sandbox = Sandbox(cpu_limit=[1], memory_limit=[2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting CPU limit too low or memory limit too high.
Confusing units for CPU and memory limits.
✗ Incorrect
Setting cpu_limit to 100% and memory_limit to 1024 MB restricts resource usage to safe levels.
5fill in blank
hardFill all three blanks to safely execute user code with timeout and restricted imports.
Agentic AI
sandbox = Sandbox(timeout=[1], allowed_imports=[2], safe_mode=[3]) result = sandbox.run(user_code)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Allowing all imports which can be dangerous.
Disabling safe_mode which reduces protection.
Setting no timeout leading to infinite loops.
✗ Incorrect
Setting a 5-second timeout, allowing only safe imports, and enabling safe_mode ensures secure execution.
