2026-01-21 20:29:15 +05:30
<div align="center">
2026-01-27 19:39:36 +05:30
<img src="./docs/assets/pmg-banner.png" alt="PMG GitHub Banner">
2026-01-21 20:29:15 +05:30
</div>
<br/>
<div align="center">
<h1>Package Manager Guard (PMG)</h1>
2026-02-16 13:35:58 +05:30
<h3>Prevent supply chain attacks before they happen.</h3>
2026-01-21 20:29:15 +05:30
</div>
<div align="center">
2026-01-27 19:39:36 +05:30
[](https://docs.safedep.io/pmg/quickstart)
[](https://safedep.io)
[](https://discord.gg/kAGEj25dCn)
2025-05-15 21:34:41 +05:30
[](https://goreportcard.com/report/github.com/safedep/pmg)


[](https://api.securityscorecards.dev/projects/github.com/safedep/pmg)
[](https://github.com/safedep/pmg/actions/workflows/codeql.yml)
2026-01-21 20:29:15 +05:30
</div>
2026-01-27 19:39:36 +05:30
<br>
2026-01-21 20:29:15 +05:30
2026-02-16 13:35:58 +05:30
<div align="center">
<img src="./docs/demo/pmg-intro.gif" width="800" alt="pmg in action">
</div>
2026-01-21 20:29:15 +05:30
2026-02-16 13:35:58 +05:30
## Why PMG?
2025-04-23 02:21:44 +05:30
2026-02-16 13:35:58 +05:30
Modern software development relies heavily on open-source packages. However, standard package managers (`npm` , `pip` , etc.) prioritize convenience over security, executing arbitrary code (like `postinstall` scripts) on your machine without validation. This vector is frequently exploited by attackers to steal credentials or inject backdoors.
2026-01-15 20:12:12 +05:30
2026-02-16 13:35:58 +05:30
**PMG acts as a security middleware layer.** It wraps your package manager to:
1. **Analyze** packages for malware before they are installed.
2. **Sandbox** the installation process to prevent system modification.
3. **Audit** every package installation event.
2025-04-23 02:21:44 +05:30
2026-01-21 20:29:15 +05:30
## Quick Start
2025-05-15 18:03:46 +05:30
2026-02-16 13:35:58 +05:30
Get protected in seconds.
2025-05-15 18:03:46 +05:30
2026-02-16 13:35:58 +05:30
### 1. Install
**MacOS / Linux (Homebrew)**
```bash
2025-05-15 18:03:46 +05:30
brew install safedep/tap/pmg
2026-02-16 13:35:58 +05:30
```
2026-01-14 15:02:08 +05:30
2026-02-16 13:35:58 +05:30
**NPM**
```bash
2026-01-14 15:02:08 +05:30
npm install -g @safedep/pmg
2025-05-15 18:03:46 +05:30
```
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
> See [Installation](#installation) for additional methods.
2026-01-08 00:24:18 +05:30
2026-02-16 13:35:58 +05:30
### 2. Setup
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
Configure your shell to use PMG automatically.
```bash
2025-06-24 18:17:06 +05:30
pmg setup install
2026-02-16 13:35:58 +05:30
# Restart your terminal to apply changes
2025-05-15 16:50:59 +05:30
```
2026-02-16 13:35:58 +05:30
### 3. Use
2026-01-09 19:26:48 +05:30
2026-02-16 13:35:58 +05:30
Continue using your favorite package manager tools as usual. PMG works silently in the background.
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
```bash
npm install express
# or
pip install requests
2025-05-15 18:03:46 +05:30
```
2026-02-16 13:35:58 +05:30
If a malicious package is detected, PMG blocks it immediately:
```text
[PMG] Blocked malicious package: malicious-lib@1.0.0
[PMG] Reason: Known malware signature detected
2025-05-15 16:50:59 +05:30
```
2025-04-23 02:21:44 +05:30
2026-01-08 00:24:18 +05:30
## Features
2025-11-05 13:49:19 +05:30
2026-02-16 13:35:58 +05:30
| Feature | Description |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| **Malicious Package Protection** | Real-time protection against malicious packages using [SafeDep ](https://docs.safedep.io/cloud/malware-analysis ). |
| **Sandboxing** | Enforces least privilege using OS native sandboxing to contain installation scripts. |
| **Dependency Analysis** | Deep scans of direct and transitive dependencies before they hit your disk. |
| **Event Logging** | Keeps a verifiable audit trail of all installed packages. |
| **Zero Config** | Works out of the box with sensible security defaults. |
| **Cross-Shell** | Seamlessly integrates with Zsh, Bash, Fish, and more. |
2025-04-23 02:21:44 +05:30
2025-05-15 16:50:59 +05:30
## Supported Package Managers
2025-04-23 02:21:44 +05:30
2026-02-16 13:35:58 +05:30
PMG supports the tools you already use:
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
| Ecosystem | Tools | Status | Command Example |
| ----------- | -------- | ------ | ------------------- |
| **Node.js** | `npm` | Yes | `npm install <pkg>` |
| | `pnpm` | Yes | `pnpm add <pkg>` |
| | `yarn` | Yes | `yarn add <pkg>` |
| | `bun` | Yes | `bun add <pkg>` |
| | `npx` | Yes | `npx <pkg>` |
| | `pnpx` | Yes | `pnpx <pkg>` |
| **Python** | `pip` | Yes | `pip install <pkg>` |
| | `poetry` | Yes | `poetry add <pkg>` |
| | `uv` | Yes | `uv add <pkg>` |
2025-04-23 02:21:44 +05:30
## Installation
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
<details>
<summary><strong>Homebrew (MacOS/Linux)</strong></summary>
2025-05-15 22:24:02 +05:30
```bash
brew tap safedep/tap
brew install safedep/tap/pmg
```
2026-02-16 13:35:58 +05:30
</details>
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
<details>
<summary><strong>NPM (Cross-Platform)</strong></summary>
2025-04-23 02:21:44 +05:30
```bash
2026-02-16 13:35:58 +05:30
npm install -g @safedep/pmg
```
</details>
<details>
<summary><strong>Go (Build from Source)</strong></summary>
```bash
# Ensure $(go env GOPATH)/bin is in your $PATH
2025-04-28 20:02:20 +05:30
go install github.com/safedep/pmg@latest
2025-04-23 02:21:44 +05:30
```
2026-02-10 22:22:40 +05:30
</details>
2026-01-08 00:24:18 +05:30
<details>
2026-02-16 13:35:58 +05:30
<summary><strong>Binary Download</strong></summary>
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
Download the latest binary for your platform from the [Releases Page ](https://github.com/safedep/pmg/releases ).
2026-01-08 00:24:18 +05:30
</details>
2026-02-16 13:35:58 +05:30
## Trust and Security
2025-05-16 19:38:06 +05:30
2026-02-16 13:35:58 +05:30
Security is our first class requirement. PMG builds are reproducible and signed.
* **Attestations**: GitHub and npm attestations are used to guarantee artifact integrity.
* **Verification**: Users can cryptographically prove the binary matches the source code.
* See [Trusting PMG ](docs/trust.md ) for verification steps.
## Usage Guide
PMG runs transparently, but you can control it when needed.
### Paranoid Mode
Treat all unverified or suspicious packages as malicious.
2025-05-16 19:38:06 +05:30
```bash
2026-02-16 13:35:58 +05:30
pmg --paranoid npm install <package>
2025-05-16 19:38:06 +05:30
```
2026-02-16 13:35:58 +05:30
### Dry Run
2026-01-08 00:24:18 +05:30
2026-02-16 13:35:58 +05:30
Simulate installation to check for malware without writing to disk.
2025-05-15 16:50:59 +05:30
```bash
2026-02-16 13:35:58 +05:30
pmg --dry-run npm install <package>
2025-05-15 16:50:59 +05:30
```
2026-02-16 13:35:58 +05:30
### Debugging
2026-01-08 00:24:18 +05:30
2026-02-16 13:35:58 +05:30
Enable verbose logs for troubleshooting.
2025-05-15 16:50:59 +05:30
```bash
2026-02-16 13:35:58 +05:30
pmg --debug npm install <package>
2025-05-15 16:50:59 +05:30
```
2026-02-16 13:35:58 +05:30
### Emergency Bypass
> ⚠️ **Warning**: Bypassing security checks exposes users to risk.
2025-07-02 19:09:27 +05:30
```bash
export PMG_INSECURE_INSTALLATION = true
2026-02-16 13:35:58 +05:30
npm install <package>
2025-07-02 19:09:27 +05:30
```
2026-02-16 13:35:58 +05:30
## Advanced Documentation
2026-01-08 00:24:18 +05:30
2026-02-16 13:35:58 +05:30
* [Trusted Packages Configuration ](docs/trusted-packages.md )
* [Proxy Mode Architecture ](docs/proxy-mode.md )
* [Sandboxing Details ](docs/sandbox.md )
2026-01-09 19:26:48 +05:30
2026-01-08 00:24:18 +05:30
## Contributing
2025-05-15 16:50:59 +05:30
2026-02-16 13:35:58 +05:30
Contributions are welcome! Please see [CONTRIBUTING.md ](CONTRIBUTING.md ) for guidelines on how to build and test PMG locally.
2025-06-30 09:47:14 +05:30
## Telemetry
2026-02-16 13:35:58 +05:30
PMG collects anonymous usage data to improve project stability and reliability.
To disable: `export PMG_DISABLE_TELEMETRY=true` .