Sandbox mode in Bazel is a security feature that isolates build actions from the host system. This helps to prevent malicious code from being able to access the host system or other build actions.
In sandbox mode, each build action is executed in a separate directory, called an execroot. The execroot contains all of the inputs and outputs of the build action, as well as any tools that are needed to execute the build action. The build action is not allowed to access any files or directories outside of the execroot.
Sandbox mode is enabled by default on systems that support it. To disable sandbox
mode, you can use the
--nosandbox flag when running Bazel.
Here are some of the benefits of using sandbox mode in Bazel:
- It helps to prevent malicious code from being able to access the host system or other build actions.
- It can help to improve the security of builds that are executed on untrusted systems.
- It can help to prevent build failures caused by malicious code.
Here are some of the drawbacks of using sandbox mode in Bazel:
- It can slow down builds, as each build action must be executed in a separate directory.
- It can make it more difficult to debug build failures, as the build action is isolated from the host system.
Overall, sandbox mode is a valuable security feature that can help to protect your system from malicious code. However, it is important to weigh the benefits and drawbacks of using sandbox mode before deciding whether or not to enable it.