Files
pmg/README.md
T

252 lines
9.2 KiB
Markdown
Raw Normal View History

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>
</div>
<div align="center">
2026-01-27 19:39:36 +05:30
[![Docs](https://img.shields.io/badge/Docs-docs.safedep.io-2b9246?style=flat-square)](https://docs.safedep.io/pmg/quickstart)
[![Website](https://img.shields.io/badge/Website-safedep.io-3b82f6?style=flat-square)](https://safedep.io)
[![Discord](https://img.shields.io/discord/1090352019379851304?style=flat-square)](https://discord.gg/kAGEj25dCn)
2025-05-15 21:34:41 +05:30
[![Go Report Card](https://goreportcard.com/badge/github.com/safedep/pmg)](https://goreportcard.com/report/github.com/safedep/pmg)
![License](https://img.shields.io/github/license/safedep/pmg)
![Release](https://img.shields.io/github/v/release/safedep/pmg)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/safedep/pmg/badge)](https://api.securityscorecards.dev/projects/github.com/safedep/pmg)
[![CodeQL](https://github.com/safedep/pmg/actions/workflows/codeql.yml/badge.svg?branch=main)](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-04-07 00:56:21 +05:30
Developers and AI coding agents install packages every day. Each `npm install` or `pip install` executes thousands of lines of code that nobody reviews.
2026-04-07 00:56:21 +05:30
Malicious packages ship constantly in popular ecosystems:
2026-02-16 13:35:58 +05:30
2026-04-07 00:56:21 +05:30
- [**litellm 1.82.8**](https://safedep.io/malicious-litellm-1-82-8-analysis/) - a popular AI proxy library compromised to exfiltrate credentials
- [**telnyx 4.87.2**](https://safedep.io/malicious-telnyx-pypi-compromise/) - a legitimate telecom SDK hijacked on PyPI
- [**pino-sdk-v2**](https://safedep.io/malicious-npm-package-pino-sdk-v2-env-exfiltration/) - a typosquat package disguised as the popular pino logger
2025-04-23 02:21:44 +05:30
2026-04-07 00:56:21 +05:30
PMG intercepts every package install and checks it for malware **before** code executes. Install it once, and every `npm install`, `pip install`, and `poetry add` is protected automatically.
2026-03-11 11:04:05 +05:30
2026-04-07 00:56:21 +05:30
> Featured in [tl;dr sec](https://tldrsec.com/p/tldr-sec-316) and used by engineering teams worldwide.
2026-03-11 11:04:05 +05:30
2026-04-07 00:56:21 +05:30
## How PMG Works
2026-03-11 11:04:05 +05:30
2026-04-07 00:56:21 +05:30
- **Transparent Protection** - PMG wraps `npm`, `pip`, and other package managers to transparently apply protection. Developers and AI agents use their tools as usual with no workflow changes.
- **Malicious Package Protection** - Every intercepted package is analyzed against [SafeDep's real-time threat intelligence](https://safedep.io) before installation. Malicious packages are blocked before code executes on the system.
- **Sandboxed Installation** - Package installation runs inside OS-native sandboxes (macOS Seatbelt, Linux Bubblewrap), preventing install scripts from modifying the system even if a threat evades detection.
- **Audit Logging** - Every package installation event is logged, providing a verifiable trail of what was installed, when, and from where.
2026-03-11 11:04:05 +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 (Install Script)**
```bash
curl -fsSL https://raw.githubusercontent.com/safedep/pmg/main/install.sh | sh
```
2026-02-16 13:35:58 +05:30
**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
```
> **Note:** NPM-based installs can be fragile when Node.js is managed by version managers like [`mise`](https://mise.jdx.dev/) or [`asdf`](https://asdf-vm.com/), since the global `npm` bin path changes with the active Node version. Prefer the install script or Homebrew in those setups.
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
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
```
2026-03-31 19:54:25 +05:30
> **Tip:** Re-run `pmg setup install` after upgrading PMG to pick up new configuration options.
2026-02-16 13:35:58 +05:30
### 3. Use
2026-04-07 00:56:21 +05:30
Use your package managers as usual or let your AI coding agent use them. PMG works silently in the background.
2026-02-16 13:35:58 +05:30
```bash
npm install express
# or
pip install requests
2025-05-15 18:03:46 +05:30
```
Verify PMG is working by installing a test package. This is a harmless package flagged as malicious in the SafeDep database, specifically meant for testing:
2026-02-16 13:35:58 +05:30
```bash
npm --prefer-online --no-cache i safedep-test-pkg@0.1.3
```
<details>
<summary>Expected output</summary>
```
2026-03-11 11:04:05 +05:30
✗ Malicious package blocked
- safedep-test-pkg@0.1.3
Reference: https://app.safedep.io/community/malysis/01KF5JYDND9XR94WNEJ2G74KY2
2026-03-11 11:04:05 +05:30
✗ PMG: 1 packages analyzed, 1 blocked
```
2025-04-23 02:21:44 +05:30
</details>
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 |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
2026-03-11 11:04:05 +05:30
| **AI Agent Safety Net** | Protects against malicious packages installed by AI coding agents (Claude Code, Cursor, Copilot, Windsurf). |
2026-02-16 13:35:58 +05:30
| **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. |
2026-04-08 22:49:30 +05:30
| **Dependency Cooldown** | Blocks package versions published within a configurable time window, reducing exposure to supply chain attacks. |
2026-02-16 13:35:58 +05:30
| **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
## 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:
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
<details>
<summary><strong>Install Script (MacOS/Linux)</strong></summary>
Downloads the latest release from GitHub, verifies its SHA-256 checksum, and installs to `$HOME/.local/bin` (if on `PATH`) or `/usr/local/bin`.
```bash
curl -fsSL https://raw.githubusercontent.com/safedep/pmg/main/install.sh | sh
```
</details>
2026-02-16 13:35:58 +05:30
<details>
<summary><strong>Homebrew (MacOS/Linux)</strong></summary>
```bash
brew tap safedep/tap
brew install safedep/tap/pmg
```
2026-02-16 13:35:58 +05:30
</details>
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
```
> **Note:** NPM-based installs can be fragile when Node.js is managed by version managers like [`mise`](https://mise.jdx.dev/) or [`asdf`](https://asdf-vm.com/). The global `npm` bin path changes with the active Node version, so switching versions can leave `pmg` unavailable on `PATH` (or pointing to an old install). For these setups, prefer the install script or Homebrew.
2026-02-16 13:35:58 +05:30
</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
```
</details>
2026-01-08 00:24:18 +05:30
<details>
2026-02-16 13:35:58 +05:30
<summary><strong>Binary Download</strong></summary>
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-04-07 00:56:21 +05:30
## Uninstallation
Remove shell integration:
```bash
pmg setup remove
```
To also remove the PMG configuration file:
```bash
pmg setup remove --config-file
```
Then uninstall PMG itself:
```bash
# Homebrew
brew uninstall safedep/tap/pmg
# NPM
npm uninstall -g @safedep/pmg
```
2026-02-16 13:35:58 +05:30
## Trust and Security
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.
2026-03-11 11:04:05 +05:30
## User Guide
2026-01-08 00:24:18 +05:30
2026-02-16 13:35:58 +05:30
* [Trusted Packages Configuration](docs/trusted-packages.md)
2026-04-08 22:49:30 +05:30
* [Dependency Cooldown](docs/dependency-cooldown.md)
2026-02-16 13:35:58 +05:30
* [Proxy Mode Architecture](docs/proxy-mode.md)
* [Sandboxing Details](docs/sandbox.md)
2026-03-11 11:04:05 +05:30
## Support
If PMG saved you from a bad package, [star this repo](https://github.com/safedep/pmg) — it helps others find it.
2026-01-08 00:24:18 +05:30
## Contributing
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, either:
- Set `disable_telemetry: true` in your PMG config file, or
- Export `PMG_DISABLE_TELEMETRY=true`.