Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gbaranski/safedotenv
Scan your code for .env leaks, quickly ⚡
https://github.com/gbaranski/safedotenv
rust
Last synced: about 2 months ago
JSON representation
Scan your code for .env leaks, quickly ⚡
- Host: GitHub
- URL: https://github.com/gbaranski/safedotenv
- Owner: gbaranski
- License: mit
- Created: 2021-02-23T10:30:31.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-14T22:52:57.000Z (almost 4 years ago)
- Last Synced: 2024-10-12T17:26:06.803Z (3 months ago)
- Topics: rust
- Language: Rust
- Homepage:
- Size: 117 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Safedotenv
Safedotenv is tool to check if your code leaks any .env variables that are left in code for testing purposes.
Scanning [llvm](https://github.com/llvm/llvm-project) source code(8 million lines of code) takes around 1 second on Intel i7-10510U and NVMe. However there is still room for improvement.
![scanning-llvm](docs/scanning-llvm.png)
- [Installation](#installation)
* [Arch Linux](#arch-linux)
* [Manual](#manual)
- [User Guide](#user-guide)
* [Using with git hooks](#using-with-git-hooks)## Installation
### Arch Linux
Install `safedotenv-git` from [AUR](https://aur.archlinux.org/packages/safedotenv-git/)
```
yay -S safedotenv-git
```### Manual
```zsh
git clone [email protected]:gbaranski/safedotenv.git
cd safedotenv
cargo build --release
./target/release/safedotenv
```## User Guide
Basic usage, scanning current directory recursively, assuming .env is present at current directory
```
safedotenv
```Scanning current directory but with .env file somewhere else
```
safedotenv --env-file somedir/.env
```Scanning specific directory but with .env file somewhere else
```
safedotenv --env-file somedir/.env ~/some/safe/dir
```Scanning specific directory but with .env file somewhere else, ignoring `REFRESH_TOKEN` and `ACCESS_TOKEN` variables from .env
```
safedotenv --env-file somedir/.env --ignore-env REFRESH_TOKEN ACCESS_TOKEN ~/some/safe/dir
```#### Using with git hooks
1. Open `.git/hooks/pre-commit` file(create if does not exits)
2. Add this code
```bash
#!/bin/bashout=$(safedotenv --quiet $(git rev-parse --show-toplevel) 2>&1)
if [[ $out ]]; then
echo -e "${out}"
echo
echo "Safedotenv prevented you from possibly commiting unsafe code, to ignore that, use"
echo " git commit --no-verify"
exit 1
fi
```
3. Add permissions to execute file
```bash
chmod +x .git/hooks/pre-commit
```