forked from OpenInterpreter/open-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request OpenInterpreter#709 from InterwebAlchemy/feature/s…
…afe-mode-docs chore: add better docs for safe_mode; load semgrep if available
- Loading branch information
Showing
6 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Safe Mode | ||
|
||
**⚠️ Safe mode is experimental and does not provide any guarantees of safety or security.** | ||
|
||
Open Interpreter is working on providing an experimental safety toolkit to help you feel more confident running the code generated by Open Interpreter. | ||
|
||
|
||
Install Open Interpreter with the safety toolkit dependencies as part of the bundle: | ||
|
||
```shell | ||
pip install open-interpreter[safe] | ||
``` | ||
|
||
Alternatively, you can install the safety toolkit dependencies separately in your virtual environment: | ||
|
||
```shell | ||
pip install semgrep | ||
``` | ||
|
||
## Features | ||
|
||
- **No Auto Run**: Safe mode disables the ability to automatically execute code | ||
- **Code Scanning**: Scan generated code for vulnerabilities with [`semgrep`](https://semgrep.dev/) | ||
|
||
## Enabling Safe Mode | ||
|
||
You can enable safe mode by passing the `--safe` flag when invoking `interpreter` or by configuring `safe_mode` in your [config file](https://github.com/KillianLucas/open-interpreter#configuration). | ||
|
||
The safe mode setting has three options: | ||
|
||
- `off`: disables the safety toolkit (_default_) | ||
- `ask`: prompts you to confirm that you want to scan code | ||
- `auto`: automatically scans code | ||
|
||
### Example Config: | ||
|
||
```yaml | ||
model: gpt-4 | ||
temperature: 0 | ||
debug_mode: false | ||
safe_mode: ask | ||
``` | ||
## Roadmap | ||
Some upcoming features that enable even more safety: | ||
- [Execute code in containers](https://github.com/KillianLucas/open-interpreter/pull/459) | ||
## Tips & Tricks | ||
You can adjust the `system_message` in your [config file](https://github.com/KillianLucas/open-interpreter#configuration) to include instructions for the model to scan packages with [`guarddog`]() before installing them. | ||
|
||
```yaml | ||
model: gpt-4 | ||
debug_mode: false | ||
safe_mode: ask | ||
system_message: | | ||
# normal system message here | ||
BEFORE INSTALLING ANY PACKAGES WITH pip OR npm YOU MUST SCAN THEM WITH `guarddog` FIRST. Run `guarddog pypi scan $package` for pip packages and `guarddog npm scan $package` for npm packages. `guarddog` only accepts one package name at a time. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import importlib.util | ||
import sys | ||
|
||
#borrowed from: https://stackoverflow.com/a/1051266/656011 | ||
def check_for_package(package): | ||
if package in sys.modules: | ||
return True | ||
elif (spec := importlib.util.find_spec(package)) is not None: | ||
try: | ||
module = importlib.util.module_from_spec(spec) | ||
|
||
sys.modules[package] = module | ||
spec.loader.exec_module(module) | ||
|
||
return True | ||
except ImportError: | ||
return False | ||
else: | ||
return False |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters