Skip to content

Commit

Permalink
Merge pull request #16 from narenaryan/docs/add-programmatic-access
Browse files Browse the repository at this point in the history
docs: create programmatic-access guide
  • Loading branch information
narenaryan authored Nov 17, 2024
2 parents 6277d32 + 094281d commit 4596493
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Whispr

![Logo](./logo.png)
![Logo](https://github.com/narenaryan/whispr/raw/main/logo.png)

Whispr (Pronounced as whisper) is a CLI tool to safely inject secrets from your favorite secret vault (Ex: AWS Secrets Manager, Azure Key Vault etc.) into your app's environment. This is very useful for enabling secure local software development.

Expand All @@ -20,7 +20,7 @@ Key Features of Whispr:

Supported Vault Technologies:

![Supported-vaults](./whispr-supported.png)
![Supported-vaults](https://github.com/narenaryan/whispr/raw/main/whispr-supported.png)


# Why use Whispr ?
Expand Down Expand Up @@ -97,12 +97,13 @@ whispr run '/bin/sh ./script.sh' # Inject secrets and run a custom bash script.
whispr run 'semgrep scan --pro' # Inject Semgrep App Token and scan current directory with Semgrep SAST tool.
```

## Whispr Architecture
## Programmatic Access

![Supported-vaults](./whispr-arch.png)
Whispr can also be used programmatically from Python code. See this guide for more information.

https://github.com/narenaryan/whispr/blob/docs/main/usage-guides/programmatic-access.md

# TODO

* Add unit tests
* Support HashiCorp Vault
* Support 1Password Vault
27 changes: 27 additions & 0 deletions usage-guides/programmatic-access.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Programmatic access of Whispr

In addition to installing Whispr as a tool, one can make use of core utility functions like this:

```bash
pip install whispr
```

Then from Python code you can import important functions like this:

```py
from whispr.utils.vault import fetch_secrets
from whispr.utils.process import execute_command

config = {
"vault": "aws",
"secret_name": "<your_secret_name>"
}

secrets = fetch_secrets(config)

# Now, inject secrets into your command's environment by calling this function
command = "ls -l"
execute_command(command.split(), no_env=False, secrets=secrets)
```

That's it. This is a programmatic equivalent to the tool usage.

0 comments on commit 4596493

Please sign in to comment.