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 (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
|
## 📑 Table of Contents
|
||||||
- [Features](#features)
|
- [PMG (Package Manager Guard)](#pmg-package-manager-guard)
|
||||||
- [Supported Ecosystems](#supported-ecosystems)
|
- [TL;DR](#tldr)
|
||||||
- [Installation](#installation)
|
- [📑 Table of Contents](#-table-of-contents)
|
||||||
- [Prerequisites](#prerequisites)
|
- [Features](#features)
|
||||||
- [Configuration](#configuration)
|
- [Supported Ecosystems](#supported-ecosystems)
|
||||||
- [Usage](#usage)
|
- [Installation](#installation)
|
||||||
- [NPM Packages](#npm-packages)
|
- [Binaries](#binaries)
|
||||||
- [PNPM Packages](#pnpm-packages)
|
- [Build from Source](#build-from-source)
|
||||||
- [Common Flags](#common-flags)
|
- [Usage](#usage)
|
||||||
- [Contributing](#contributing)
|
- [PMG in Action](#pmg-in-action)
|
||||||
|
- [Malicious Package Detection](#malicious-package-detection)
|
||||||
|
- [Bulk Package Analysis](#bulk-package-analysis)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
|
||||||
## Features
|
## 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
|
- ⚡ Fast and efficient package verification
|
||||||
- 🔄 Seamless integration with existing package managers
|
- 🔄 Seamless integration with existing package managers
|
||||||
|
|
||||||
## Supported Ecosystems
|
## Supported Ecosystems
|
||||||
Currently, PMG supports the following package ecosystems:
|
|
||||||
|
|
||||||
| Ecosystem | Status | Command |
|
PMG supports the following package ecosystems:
|
||||||
|-----------|--------|---------|
|
|
||||||
| NPM | ✅ Active | `pmg npm install <package>` |
|
| Ecosystem | Status | Command |
|
||||||
| PNPM | ✅ Active | `pmg pnpm add <package>` |
|
| --------- | --------- | --------------------------- |
|
||||||
| PyPI | 🚧 Planned | Coming soon |
|
| NPM | ✅ Active | `pmg npm install <package>` |
|
||||||
| Go | 🚧 Planned | Coming soon |
|
| 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
|
## 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
|
> 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
|
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
|
## 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
|
#### Malicious Package Detection
|
||||||

|

|
||||||
@@ -66,30 +92,6 @@ Get your API credentials by visiting [SafeDep Quickstart Guide](https://docs.saf
|
|||||||
#### Bulk Package Analysis
|
#### 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
|
## Contributing
|
||||||
|
|
||||||
Refer to [CONTRIBUTING.md](CONTRIBUTING.md)
|
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)
|
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",
|
name: "no install target",
|
||||||
command: "npm install",
|
command: "npm install",
|
||||||
|
|||||||
Reference in New Issue
Block a user