mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
Update README
This commit is contained in:
@@ -1,39 +1,66 @@
|
||||
|
||||
# PMG (Package Manager Guard)
|
||||
PMG is a wrapper for package managers to protect developers from installing malicious packages.
|
||||
|
||||
PMG is a security-focused wrapper for package managers that helps detect and prevent the installation of potentially malicious packages.
|
||||
## TL;DR
|
||||
|
||||
Set up `pmg` to protect you development environment:
|
||||
|
||||
```
|
||||
echo "alias npm='pmg npm'" >> ~/.zshrc
|
||||
echo "alias pnpm='pmg pnpm'" >> ~/.zshrc
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
Continue using your favorite package manager as usual:
|
||||
|
||||
```
|
||||
npm install <package-name>
|
||||
pnpm add <package-name>
|
||||
```
|
||||
|
||||
## 📑 Table of Contents
|
||||
- [Features](#features)
|
||||
- [Supported Ecosystems](#supported-ecosystems)
|
||||
- [Installation](#installation)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Configuration](#configuration)
|
||||
- [Usage](#usage)
|
||||
- [NPM Packages](#npm-packages)
|
||||
- [PNPM Packages](#pnpm-packages)
|
||||
- [Common Flags](#common-flags)
|
||||
- [Contributing](#contributing)
|
||||
- [PMG (Package Manager Guard)](#pmg-package-manager-guard)
|
||||
- [TL;DR](#tldr)
|
||||
- [📑 Table of Contents](#-table-of-contents)
|
||||
- [Features](#features)
|
||||
- [Supported Ecosystems](#supported-ecosystems)
|
||||
- [Installation](#installation)
|
||||
- [Binaries](#binaries)
|
||||
- [Build from Source](#build-from-source)
|
||||
- [Usage](#usage)
|
||||
- [PMG in Action](#pmg-in-action)
|
||||
- [Malicious Package Detection](#malicious-package-detection)
|
||||
- [Bulk Package Analysis](#bulk-package-analysis)
|
||||
- [Contributing](#contributing)
|
||||
|
||||
## Features
|
||||
- 🚫 Malware detection and prevention
|
||||
- 🌲 Deep dependency analysis
|
||||
|
||||
- 🚫 Malicious package identification using [SafeDep Cloud](https://docs.safedep.io/cloud/malware-analysis)
|
||||
- 🌲 Deep dependency analysis and transitive dependency resolution
|
||||
- ⚡ Fast and efficient package verification
|
||||
- 🔄 Seamless integration with existing package managers
|
||||
|
||||
## Supported Ecosystems
|
||||
Currently, PMG supports the following package ecosystems:
|
||||
|
||||
| Ecosystem | Status | Command |
|
||||
|-----------|--------|---------|
|
||||
| NPM | ✅ Active | `pmg npm install <package>` |
|
||||
| PNPM | ✅ Active | `pmg pnpm add <package>` |
|
||||
| PyPI | 🚧 Planned | Coming soon |
|
||||
| Go | 🚧 Planned | Coming soon |
|
||||
PMG supports the following package ecosystems:
|
||||
|
||||
| Ecosystem | Status | Command |
|
||||
| --------- | --------- | --------------------------- |
|
||||
| NPM | ✅ Active | `pmg npm install <package>` |
|
||||
| PNPM | ✅ Active | `pmg pnpm add <package>` |
|
||||
| PyPI | 🚧 Planned | Coming soon |
|
||||
| Go | 🚧 Planned | Coming soon |
|
||||
|
||||
Want us to support your favorite package manager? [Open an issue](https://github.com/safedep/pmg/issues) and let us know!
|
||||
|
||||
## Installation
|
||||
- Build from source
|
||||
|
||||
### Binaries
|
||||
|
||||
Download the latest binary from the [releases page](https://github.com/safedep/pmg/releases).
|
||||
|
||||
### Build from Source
|
||||
|
||||
> Ensure $(go env GOPATH)/bin is in your $PATH
|
||||
|
||||
@@ -41,24 +68,23 @@ Currently, PMG supports the following package ecosystems:
|
||||
go install github.com/safedep/pmg@latest
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
- Go 1.24
|
||||
- SafeDep API credentials (SAFEDEP_API_KEY and SAFEDEP_TENANT_ID)
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
| Variable | Description | Required |
|
||||
|----------|-------------|----------|
|
||||
| `SAFEDEP_API_KEY` | Your SafeDep API key | Yes |
|
||||
| `SAFEDEP_TENANT_ID` | Your SafeDep tenant ID | Yes |
|
||||
|
||||
Get your API credentials by visiting [SafeDep Quickstart Guide](https://docs.safedep.io/cloud/quickstart).
|
||||
|
||||
## Usage
|
||||
|
||||
### Security in Action
|
||||
Install a package with `npm` or `pnpm`:
|
||||
|
||||
```bash
|
||||
pmg npm install <package-name>
|
||||
pmg pnpm add <package-name>
|
||||
```
|
||||
|
||||
Set shell alias for convenience:
|
||||
|
||||
```bash
|
||||
alias npm="pmg npm"
|
||||
alias pnpm="pmg pnpm"
|
||||
```
|
||||
|
||||
### PMG in Action
|
||||
|
||||
#### Malicious Package Detection
|
||||

|
||||
@@ -66,30 +92,6 @@ Get your API credentials by visiting [SafeDep Quickstart Guide](https://docs.saf
|
||||
#### Bulk Package Analysis
|
||||

|
||||
|
||||
### NPM Packages
|
||||
Install a package:
|
||||
```bash
|
||||
pmg npm install <package-name>
|
||||
```
|
||||
|
||||
Alternative commands:
|
||||
```bash
|
||||
pmg npm i <package-name> # Short form
|
||||
pmg npm add <package-name> # Alternative syntax
|
||||
```
|
||||
|
||||
### PNPM Packages
|
||||
Install a package:
|
||||
```bash
|
||||
pmg pnpm add <package-name>
|
||||
```
|
||||
|
||||
### Common Flags
|
||||
All standard package manager flags are supported:
|
||||
```bash
|
||||
pmg npm install --save-dev <package-name> # Install as dev dependency
|
||||
pmg pnpm add -D <package-name> # Install as dev dependency
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Refer to [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
@@ -33,6 +33,24 @@ func TestNpmParseCommand(t *testing.T) {
|
||||
assert.Equal(t, "1.2.3", parsedCommand.InstallTargets[0].PackageVersion.Version)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "install a development package",
|
||||
command: "npm install --save-dev @types/node",
|
||||
assert: func(t *testing.T, parsedCommand *ParsedCommand, err error) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(parsedCommand.InstallTargets))
|
||||
assert.Equal(t, "@types/node", parsedCommand.InstallTargets[0].PackageVersion.Package.Name)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "install a development package with short flag",
|
||||
command: "npm i -D @types/node",
|
||||
assert: func(t *testing.T, parsedCommand *ParsedCommand, err error) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(parsedCommand.InstallTargets))
|
||||
assert.Equal(t, "@types/node", parsedCommand.InstallTargets[0].PackageVersion.Package.Name)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no install target",
|
||||
command: "npm install",
|
||||
|
||||
Reference in New Issue
Block a user