How safedep/pmg works
PMG is a command-line package-install firewall: developers and coding agents keep using familiar package-manager commands, while PMG intercepts installs, checks threats and cooldown policy, optionally sandboxes execution, and records an audit trail. The per-command flow is the runtime orchestrator; a persistent proxy daemon supports intercepted traffic across ecosystems. The graph preserves documented protections and operational capabilities. Some subsystems are represented from README and index references because their implementation excerpts were not provided.
Main entry points: proxy_flow.go Install flow · main.go PMG CLI · execute.go Command execution · server.go Persistent proxy
Components 16
Command interception
- PMG CLI
main.go - Shell interception
internal/alias/alias.go - Command shim
internal/shim/shim.go
Install protection
- Install flow
internal/flows/proxy_flow.go - Package parsing
packagemanager/packagemanager.go - Malware analysis
analyzer/malysis_query.go - Sandbox policy
sandbox/executor/apply.go - Command execution
internal/runner/execute.go
Registry proxy
- Persistent proxy
internal/proxyserver/server.go - Registry interceptors
proxy/interceptors/pypi_url_parser.go - Proxy certificates
proxy/certmanager/certmanager.go
Audit and operations
- Local event log
internal/eventlog/eventlog.go - Audit system
internal/audit/audit.go - Cloud sync
internal/audit/cloud_client.go - Setup diagnostics
cmd/setup/doctor.go
Other components
- Developer or agent
Connections 18
- Developer or agent → Shell interception: runs install
README.md - Shell interception → Command shim: intercepts command
internal/shim/shim.go - Developer or agent → PMG CLI: manages PMG
README.md - PMG CLI → Install flow: routes command
main.go - Install flow → Package parsing: parses command
internal/flows/proxy_flow.go - Install flow → Malware analysis: checks packages
internal/flows/proxy_flow.go - Install flow → Persistent proxy: starts proxy
internal/flows/proxy_flow.go - Install flow → Command execution: executes command
internal/flows/proxy_flow.go - Command execution → Sandbox policy: applies policy
internal/runner/execute.go - Persistent proxy → Registry interceptors: builds interceptors
internal/proxyserver/server.go - Persistent proxy → Proxy certificates: configures certificates
- Install flow → Local event log: records events
- PMG CLI → Audit system: initializes audit
main.go - Audit system → Cloud sync: syncs events
internal/audit/cloud_client.go - PMG CLI → Setup diagnostics: runs diagnostics
main.go - Registry interceptors → Malware analysis: checks threat data
- Registry interceptors → Package parsing: identifies packages
- Command execution → Developer or agent: returns result