# AI Tools Discovery Source: https://docs.safedep.io/ai-security/ai-tools-discovery Discover AI coding agents, MCP servers, CLI tools, IDE extensions, and agent skills across developer machines and project repositories `vet ai discover` is an alias for `vet endpoint scan --kind ai-tool --kind agent-skill`. It scans the local system and project directory to inventory AI tool usage signals: coding agents, MCP servers, CLI tools, IDE extensions, project configuration files, and agent skills. When SafeDep credentials are configured, discovered items sync to SafeDep Cloud's Endpoint Hub automatically. See [Inventory](/governance/cloud/endpoint-hub/inventory). ## Prerequisites * `vet` [installed](/governance/vet/quickstart) ## Usage Discover all AI tool usage signals on the current system and project: ```bash theme={null} vet ai discover ``` ### Scope Filtering Limit discovery to system-level or project-level signals: ```bash theme={null} # Only system-level signals (global configs, CLI binaries, IDE extensions) vet ai discover --scope system # Only project-level signals for a specific repository vet ai discover --scope project -D /path/to/repo ``` ### JSON Output Write a structured JSON inventory for downstream processing: ```bash theme={null} vet ai discover --report-json inventory.json # JSON only, suppress table output vet ai discover --report-json inventory.json --silent ``` ## What Gets Discovered `vet ai discover` reports **usage signals**, not unique tools. The same tool may appear multiple times because it can be configured at different scopes. Each row represents a distinct configuration entry. For example, Claude Code might produce: | Type | Name | Scope | Why | | - | - | - | - | | `coding_agent` | Claude Code | system | `~/.claude/settings.json` exists | | `project_config` | Claude Code | project | Project has a `CLAUDE.md` | | `mcp_server` | my-server | system | Configured in `~/.claude/settings.json` | | `mcp_server` | my-server | project | Also configured in `.mcp.json` | ### Signal Types The `--kind` flag on `vet endpoint scan` controls which signal types are collected. `vet ai discover` always collects all of them. | Type | Kind | Description | | - | - | - | | **coding\_agent** | `ai-tool` | AI coding assistant installed on the system, detected via system-level config directories | | **mcp\_server** | `ai-tool` | Model Context Protocol server configured for an application | | **cli\_tool** | `ai-tool` | Standalone AI CLI binary found on `$PATH`, verified by executing with a version flag | | **ai\_extension** | `ai-tool` | AI-related IDE extension detected from installed extension manifests | | **project\_config** | `ai-tool` | AI tool configuration or instruction file found in a project repository | | **agent\_skill** | `agent-skill` | Agent skill directory discovered in a supported agent's skill path (e.g. `.claude/skills/`, `.agents/skills/`) | ### Scope * **system** refers to user-global config (e.g. `~/.claude/settings.json`, `~/.cursor/mcp.json`) * **project** refers to repo-scoped config (e.g. `.mcp.json`, `.cursorrules`, `CLAUDE.md`) ## What Gets Scanned **App configuration** is read from well-known system and project-level config paths for each supported application. System-level configs indicate the tool is installed; project-level configs indicate the project is set up for a tool. **CLI binaries** are discovered by searching `$PATH` for known binary names. Each candidate is executed with a version flag and the output verified against known patterns. **IDE extensions** are discovered by reading extension manifests from supported IDE distributions and matching against a curated list of known AI extension identifiers. **Agent skill directories** are discovered by scanning known per-agent skill paths at system and project scope. ## Security Discovery makes no network calls. All scanning reads the local filesystem and `$PATH`. Environment variable and header values are never captured; only key names are recorded. CLI arguments matching secret patterns (`--token=`, `--api-key=`, `--password=`, etc.) are redacted. Sync to SafeDep Cloud is a separate step that runs only when credentials are configured. > [card] [Inventory](/governance/cloud/endpoint-hub/inventory) > > Sync discovered AI tools and skills to SafeDep Cloud's Endpoint Hub > [card] [Shadow AI in Code](/governance/shadow-ai-detection) > > Detect AI SDK usage in source code and generate AI-enriched SBOMs > [card] [xBOM Concepts](/governance/xbom/overview) > > Learn about extended Bill of Materials and signature-based detection # Gryph Source: https://docs.safedep.io/ai-security/gryph-overview Gryph records what your AI coding agents do, every file read, write, and command, to a local audit log you can query and replay. AI coding agents like Claude Code, Cursor, and Gemini CLI can read any file, write anywhere, and run arbitrary commands on your machine. They fire off dozens of tool calls per session, and when something goes wrong there is usually no record of what happened. **Gryph** gives you that record. Gryph hooks into your AI coding agents, logs every action to a local audit database, and lets you query, review, and replay agent activity. It is an observability tool. It tells you what an agent did, after the fact. It does not block or sandbox agent actions. > [!NOTE] > > Gryph runs fully locally. All data stays on your machine. There is no cloud component, no telemetry, and no SafeDep account or API key. ## What Gryph does * **Records agent activity.** Every file read, file write, and command execution becomes a structured event. * **Stores it locally.** Events go to a local SQLite database on your machine. Nothing is transmitted. * **Lets you investigate.** Query, filter, and replay sessions to understand and debug what an agent did. * **Flags sensitive access.** Gryph detects when agents touch sensitive files like `.env`, keys, and secrets, and it can redact or hash captured content. ## Supported agents Gryph installs lightweight hooks into the agents you already use: * Claude Code * Cursor * Gemini CLI * Windsurf * OpenCode * Codex * Pi Agent The list grows over time. See the [Gryph repository](https://github.com/safedep/gryph) for the current set and the events captured for each agent. ## Get started **1. Install Gryph** ```bash theme={null} brew install safedep/tap/gryph ``` Other methods (install script, npm, Go) are in the [Gryph README](https://github.com/safedep/gryph#installation). **2. Install hooks into your agents** ```bash theme={null} gryph install ``` Gryph detects the AI coding agents on your machine and wires up its hooks. **3. Use your agent normally** Run your AI coding agent as usual. Gryph records activity in the background. **4. Review what happened** ```bash theme={null} gryph logs ``` View recent agent activity. Use `gryph query` to filter the audit log and `gryph sessions` to list recorded sessions. > [!NOTE] > > Gryph is young and changes often. For the latest commands, configuration, and supported agents, see the [Gryph repository](https://github.com/safedep/gryph) and its [releases](https://github.com/safedep/gryph/releases). ## How it differs from the SafeDep MCP server Gryph and the [SafeDep MCP server](/ai-security/mcp-server) both work with AI coding tools, but they solve opposite problems: * **Gryph** observes the agent. It records what the agent reads, writes, and runs on your machine. * **The MCP server** gives capabilities to the agent. It lets the agent ask SafeDep "is this package safe?" before suggesting an install. Use them together. MCP helps the agent make safer suggestions, and Gryph keeps an audit trail of its actions. > [card] [Gryph on GitHub](https://github.com/safedep/gryph) > > Full documentation, configuration, and source. > [card] [SafeDep MCP server](/ai-security/mcp-server) > > Give your AI coding tools access to SafeDep package intelligence. # SafeDep MCP Server Source: https://docs.safedep.io/ai-security/mcp-server Protect your AI coding agents against malicious packages using SafeDep MCP The SafeDep CLI is the fastest way to get started. One command signs you in, sets up your API key, and configures SafeDep in every AI coding agent it finds on your machine. To configure things manually, see [Manual Setup](#manual-setup). SafeDep monitors npm, PyPI, and other package registries in real time. It stays invisible when packages are safe and surfaces only when it blocks something dangerous. > [!NOTE] > > SafeDep MCP has a free tier. See [pricing](https://safedep.io/pricing) for details. > [!NOTE] > > With SafeDep Cloud, the packages your agents check through the MCP server appear per endpoint under [MCP Advisor](/governance/cloud/endpoint-hub/mcp-advisor) in Endpoint Hub, with the verdict each one got. ## Quick Start **1. Run the setup command** Run the following command in your terminal. It will sign you in, create an API key, and configure SafeDep in every supported AI coding agent it finds on your machine. > [tab] npx > > ```bash theme={null} > npx @safedep/cli setup mcp install > ``` > [tab] pnpx > > ```bash theme={null} > pnpx @safedep/cli setup mcp install > ``` > [tab] bunx > > ```bash theme={null} > bunx @safedep/cli setup mcp install > ``` ![SafeDep MCP setup via CLI](https://mintcdn.com/safedep/hTtYBaEpqG3xfAaW/images/safedep-mcp-setup.png?fit=max\&auto=format\&n=hTtYBaEpqG3xfAaW\&q=85\&s=ab24c2089959afd950710afbb4043f83) **2. Test the Integration** Verify the setup by asking your coding agent to install a [test package](#testing). The agent should block it as malicious. ![Claude using SafeDep MCP](https://mintcdn.com/safedep/hTtYBaEpqG3xfAaW/images/claude-using-safedep-mcp.png?fit=max\&auto=format\&n=hTtYBaEpqG3xfAaW\&q=85\&s=cf0957c85717a92157eaf7c3ee3c07a2) ## Endpoints | Endpoint | Description | | - | - | | `https://mcp.safedep.io/model-context-protocol/threats/v1/mcp` | SafeDep MCP endpoint (HTTP) | | `https://mcp.safedep.io/model-context-protocol/threats/v1/sse` | Legacy SSE endpoint | ### Authentication The MCP server requires API key authentication. The following HTTP headers are required: | Header | Description | | - | - | | `Authorization` | `` | | `X-Tenant-ID` | `your-tenant-domain (e.g. default-team.your-domain.safedep.io)` | > [!TIP] > > Your tenant domain is shown in [SafeDep Cloud settings](https://app.safedep.io/settings/api-keys) after you sign in. ## Manual Setup To configure an agent manually, or if the CLI did not auto-detect yours, follow the instructions below. Each configuration requires a SafeDep API key and your tenant domain. Create an API key in [SafeDep Cloud settings](https://app.safedep.io/settings/api-keys). > [accordion] Claude Code > > Use `claude` CLI to add the MCP server to your user settings. This configuration will be available across all Claude Code projects. > > ```bash theme={null} > claude mcp add -s user --transport http safedep \ > https://mcp.safedep.io/model-context-protocol/threats/v1/mcp \ > --header "Authorization: " \ > --header "X-Tenant-ID: " > ``` > [accordion] Cursor > > Add the SafeDep MCP server to your Cursor configuration. Create or edit `~/.cursor/mcp.json` in your home directory: > > ```json theme={null} > { > "mcpServers": { > "safedep": { > "url": "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp", > "headers": { > "Authorization": "", > "X-Tenant-ID": "" > } > } > } > } > ``` > > Restart Cursor after saving the configuration. You can verify the server connection in **Cursor Settings > MCP Servers**. > > See the [Cursor MCP documentation](https://cursor.com/docs/context/mcp) for more details. > [accordion] VS Code > > Add the SafeDep MCP server to your VS Code configuration. Create or edit the user-level `mcp.json` file for your platform: > > | Platform | Path | > | - | - | > | Linux | `~/.config/Code/User/mcp.json` | > | macOS | `~/Library/Application Support/Code/User/mcp.json` | > | Windows | `%APPDATA%\Code\User\mcp.json` | > > ```json theme={null} > { > "servers": { > "safedep": { > "type": "http", > "url": "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp", > "headers": { > "Authorization": "", > "X-Tenant-ID": "" > } > } > } > } > ``` > > Reload VS Code after saving the configuration. > [accordion] Gemini CLI > > Add the SafeDep MCP server to your Gemini CLI configuration. Edit `~/.gemini/settings.json` in your home directory: > > ```json theme={null} > { > "mcpServers": { > "safedep": { > "httpUrl": "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp", > "headers": { > "Authorization": "", > "X-Tenant-ID": "" > } > } > } > } > ``` > > See the [Gemini CLI repository](https://github.com/google-gemini/gemini-cli) for MCP configuration details. > [accordion] OpenCode > > Add the SafeDep MCP server to your OpenCode configuration. Create or edit `~/.config/opencode/opencode.json` in your home directory: > > ```json theme={null} > { > "mcp": { > "safedep": { > "type": "remote", > "url": "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp", > "enabled": true, > "headers": { > "Authorization": "", > "X-Tenant-ID": "" > } > } > } > } > ``` > [accordion] Antigravity > > Add the SafeDep MCP server to your Antigravity configuration. Create or edit `~/.gemini/antigravity/mcp_config.json` in your home directory: > > ```json theme={null} > { > "mcpServers": { > "safedep": { > "serverUrl": "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp", > "headers": { > "Authorization": "", > "X-Tenant-ID": "" > } > } > } > } > ``` > [accordion] OpenAI Codex > > Add the SafeDep MCP server to your Codex configuration. Edit `~/.codex/config.toml` (or `.codex/config.toml` in your project root for project-scoped access): > > ```toml theme={null} > [mcp_servers.safedep] > url = "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp" > > [mcp_servers.safedep.env_http_headers] > "Authorization" = "SAFEDEP_API_KEY" > "X-Tenant-ID" = "SAFEDEP_TENANT_ID" > ``` > > Set the environment variables with your credentials: > > ```bash theme={null} > export SAFEDEP_API_KEY="" > export SAFEDEP_TENANT_ID="" > ``` > > See the [Codex repository](https://github.com/openai/codex) for MCP configuration details. > [accordion] Windsurf > > Add the SafeDep MCP server to your Windsurf configuration. Create or edit `~/.codeium/windsurf/mcp_config.json` in your home directory: > > ```json theme={null} > { > "mcpServers": { > "safedep": { > "url": "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp", > "headers": { > "Authorization": "", > "X-Tenant-ID": "" > } > } > } > } > ``` > > See the [Windsurf Cascade MCP documentation](https://docs.windsurf.com/windsurf/cascade/mcp) for more details. > [accordion] Zed > > Add the SafeDep MCP server to your Zed configuration. Create or edit `~/.config/zed/settings.json` in your home directory. > > ```json theme={null} > { > "context_servers": { > "safedep": { > "enabled": true, > "url": "https://mcp.safedep.io/model-context-protocol/threats/v1/mcp", > "headers": { > "Authorization": "", > "X-Tenant-ID": "" > } > } > } > } > ``` > > See the [Zed MCP documentation](https://zed.dev/docs/ai/mcp) for more details. ## Testing After setup, verify the integration by asking your coding agent to install one of the following test packages: | Package | Ecosystem | | - | - | | `safedep-test-pkg` | npm | | `safedep-test-pkg` | PyPI | These packages are harmless but are marked as malicious in the SafeDep database for testing purposes. Your coding agent should block the installation and warn that the package is flagged. For example, try prompting your agent with: ``` Install the npm package safedep-test-pkg ``` If the MCP server is configured correctly, the agent will check the package against SafeDep's threat intelligence and refuse to install it. # AI Agent Security Source: https://docs.safedep.io/ai-security/overview Discover, audit, and control what AI coding agents access and run across your developer environments. AI coding agents can read, write, and run almost anything on a developer's machine, and they adopt external components (packages, MCP servers, Agent Skills) faster than any human review. SafeDep helps you see what your agents do and keep them from pulling in malicious components. > [card] [Audit agent activity](/ai-security/gryph-overview) > > **Gryph** records every file and command your AI coding agents touch, in a local audit trail. > [card] [Protect AI coding tools](/ai-security/mcp-server) > > The **SafeDep MCP server** lets agents check that a package is safe before suggesting it. > [card] [Sandbox coding agents](/ai-security/sandbox-coding-agents) > > **PMG** runs Claude Code, Codex, or Pi in a sandbox that blocks credential reads and limits the hosts the agent can reach. > [card] [Discover AI usage](/ai-security/ai-tools-discovery) > > Find the AI agents, MCP servers, and tools in use across your code and machines. > [card] [Govern AI usage](/governance/ai-governance) > > Gain visibility into AI usage across your code and supply chain so you can govern it. # Sandbox Your AI Coding Agent Source: https://docs.safedep.io/ai-security/sandbox-coding-agents Run Claude Code, Codex, or Pi in the PMG sandbox to block credential reads and limit the hosts the agent can reach. A coding agent runs many commands in a session, and each command can read your credentials or send data out. `pmg sandbox exec` runs the agent and every process it starts under one sandbox policy. The sandbox: * Blocks reads and writes of credential files in the repository and in your home directory. * Removes secret variables, model API keys included, from the agent environment. * Makes the agent hook configuration read-only, so the agent cannot remove a hook such as [Gryph](/ai-security/gryph-overview). * Lets the agent write only in the repository, temporary directories, tool caches, and the state directory of its preset. * Sends every outbound connection through a PMG proxy that applies a network policy. [PMG Sandbox Network Policy for Coding Agents](https://www.youtube.com/embed/rwlIeKNVVnw) > [!NOTE] > > `pmg sandbox exec` is experimental. It runs on macOS and on Linux with the Landlock driver. It does not run with Bubblewrap or on Windows. This page needs PMG v0.33.0 or later. Install PMG with the [PMG quickstart](/package-security/pmg/quickstart). ## Run the agent in the sandbox Each agent has a preset that adds its state directory, its own API key, and its own hosts. > [tab] Claude Code > > ```bash theme={null} > pmg sandbox exec --sandbox-allow preset=claude -- claude > ``` > [tab] Codex > > ```bash theme={null} > pmg sandbox exec --sandbox-allow preset=codex -- codex > ``` > [tab] Pi > > ```bash theme={null} > pmg sandbox exec --sandbox-allow preset=pi -- pi > ``` To apply the preset on every run in this repository, save it once: ```bash theme={null} pmg sandbox allow preset=claude pmg sandbox exec -- claude ``` ## Limit the hosts the agent can reach By default the agent can reach every host, and PMG records each destination. Build a network policy from a session, then enforce it. **1. Run a normal session** ```bash theme={null} pmg sandbox exec --sandbox-allow preset=claude -- claude ``` Do the work that the agent usually does in this repository. **2. Propose a profile** ```bash theme={null} pmg sandbox profile propose --last --new agent ``` PMG writes the user profile `agent` in the PMG config directory, outside the repository, where the agent cannot change it. The profile allows each host that the session reached and denies every other destination. Open it with `pmg sandbox profile edit agent` and remove each host that the agent does not need. **3. Run the agent under the profile** ```bash theme={null} pmg sandbox exec --sandbox-profile agent --network-mode enforce \ --sandbox-allow preset=claude -- claude ``` The preset keeps the agent hosts open, such as its model API and sign-in. The profile keeps the hosts that the repository needs. When the proxy refuses a destination, PMG prints the destination and the rule after the agent exits: ```text theme={null} ⊘ Network policy denied pastebin.com:443 rule *:* Allow it with pmg sandbox allow net-connect=pastebin.com:443. ``` ## Fix a denied operation The agent sees a permission error. After the session, find the cause and the command that allows it: ```bash theme={null} pmg sandbox explain --last ``` Git over SSH fails, because the sandbox blocks the SSH agent socket. Use an HTTPS remote. ## Next steps For the exec profile, custom profiles, the network flags, and the limits, see the [sandbox exec documentation](https://github.com/safedep/pmg/blob/main/docs/sandbox-exec.md) in the PMG repository. Read the hosts that a preset allows with `pmg sandbox preset show claude`. > [card] [Gryph](/ai-security/gryph-overview) > > Record every file and command your coding agent touches. > [card] [Stop Install Scripts from Reading Your Secrets](/package-security/pmg/sandbox) > > Run package installs in the PMG sandbox. # Changelog 2026 Source: https://docs.safedep.io/changelog/2026 What SafeDep shipped in 2026, twice a month: the open source tools PMG, vet and Gryph, and SafeDep Cloud. SafeDep is open core. The open source tools [PMG](/package-security/pmg/overview), [vet](/governance/vet/overview) and [Gryph](/ai-security/gryph-overview) are the core. [SafeDep Cloud](/governance/cloud/overview) is the intelligence layer that makes them work: it gives the tools real-time threat intelligence about [malicious packages](/concepts/malicious-package), and it runs them across a team. Each entry covers half a month and lists the open source releases first. A release heading links to its full release notes. **2026-10-31** October 16 to 31, 2026 ## Open Source ### PMG [v0.33.0](https://github.com/safedep/pmg/releases/tag/v0.33.0) * **New:** A sandbox profile can list the hosts that a package manager may reach. The PMG proxy enforces the list, also in the persistent proxy. `deny_ip_literals: true` also refuses an IP address that no rule names. See [Network policy](/package-security/pmg/network-policy). * **New:** `pmg sandbox profile propose` builds a network profile from the hosts that a run reached. The GitHub Action builds one from each job. See [Allow Only Known Hosts in GitHub Actions](/package-security/pmg/github-actions-network-policy). * **New:** The `claude`, `codex` and `pi` sandbox presets allow the hosts that each agent needs. See [Use a preset for a known tool](/package-security/pmg/sandbox#use-a-preset-for-a-known-tool). * **Breaking:** `pmg sandbox exec` sends every outbound connection through a PMG proxy. A program that does not use the proxy variables, such as `psql`, `ssh` or `nc`, cannot connect. To allow direct connections again, set `network_via_proxy_only: false` in a child profile. ### vet v2 [alpha of October 23](https://github.com/safedep/vet/releases/tag/v2.0.0-alpha.20261023182239) * **New:** Each vulnerability finding says whether your code imports the vulnerable package. For Go, it also says whether your code calls the vulnerable function. `vet report finding show` prints the call path. Set the depth with `vet scan --reach`. * **Improved:** Findings carry MITRE ATT\&CK technique IDs in JSON and SARIF output. Attack findings come first. * **Breaking:** vet does not read the saved scans of older alpha builds. Run the scan again. ## SafeDep Cloud ### Endpoint Hub * **New:** The Package Events tab of an endpoint shows the network policy decisions of PMG: each host that PMG allowed or denied. Needs PMG v0.33.0 or later. See [Package Guard](/governance/cloud/endpoint-hub/package-guard). * **New:** The Package Events tab shows the sandbox violations that PMG reports, with the denied operations of each run. Needs PMG v0.34.0 or later. ### Threat Intel * **New:** The Threat Intel Feed has four new indicator types: container image, Telegram bot token, Telegram chat ID and HTTP header. Needs the Threat Intel Feed add-on. See [Schema](/threat-intel/schema). ### Web app * **New:** Maintainers of open source projects can apply for a free Team plan at [app.safedep.io/oss/apply](https://app.safedep.io/oss/apply). * **Fixed:** A revoked invitation can no longer give access to a tenant. **2026-10-15** October 1 to 15, 2026 ## Open Source ### PMG [v0.30.0](https://github.com/safedep/pmg/releases/tag/v0.30.0), [v0.31.0](https://github.com/safedep/pmg/releases/tag/v0.31.0), [v0.32.0](https://github.com/safedep/pmg/releases/tag/v0.32.0) * **New:** Kernel enforcement on Linux. The kernel sends package manager traffic to the persistent proxy, so a tool cannot go around PMG. Traffic from containers on the host goes through the proxy too. See [Kernel enforcement](/package-security/pmg/kernel-enforcement). * **New:** A Windows MSI installs PMG for all users. It is also on Chocolatey and winget. See [System-wide install](/package-security/pmg/system-install). * **New:** PMG checks crates from a custom Cargo registry. The persistent proxy also checks Cargo crates and Go modules. See [Private registries](/package-security/pmg/private-registries). ### vet v2 [first alpha](https://github.com/safedep/vet/releases/tag/v2.0.0-alpha.20261014124335) vet v2 is a new release line with a new command line, report, policy format and config. vet v1 gets security fixes only. The [vet v2.0.0 release notes](https://github.com/safedep/vet/blob/v2/docs/release-notes/v2.0.0.md) list each change that a v1 user must make. * **New:** `vet scan` scans a directory, a git URL, a container image, an SBOM or one package URL. It finds malicious packages, vulnerabilities, risky GitHub Actions workflows, lockfile tampering and changes to AI agent configs. * **New:** `vet scan --base-ref origin/main` reports only what a pull request adds. The `safedep/vet` GitHub Action comments on pull requests, and `vet ci init` adds it to a repository. * **New:** `vet endpoint audit` checks the AI tools, MCP servers, agent skills, editor extensions and global npm packages on a machine. * **New:** `vet auth login` connects vet to a SafeDep Cloud tenant. PMG and the SafeDep CLI use the same login. ## SafeDep Cloud ### Endpoint Hub * **New:** A host observation event shows the port, the entry point and the client process. Needs PMG v0.31.0 or later. ### Threat Intel * **New:** Each indicator of compromise in reports, campaigns and the snapshot export has a confidence (automated or human verified) and a disposition. The feed no longer serves a withdrawn indicator. Needs the Threat Intel Feed add-on. * **Improved:** Detection flags npm packages that hide a loader in a prebuilt native addon. ### Web app * **New:** On a component page, each project links to the scan that found the component. ### SafeDep CLI [v0.10.0](https://github.com/safedep/cli/releases/tag/v0.10.0) * **New:** `safedep integration bitbucket link delete` removes the link to a Bitbucket workspace. # Community Source: https://docs.safedep.io/community Join the SafeDep and Vet user community for support and discussions Connect with other users, get support, and follow development. ## Discord Community Discord is the primary community hub. Join to: * Ask questions and get answers from members and maintainers * Discuss features and use cases * Get announcements about new releases * Connect with other security professionals using Vet and SafeDep > [card] [Join SafeDep Discord](https://discord.gg/kAGEj25dCn) > > **Join the server:** [https://discord.gg/kAGEj25dCn](https://discord.gg/kAGEj25dCn) ![SafeDep Discord Community](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/safedep-discord.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=e190d895b497a7673189b267df6febc5) ## Other Community Channels > [card] [GitHub Discussions](https://github.com/safedep/vet/discussions) > > Join conversations about Vet development and usage > [card] [GitHub Issues](https://github.com/safedep/vet/issues) > > Report bugs, request features, or contribute to development > [card] [LinkedIn](https://linkedin.com/company/safedep) > > Follow SafeDep for company updates and industry insights > [card] [Twitter/X](https://x.com/safedepio) > > Get quick updates and security tips ## Getting Help ### Before Asking Questions 1. **Check the documentation** - Search the guides and API reference 2. **Review existing issues** - Your question may already be answered 3. **Try debugging steps** - Use debug logs to gather more information ### How to Ask Effective Questions > [accordion] Provide Context > > * What are you trying to accomplish? > * What command did you run? > * What was the expected vs actual behavior? > [accordion] Include Details > > * Operating system and version > * Vet version (`vet version`) > * Relevant configuration files > * Error messages and logs > [accordion] Share Code/Commands > > * Use code blocks for commands and outputs > * Include relevant parts of manifests or config files > * Sanitize any sensitive information ### Debug Information ```bash theme={null} # Get version information vet version # Enable debug logging and verbose output vet scan -D /path/to/repo -l- -d # Log to file for sharing vet scan -D /path/to/repo -l /tmp/vet.log -d ``` ## Contributing ### Ways to Contribute > [card] Report Issues > > Help improve Vet by reporting bugs and issues you encounter > [card] Feature Requests > > Suggest new features or improvements > [card] Documentation > > Help improve documentation with corrections, clarifications, or new content > [card] Code Contributions > > Contribute bug fixes, features, or performance improvements ### Contribution Guidelines Before contributing: 1. **Check existing issues** to avoid duplicates 2. **Follow the code of conduct** in all interactions 3. **Use issue templates** when reporting bugs or requesting features 4. **Test your changes** thoroughly before submitting ## Community Guidelines ### Code of Conduct * **Be respectful** in all interactions * **Help others** learn and grow * **Stay on topic** in discussions * **No spam or self-promotion** without prior approval * **Report inappropriate behavior** to moderators Use the right channel for your topic: * General questions: Discord general channel * Bug reports: GitHub issues * Feature requests: GitHub discussions * Support requests: Discord help channel ## Resources > [card] [Documentation](/introduction) > > Complete documentation for Vet and SafeDep Cloud > [card] [Examples Repository](https://github.com/safedep/vet/tree/main/examples) > > Sample configurations and use cases > [card] [Changelog](https://github.com/safedep/vet/releases) > > Latest releases and version history > [card] [Security Policy](https://github.com/safedep/vet/security/policy) > > How to report security vulnerabilities ## Contact * **General support**: [support@safedep.io](mailto:support@safedep.io) * **Security issues**: Follow the [security policy](https://github.com/safedep/vet/security/policy) * **Business inquiries**: [hello@safedep.io](mailto:hello@safedep.io) # CEL Source: https://docs.safedep.io/concepts/cel Common Expression Language (CEL) is the syntax SafeDep uses for filters, queries, and policy rules over package data. [Common Expression Language (CEL)](https://cel.dev/) is a safe, sandboxed expression language. SafeDep adopts it as the common syntax for filtering scan results, running queries, and writing policy rules. A CEL expression evaluates to true or false for each package, so you describe exactly which dependencies you care about. ## Why it matters One language covers three jobs: ad-hoc filtering during a scan, repeatable queries over saved scan data, and enforceable policy. You learn the syntax once and reuse it everywhere. ## What you can reference A CEL expression in Vet receives this data about each package: | Variable | What it holds | | - | - | | `pkg` | Package coordinates: `ecosystem`, `name`, `version` | | `vulns` | Vulnerabilities by severity: `all`, `critical`, `high`, `medium`, `low` (each item has an `id`) | | `scorecard` | OpenSSF Scorecard data: `score` and per-check `scores["Check-Name"]` | | `projects` | Source projects: `name`, `type`, `stars`, `forks`, `issues` | | `licenses` | SPDX license identifiers | A few expressions: ```cel theme={null} vulns.critical.exists(x, true) licenses.exists(p, p == "MIT") projects.exists(x, x.stars < 100) && scorecard.scores.Maintained < 5 ``` Hyphenated scorecard checks use the bracket form, for example `scorecard.scores["Token-Permissions"]`. ## Related > [card] [Filtering](/reference/filtering) > > The full filter input structure and recipes. > [card] [Build Your Own Queries](/reference/build-your-own-queries) > > Reuse CEL over saved scan data. > [card] [Policy](/concepts/policy) > > How CEL rules become enforceable policy. > [card] [Policy as Code](/reference/policy-as-code) > > Write policy files with CEL. # Endpoint Source: https://docs.safedep.io/concepts/endpoint An endpoint is a developer machine, CI runner, or agent sandbox that runs SafeDep tooling and reports inventory to Endpoint Hub. An endpoint is a managed asset, such as a developer machine, a CI runner, or an agent sandbox, that runs SafeDep's open-source tools and reports what it finds to [Endpoint Hub](/governance/cloud/endpoint-hub/overview) in SafeDep Cloud. > [!NOTE] > > An endpoint here is a machine, not an API endpoint. For SafeDep's service hostnames, see [API Endpoints](/reference/endpoints). ## Why it matters Endpoints give a team visibility into what runs across its development infrastructure: AI coding agents, MCP servers, CLI tools, IDE extensions, and the packages developers install. That inventory is what you govern. ## What an endpoint reports * AI tooling discovered by `vet endpoint scan`: coding agents, MCP servers, CLI tools, IDE extensions, and Agent Skills. * Package install activity captured by [PMG](/package-security/pmg/overview) through Package Guard. Each endpoint appears by hostname in Endpoint Hub, where you browse its inventory and package events. Reporting requires SafeDep Cloud credentials; without them, scans run locally only. ## Related > [card] [Endpoint Hub](/governance/cloud/endpoint-hub/overview) > > The console view of your endpoints. > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > Package activity from each endpoint. > [card] [Tenant](/concepts/tenant) > > The org boundary endpoints report into. > [card] [API Endpoints](/reference/endpoints) > > SafeDep's service hostnames (different meaning). # Labels Source: https://docs.safedep.io/concepts/labels A label is a key and value on an endpoint or a project. The prefix of the key names its source, and a policy override selects subjects by their labels. A label is a `key=value` pair on an [endpoint](/concepts/endpoint) or a project. A policy override of the cloud [policy](/concepts/policy) uses a label selector to choose the endpoints and projects that it applies to. See [Policy Resolution](/concepts/policy-resolution). ## Prefixes and sources The key of a label has the form `prefix/name`, as in `custom/criticality`. The prefix names the source of the label. Each source can write only its own prefixes, so an endpoint cannot write a `custom/` label and an Admin cannot write a `scm/` label. | Prefix | Source | Labels | | - | - | - | | `safedep.io/` | SafeDep Cloud | `safedep.io/endpoint-id` on an endpoint. `safedep.io/project-id` and `safedep.io/project-source` (such as `github`) on a project. | | `scm/` | SafeDep Cloud, from the repository that is bound to a project | `scm/forge` (`github` or `bitbucket`), `scm/owner` and `scm/repo`. | | `custom/` | An Admin of the tenant | Any name and value that you choose, as `custom/criticality=high`. Set them with `safedep project label set` and `safedep endpoint label set`. | | `reported/` | The tool on the endpoint | PMG sends `reported/os` and `reported/arch`, with values such as `darwin` and `arm64`. | | `managed/` | A managed file that MDM writes | No tool sends these labels yet. | | `scm-property/` | GitHub custom properties | SafeDep Cloud does not store these labels yet. | A selector can name each of the six prefixes. A project that is not bound to a repository has only `safedep.io/` and `custom/` labels. ## Selectors A label selector has the form of a Kubernetes label selector: * `matchLabels` holds pairs that must match exactly. * `matchExpressions` holds terms with the operators `In`, `NotIn`, `Exists` and `DoesNotExist`. Every pair and every term must hold. An empty selector matches every subject. A key that a subject does not have fails `In` and `Exists`, and passes `NotIn` and `DoesNotExist`. To select the subjects that have one of two labels, give them one shared `custom/` label, or write two policy overrides. Before you publish a policy override, you can list the projects and endpoints that its selector matches. See [Target a Group](/governance/cloud/policy/target-a-group#check-the-result). ## When a label change applies A label change makes no policy revision. It applies when the subject resolves next: at the next policy fetch of an endpoint, or at the next pull request check of a project. Each label change writes an audit event. ## Which labels you can trust An endpoint sends its own `reported/` labels, and later its `managed/` labels. A forge admin sets GitHub custom properties. SafeDep Cloud cannot check these values. Also, until endpoint enrollment ships, an endpoint asserts its own identity, so an endpoint can claim the identity, and the labels, of another endpoint. So no endpoint label is an access boundary yet. For a policy override that loosens the policy, select on `safedep.io/`, `scm/` or `custom/` labels. The preview of a policy change warns when a policy override that loosens selects on `managed/`, `reported/` or `scm-property/` labels. ## Limits A subject has at most 32 `custom/` labels. A `custom/` value has at most 63 characters, and the name after the prefix has at most 75. See [Cloud Policy Limits](/reference/cloud-policy-limits). ## Related > [card] [Policy Resolution](/concepts/policy-resolution) > > How the matched policy overrides merge. > [card] [Target a Group](/governance/cloud/policy/target-a-group) > > Label endpoints and projects and write a policy override for them. > [card] [Endpoint](/concepts/endpoint) > > The machines and runners that report to your tenant. # Malicious Package Source: https://docs.safedep.io/concepts/malicious-package What a malicious open-source package is, how it differs from a vulnerability, and how SafeDep detects them. A malicious package is an open-source package built or altered to harm whoever installs it: stealing secrets, opening a backdoor, or running unwanted code. Unlike a [vulnerability](/concepts/vulnerability), which is an unintended flaw in an otherwise legitimate package, a malicious package is harmful by design. ## Common forms * **Typosquatting and dependency confusion:** a package named to be mistaken for a popular or internal one. * **Malicious install scripts:** code that runs the moment a package is installed, before you ever import it. * **Backdoors and data exfiltration:** harmful behavior hidden inside otherwise working code. * **Compromised releases:** malicious code injected into a previously trusted package, usually in a fresh version. ## How SafeDep detects them SafeDep monitors public package registries (npm, PyPI, RubyGems, and more) and analyzes new and updated packages with: * **Static analysis** of the package's code, * **Dynamic analysis** of its runtime behavior (network, file system, and process activity), * **Metadata analysis** of the package and its publisher. Suspicious packages are verified by security experts before classification. The result feeds a real-time malicious package database that every SafeDep tool reads from. ```mermaid theme={null} graph TD NPM[npm Registry] --> MONITORING[SafeDep Monitoring] PYPI[PyPI Registry] --> MONITORING RUBYGEMS[RubyGems Registry] --> MONITORING OTHER[Other Package Registries] --> MONITORING MONITORING --> STATIC[Static Code Analysis] STATIC --> DYNAMIC[Dynamic Analysis] DYNAMIC --> EXPERT[Expert Verification] EXPERT --> DATABASE[Real-time Malicious Package Database] DATABASE --> VET[SafeDep Vet
CI/CD Protection] DATABASE --> PMG[SafeDep PMG
Developer Environment Protection] VET --> CICD_BLOCK[Block Malicious Packages in CI/CD] PMG --> DEV_BLOCK[Block Malicious Packages at Install Time] classDef benefit fill:#4ade80,stroke:#16a34a,stroke-width:2px,color:#000000 class CICD_BLOCK,DEV_BLOCK benefit ``` ## Blocking malicious packages Detection is how SafeDep knows a package is malicious. Blocking it is the job of [Package Security](/package-security/overview): * [PMG](/package-security/pmg/overview) blocks them at install time on developer machines. * [Vet](/governance/vet/overview) blocks them in CI/CD. * The [SafeDep MCP server](/ai-security/mcp-server) lets AI coding agents check a package before suggesting it. ## Related > [card] [Vulnerability](/concepts/vulnerability) > > The other kind of dependency risk: unintended flaws in legitimate packages. > [card] [Package Security](/package-security/overview) > > Block malicious packages at every entry point. > [card] [Malware Analysis](/governance/cloud/malware-analysis) > > Analyze a package on demand in SafeDep Cloud. > [card] [Policy](/concepts/policy) > > Turn detection into enforceable rules. # Package Rules Source: https://docs.safedep.io/concepts/package-rules A package rule is a block entry or a trust entry in the cloud policy. It selects packages by PURL and has a reason, an author and an expiry. A package rule is one entry in the cloud [policy](/concepts/policy) that decides about specific packages. It is a **block entry** or a **trust entry**. Each rule selects packages with a package URL (PURL), has a reason and an author, and can expire. A rule id, such as `r_9c1x4kq7dm`, identifies it, and each decision that the rule makes cites that id. ## Block entries A block entry stops the packages that it selects. PMG blocks the install, and the pull request check fails when a pull request adds the package. A block entry stops new installs. It does not remove copies that are already installed. A block entry can select: * every version of one package, as `pkg:npm/evil`; * one version, as `pkg:npm/evil@1.2.4`; * a version range in the [vers](https://github.com/package-url/vers-spec) form, as `vers:npm/>=1.2.0|<2.0.0`; * many packages with a prefix that ends with `/*` or `.*`, as `pkg:npm/@acme/*`, `pkg:maven/org.apache.*` or `pkg:nuget/Microsoft.*`. A prefix has no version. To limit a prefix to some versions, add a range. A wide prefix such as `pkg:npm/*` selects every package of an ecosystem, and so stops every install of that ecosystem in the tenant. ## Trust entries A trust entry waives the verdicts of its trust scopes for one package. It selects one package, with an optional version or range. It cannot use a prefix: in most ecosystems anyone can publish under a prefix, so a prefix would also trust packages that do not exist yet and that no one reviewed. Each trust entry names the trust scopes that it waives: `malware` (a malware verdict that is not verified, such as a suspicious package), `cooldown` (the dependency cooldown) or `vulnerability` (the vulnerability findings of a scan gate). Each tool applies only the scopes that fit its checks. See [Cloud Policy Settings](/reference/cloud-policy-settings#package-rule-fields) for the scopes that PMG and the pull request check apply. A trust entry never waives a scope that it does not name. A client that offers "all scopes" expands it to the scopes that exist when the admin creates the rule. So a scope that a later release adds never widens a rule that exists. A trust entry needs a reason and an expiry. The expiry is at most 90 days from now. A trust entry never skips the malware analysis. ## Block beats trust When a block entry and a trust entry both select a package, the block entry wins. A cloud block entry in PMG also wins over the PMG `trusted_packages` list and the `PMG_INSECURE_INSTALLATION` environment variable. ## Verified malware is never trusted No trust entry waives a verdict of verified malware, whatever its scopes. No policy setting turns off the block of verified malware either. Without this rule, an attacker who takes over the account of one Admin could trust a malicious package and deliver it to every developer of the tenant. PMG and the pull request check both enforce the rule. ## How rules match Every match compares the canonical package name and version, by the rules of the ecosystem. For example, PyPI treats `Foo_Bar` and `foo-bar` as one package, so a rule for one spelling also selects the other. A PURL that is not canonical never lets a blocked package through. Set a version in the PURL or a range, not both. When a tool cannot order a version, a block entry with a range still selects it, and a trust entry with a range does not. The checks fail closed. ## Where a rule applies A rule attaches to the policy base, and then it applies to every endpoint and project of the tenant. Or it attaches to one policy override, and then it applies only to the subjects that the policy override matches. Package rules are not in the policy settings document. Each rule command of the safedep CLI publishes at once, as one new [policy revision](/concepts/policy-revisions). So a run that publishes the settings document cannot delete a block that an on-call responder added. A rule never changes its selector, effect or scopes. To change them, delete the rule and create another. The tools apply package rules on the endpoint and in the pull request check. The malware analysis does not apply them: it gives the same verdict to every tenant and holds no tenant data. A PMG with no cloud policy support, or with the cloud policy turned off, gets no package rules from the cloud. It gets no trust entries, so a trust entry never lets a package through on that endpoint. It also gets no block entries, so a block entry does not stop an install on that endpoint. During an incident, do not count on a block entry for such endpoints. Such an endpoint reports no applied revision, so its `Policy` column in `safedep endpoint list` shows `-`. The filter `--applied-revision ' [card] [Block a Package](/governance/cloud/policy/block-a-package) > > Block a package for the whole tenant during an incident. > [card] [Trust a Package](/governance/cloud/policy/trust-a-package) > > Trust a package after a false positive. > [card] [Malicious Package](/concepts/malicious-package) > > How SafeDep classifies a package as malicious. > [card] [Cloud Policy Limits](/reference/cloud-policy-limits) > > The number of rules, the length of a reason and other limits. # Policy Source: https://docs.safedep.io/concepts/policy A SafeDep policy decides which packages pass. There are two kinds: the cloud policy of a tenant, and policy as code in a repository. A policy turns your supply chain rules into data that SafeDep tools apply to each package. You write a rule once, and the tools apply it the same way on every machine and in every check. SafeDep has two kinds of policy. They differ in where they live, who changes them, and which tools read them. ## The cloud policy The cloud policy is one policy for each [tenant](/concepts/tenant). It lives in SafeDep Cloud, and an Admin of the tenant changes it with the [safedep CLI](/get-started/cli-tools). A change reaches every endpoint and every pull request check of the tenant with no new MDM package. The cloud policy holds two kinds of content: * **Policy settings** are typed values, such as the dependency cooldown or the lowest vulnerability severity that fails a pull request check. Settings come in layers: the SafeDep default policy, the policy base of the tenant, and policy overrides for groups of endpoints and projects. See [Policy Resolution](/concepts/policy-resolution). * **Package rules** are block entries and trust entries for packages. See [Package Rules](/concepts/package-rules). Each publish makes a new [policy revision](/concepts/policy-revisions). Each decision that a tool makes with the cloud policy names the revision and the rule or setting that decided. So you can explain a block, roll back a bad change, and show an auditor which policy applied on a date. These tools enforce the cloud policy: * [PMG](/package-security/pmg/cloud-policy) on developer machines and CI runners applies the package rules and the dependency cooldown. * The pull request check of the [SafeDep GitHub App](/governance/integrations/github) and the [Bitbucket app](/governance/integrations/bitbucket-app) applies the scan gate settings and the package rules. * Vet does not read the cloud policy yet. ## Policy as code Policy as code is a Vet filter suite: a YAML file of [CEL](/concepts/cel) rules that you keep in a repository. Vet evaluates each package of a scan against the rules, including transitive dependencies, and you decide what a match does. During a local scan, Vet can exit with a non-zero code when a package matches a rule. In CI/CD, [vet-action](https://github.com/safedep/vet-action) takes the policy file in its `policy` input. See [Policy as Code](/reference/policy-as-code) for the syntax and examples. ## Compare the two kinds | | Cloud policy | Policy as code | | - | - | - | | Where it lives | SafeDep Cloud, one for each tenant | A YAML file in a repository | | Who changes it | An Admin of the tenant, with the safedep CLI | Each person who can change the file | | What it holds | Policy settings and package rules | CEL rules over package data | | History | Policy revisions and audit events | The history of the repository | | What enforces it | PMG and the pull request check | Vet and vet-action | | Plan | SafeDep Cloud Team or Enterprise | Free and open source | ## Related > [card] [Cloud Policy](/governance/cloud/policy/overview) > > Manage the cloud policy of your tenant. > [card] [Policy Resolution](/concepts/policy-resolution) > > How the layers of the cloud policy merge for one endpoint or project. > [card] [Policy as Code](/reference/policy-as-code) > > Write and structure Vet policy files. > [card] [CEL](/concepts/cel) > > The expression syntax of policy as code. > [card] [Malicious Package](/concepts/malicious-package) > > The intelligence that policies act on. > [card] [JFrog Xray Blocking](/threat-intel/integrations/jfrog-xray) > > Enforce package blocking in JFrog Xray. # Policy Resolution Source: https://docs.safedep.io/concepts/policy-resolution How SafeDep Cloud merges the default policy, the policy base and the policy overrides into the resolved policy of one endpoint or project. A tenant has one cloud [policy](/concepts/policy), but its endpoints and projects do not all need the same values. A CI runner can need a longer dependency cooldown than a laptop. A payment service can need a stricter pull request check than an internal tool. Policy resolution is how SafeDep Cloud computes the values for one of them. ## Subjects A subject is a thing that the policy resolves for: an [endpoint](/concepts/endpoint) or a project. A repository is a project. Each subject has [labels](/concepts/labels), and the labels decide which policy overrides apply to it. ## The three layers Resolution stacks three layers of policy settings, from low to high: 1. **The SafeDep default policy.** SafeDep defines it and gives it its own revision number. No tenant can change it. It holds policy settings only, never package rules. Today it sets `scan_gate.fail_on` to `high` and `scan_gate.fail_on_attacks` to `fail`, the gate that the pull request check used before the cloud policy existed. 2. **The policy base.** It applies to every endpoint and every project of the tenant. 3. **Policy overrides.** Each policy override has a name, a label selector, a unique priority, and the settings that it changes. It applies only to the subjects that its selector matches. A policy override can also have an expiry, after which it matches no subject. For each field, the highest layer that sets the field wins. Among the policy overrides that match a subject, the one with the highest priority wins. A policy override sets only the fields that it lists. Every other field comes from the next layer down. A tenant that sets nothing gets the default policy alone. So does a pull request check of an installation that is not linked to a tenant, and of a tenant whose plan does not include the cloud policy. ## Package rules [Package rules](/concepts/package-rules) do not use the layers above. A package rule attaches to the policy base, or to one policy override. A subject gets the rules of the policy base plus the rules of each policy override that matches it. ## Example The policy base sets a cooldown of 48 hours. Two policy overrides change it: | Policy override | Priority | Selector | Settings | | - | - | - | - | | `payments` | 200 | `custom/criticality=high` | `scan_gate.fail_on: medium`, `package_admission.cooldown.min_age: 168h` | | `macs` | 100 | `reported/os=darwin` | `package_admission.cooldown.min_age: 120h` | | Subject | Matches | Cooldown | `scan_gate.fail_on` | | - | - | - | - | | A Linux CI runner with no `custom/` labels | none | 48h, from the policy base | `high`, from the default policy | | A macOS laptop | `macs` | 120h, from `macs` | `high`, from the default policy | | A macOS laptop with `custom/criticality=high` | `payments` and `macs` | 168h, from `payments` (higher priority) | `medium`, from `payments` | ## The resolved policy The resolved policy is the result for one subject. It holds the merged settings, the package rules that apply, the tenant policy revision, the default policy revision and the policy overrides that matched. It also names the layer that set each field, so a tool can explain a decision. SafeDep Cloud resolves the policy when a subject needs it: * An endpoint gets its resolved policy at each policy fetch. PMG keeps the last one in a local cache. * A project gets its resolved policy at each pull request check. A new revision, a label change or an expiry changes the result at the next fetch or check. To see the result for one subject, and the layer that set each value, run `safedep endpoint policy show` or `safedep project policy show`. ## Related > [card] [Labels](/concepts/labels) > > How a policy override selects endpoints and projects. > [card] [Package Rules](/concepts/package-rules) > > Block and trust entries. > [card] [Target a Group](/governance/cloud/policy/target-a-group) > > Write a policy override for a group of endpoints or projects. > [card] [Cloud Policy Settings](/reference/cloud-policy-settings) > > Each setting and its value in the default policy. # Policy Revisions and Changes Source: https://docs.safedep.io/concepts/policy-revisions How a change to the cloud policy goes from a draft to a published revision: preview, change direction, stale changes, rollback, notices and audit. Each change to the cloud [policy](/concepts/policy) goes through the same steps. You write a draft, you read a preview of its effect, and you publish it. The publish makes a new policy revision. This page explains each step. ## Policy changes A policy change is a draft on the server. It starts from a base revision, the head revision when you created it. It can edit the policy settings document, add package rule operations, or both. Nothing applies until an Admin publishes it. `safedep policy edit` opens the policy settings document of the tenant in your editor: the policy base and every policy override. When you save the file, the command creates a policy change. Package rules are not in this document. The rule commands, such as `safedep policy rule create`, create a change and publish it in one step. The document keeps no YAML comments. Write the reason for a value in the `description` of the policy override, or in `base_description` for the policy base. ## The preview `safedep policy change show` compares an open change with the head revision. It shows: * each field that changes, in the policy base and in each policy override, with its old value, its new value and its change direction; * each change to a policy override itself, such as a new selector or priority; * the package rule operations; * the number of projects and endpoints that the change reaches; * policy coverage: how many of those subjects can enforce each new value, and which ones enforce it only in part; * warnings, for example when a block entry selects every package of an ecosystem, when a policy override that loosens selects on a label that an endpoint can send, or when a rollback drops fields of a policy override. In this release, only the pull request check reports policy coverage, so the coverage counts include projects only. ## Change direction SafeDep Cloud computes the change direction of each change: it **tightens**, it **loosens**, or it is **neutral**. It compares the resolved policy before and after the change, for each group of subjects that the change reaches. * A setting tightens when its new value is stricter, such as a longer cooldown or a lower severity for `scan_gate.fail_on`. * A setting that had no value before the change, or that has no value after it, loosens. SafeDep Cloud cannot know what a tool does when no layer sets the field. So the first cooldown that you set counts as a change that loosens. * A new block entry tightens. A new trust entry loosens. * A deleted block entry loosens. A deleted trust entry tightens. * A later expiry of a trust entry loosens. A new or earlier expiry of a block entry loosens, because it narrows the block. * A new or deleted policy override, or a change of a selector, a priority or the expiry of a policy override, loosens. Such a change can move subjects to a looser result. * A change of a name or a description is neutral. A change loosens when any part of it loosens. ## Publish and revisions `safedep policy change publish` makes a new policy revision from an open change. A revision is immutable, and revision numbers only go up. In this release every publish needs the Admin role. A change that loosens the policy also needs a confirmation: the command asks in a terminal, and needs `--yes` in a script. After a publish, each pull request check uses the new revision at once. Each endpoint applies it after its next policy fetch. ## Stale changes and sync Two Admins can work on the policy at the same time. A publish checks that the parts that a change edits did not change after its base revision: * The policy settings document is one part. When another publish changed it, the change is stale. * Each package rule is one part, by its rule id. A new block entry does not touch the settings document. So a block that an on-call responder adds does not make an open settings change stale. A stale change must be synced before it can be published. A sync moves the base revision of the change to head and keeps the settings as the admin wrote them. SafeDep Cloud never merges two changes, so the settings of a synced change can undo the other change. The admin reads the preview again before the publish. See [If the publish stops](/governance/cloud/policy/target-a-group#if-the-publish-stops). ## Rollback A rollback is a new change, not a deletion of history. It restores capabilities, such as `scan_gate`, from an old revision. For each restored capability, the policy base and every policy override take their values from that revision. A policy override that did not exist then loses the fields of the restored capabilities, and the preview warns about it. Package rules stay at head, unless the admin asks to restore them too. The publish of a rollback makes a new revision with a higher number. See [Roll Back a Change](/governance/cloud/policy/roll-back-a-change). ## Notices SafeDep Cloud sends an email to every Owner and Admin of the tenant after a publish that: * loosens the policy, * adds a block entry, or * restores a revision. The email names the tenant, the revision, the person who published it, the change direction, the message, the changed fields, and for a block the selector and the reason. ## Audit events Each admin action writes one audit event in the same transaction as the action: each change, publish, rule operation and label change. An action that fails writes no event, and a publish that fails sends no email. See [Audit Policy Changes](/governance/cloud/policy/audit-policy-changes). ## Related > [card] [Quickstart](/governance/cloud/policy/quickstart) > > Publish your first policy revision. > [card] [Roll Back a Change](/governance/cloud/policy/roll-back-a-change) > > Restore a setting from an old revision. > [card] [Policy Resolution](/concepts/policy-resolution) > > How a revision becomes the policy of one subject. > [card] [Cloud Policy Limits](/reference/cloud-policy-limits) > > Publishes in a day, open changes and retention. # SBOM Source: https://docs.safedep.io/concepts/sbom A Software Bill of Materials (SBOM) is a complete inventory of your software's components; an xBOM enriches it with AI, SaaS, and crypto usage. A Software Bill of Materials (SBOM) is a complete inventory of the components your software depends on, along with security metadata such as known vulnerabilities and licenses. The common interchange format is [CycloneDX](https://cyclonedx.org/). ## SBOM and xBOM * A plain **SBOM** lists the dependencies declared in your manifests and lockfiles. Vet generates a CycloneDX SBOM as part of a scan. * An **xBOM** goes further: [xBom](/governance/xbom/overview) analyzes your source code to also surface AI SDKs, SaaS APIs, and cryptographic usage that never appear in a manifest. Use Vet's SBOM for dependency inventory. Reach for xBom when you also need to see the AI, SaaS, and crypto components your code actually uses. ## Why it matters An accurate inventory underpins vulnerability management, license compliance, and regulatory requirements. You cannot secure what you have not inventoried. ## Related > [card] [CycloneDX SBOM](/governance/cyclonedx-sbom) > > Generate an SBOM with Vet. > [card] [xBom](/governance/xbom/overview) > > Enriched BOMs from static code analysis. > [card] [Dependency Inventory](/governance/vet/dependency-inventory) > > Inventory your dependencies with Vet. # Tenant Source: https://docs.safedep.io/concepts/tenant A tenant is your organization's isolated space in SafeDep Cloud, identified by its tenant domain such as your-company.safedep.io. A tenant is your organization's isolated space in SafeDep Cloud. Your users, API keys, policies, scan data, and endpoints all live inside it, separate from every other tenant. ## Your tenant ID is your tenant domain The tenant identifier is a domain, for example `your-company.safedep.io`. There is no separate tenant ID to look up. You use the domain to: * send the `X-Tenant-ID` header on API requests, * configure Vet with `vet auth configure --tenant your-company.safedep.io`, * set the `SAFEDEP_TENANT_ID` environment variable. ## Why it matters The tenant is the boundary for isolation and governance: scan results, policies, and access are all scoped to it. You create and manage API keys inside your tenant from the SafeDep Cloud console. ## Related > [card] [Authentication](/governance/cloud/authentication) > > Authenticate against your tenant. > [card] [Endpoint](/concepts/endpoint) > > Assets that report into your tenant. > [card] [API Endpoints](/reference/endpoints) > > Where the X-Tenant-ID header is sent. # Vulnerability Source: https://docs.safedep.io/concepts/vulnerability What a vulnerability is in an open-source dependency, and how SafeDep surfaces and gates them. A vulnerability is a disclosed security flaw in a package's code. The package is legitimate; the flaw is a mistake, not an attack. Unlike a [malicious package](/concepts/malicious-package), which is harmful by design, a vulnerable package became exploitable by accident. Vulnerabilities are tracked under identifiers like CVEs and aggregated in open databases such as [OSV](https://osv.dev). Each carries a severity, for example `CRITICAL` or `HIGH`, that signals how urgent a fix is. ## How SafeDep surfaces them [Vet](/governance/vet/overview) checks every dependency against OSV and reports known vulnerabilities with their severity. You decide what to do about them with [policy](/concepts/policy): for example, fail a build when any dependency has a `CRITICAL` or `HIGH` vulnerability. ## Related > [card] [Malicious Package](/concepts/malicious-package) > > The other kind of dependency risk: packages that are harmful by design. > [card] [Policy](/concepts/policy) > > Gate builds on vulnerability severity. > [card] [Repository Scanning](/governance/vet/overview) > > Scan a repository's dependencies for known vulnerabilities. > [card] [SBOM](/concepts/sbom) > > Inventory the components you ship. # Vet FAQ Source: https://docs.safedep.io/faq Frequently asked questions about using Vet and troubleshooting common issues ## General Usage ### How do I disable the banner? ```bash theme={null} export VET_DISABLE_BANNER=1 ``` ### Something is wrong! How do I debug this? Enable debug logging: > [tab] Log to stdout > > ```bash theme={null} > vet scan -D /path/to/repo -l- -d > ``` > [tab] Log to file > > ```bash theme={null} > vet scan -D /path/to/repo -l /tmp/vet.log -d > ``` > [tab] Verbose output > > ```bash theme={null} > vet scan -D /path/to/repo -l- -v > ``` ## Installation and Setup ### Which version of Vet should I use? Always use the latest stable version available: ```bash theme={null} # Check current version vet version # Update via Homebrew (macOS/Linux) brew upgrade safedep/tap/vet # Or download latest from GitHub releases # https://github.com/safedep/vet/releases ``` ### Does Vet work offline? Vet requires internet connectivity to: * Download vulnerability data from OSV database * Fetch OpenSSF Scorecard information * Access package registry metadata * Communicate with SafeDep Cloud (if using cloud features) For offline environments, consider using the [JSON dump workflow](/reference/build-your-own-queries) to cache data locally. ### What package managers does Vet support? Vet supports: > [accordion] JavaScript/Node.js > > * package-lock.json (npm) > * yarn.lock (Yarn) > * pnpm-lock.yaml (pnpm) > [accordion] Python > > * requirements.txt > * Pipfile.lock (Pipenv) > * poetry.lock (Poetry) > * pyproject.toml > [accordion] Java/JVM > > * pom.xml (Maven) > * build.gradle (Gradle) > * gradle.lockfile > [accordion] Go > > * go.mod > * go.sum > [accordion] Other Languages > > * Gemfile.lock (Ruby) > * Cargo.lock (Rust) > * composer.lock (PHP) > * And many more... ## Scanning and Analysis ### Why is my scan taking so long? Common causes: > [accordion] Large dependency trees > > Use path exclusions to skip irrelevant directories: > > ```bash theme={null} > vet scan -D . --exclude 'node_modules/*' --exclude 'test/*' > ``` > [accordion] Network latency > > The scan fetches metadata from external sources. Slow internet can impact performance. > [accordion] Malware analysis > > Malware detection with `--malware-query` is a fast lookup against SafeDep's > known malicious packages database and adds negligible overhead: > > ```bash theme={null} > vet scan -D . --malware-query > ``` > [accordion] First-time caching > > Initial scans may be slower as Vet builds local caches. ### No vulnerabilities found - is this correct? If Vet reports no vulnerabilities: 1. **Check the package versions** - Ensure you're scanning current dependency versions 2. **Verify manifest files** - Confirm Vet is finding and parsing your package manifests 3. **Check exclusions** - Make sure you haven't excluded relevant directories 4. **Review scan output** - Look for any warnings or errors during scanning ### How do I scan only specific files? Use the `-M` flag to specify individual manifest files: ```bash theme={null} # Single file vet scan -M package-lock.json # Multiple files vet scan -M package-lock.json -M requirements.txt ``` ## Policy and Filtering ### How do I create effective policies? Start with a basic vulnerability check, then layer in additional conditions: ```bash theme={null} --filter 'vulns.critical.size() > 0' ``` Test against known-good and known-bad packages before deploying. Enable warning-only mode first, then switch to blocking once the policy is stable. Add comments to policy files explaining the rationale for each rule. ### Why is my filter not working? Common causes: > [accordion] Syntax Errors > > Verify CEL expression syntax: > > ```bash theme={null} > # Correct > vulns.critical.size() > 0 > > # Incorrect > vulns.critical.length() > 0 # Use size(), not length() > ``` > [accordion] Data Structure > > Check the [filter input specification](/reference/filtering) to understand available fields. > [accordion] Boolean Logic > > Ensure your expression evaluates to true/false: > > ```bash theme={null} > # Returns boolean > licenses.exists(p, p == "MIT") > > # Returns array (won't work as filter) > licenses > ``` ## Performance and Optimization ### How can I speed up my scans? > [accordion] Use Path Exclusions > > Skip irrelevant directories: > > ```bash theme={null} > vet scan -D . \ > --exclude 'test/*' \ > --exclude 'docs/*' \ > --exclude 'examples/*' > ``` > [accordion] Scan Specific Manifests > > Target only relevant package files: > > ```bash theme={null} > vet scan -M package-lock.json -M requirements.txt > ``` > [accordion] Use JSON Dump Workflow > > Cache enriched data for repeated analysis: > > ```bash theme={null} > vet scan -D . --json-dump-dir /tmp/cache > vet query --from /tmp/cache --filter 'your-filter' > ``` > [accordion] Parallel Processing > > For multiple projects, run scans in parallel or use CI/CD matrix builds. ## CI/CD Integration ### My GitHub Action is failing - what should I check? > [accordion] Action Version > > Ensure you're using the latest version of vet-action: > > ```yaml theme={null} > uses: safedep/vet-action@v1 # Use latest stable > ``` > [accordion] Permissions > > Check GitHub token permissions: > > ```yaml theme={null} > permissions: > contents: read > security-events: write # For SARIF upload > pull-requests: write # For PR comments > ``` > [accordion] Secrets Configuration > > Verify required secrets are set if using SafeDep Cloud: > > * `SAFEDEP_CLOUD_API_KEY` > * `SAFEDEP_CLOUD_TENANT_DOMAIN` ### How do I handle false positives in CI? > [accordion] Use Exceptions > > Create an exceptions file for known false positives: > > ```yaml theme={null} > - name: Run vet with exceptions > uses: safedep/vet-action@v1 > with: > exception-file: '.github/vet-exceptions.yml' > ``` > [accordion] Adjust Policies > > Refine your filter expressions to reduce noise: > > ```bash theme={null} > # Be more specific about severity > --filter 'vulns.critical.size() > 0' > # Instead of > --filter 'vulns.all.size() > 0' > ``` > [accordion] Use Warning Mode > > The action does not fail the build by default, so you can surface findings without blocking while you tune policies. Just leave `paranoid` off (its default is `false`): > > ```yaml theme={null} > with: > paranoid: false > ``` ## Data and Privacy ### What data does Vet collect? Vet collects: * **Package metadata** from public registries * **Vulnerability data** from public databases (OSV, NVD) * **OpenSSF Scorecard** metrics from public repositories Only **package coordinates** (ecosystem, name, version) leave your machine. Your source code is never transmitted. ### Does Vet send my code anywhere? No. Vet reads your manifests, lockfiles, and (when [code analysis](/governance/vet/code-analysis) is enabled) your source code **locally** to identify and trace dependencies. Only package coordinates are sent to SafeDep for vulnerability and malware analysis; your source code never leaves your machine. ### Can I use Vet in air-gapped environments? Vet requires internet access for vulnerability data and package metadata. For air-gapped environments: 1. **Pre-cache data** using the [JSON dump workflow](/reference/build-your-own-queries) 2. **Use proxy servers** to control external access 3. **Consider enterprise solutions** for offline vulnerability databases ## Troubleshooting ### Common error messages and solutions > [accordion] 'No manifest files found' > > * Check that you're in the correct directory > * Verify manifest files exist (package-lock.json, requirements.txt, etc.) > * Use `-M` flag to specify files explicitly > [accordion] 'Failed to download vulnerability data' > > * Check internet connectivity > * Verify firewall/proxy settings > * Try again later (service might be temporarily unavailable) > [accordion] 'Memory limit exceeded' > > * Use path exclusions to reduce scope > * Scan smaller directory trees > * Increase available memory in CI/CD > [accordion] 'Invalid filter expression' > > * Check CEL syntax > * Verify field names in filter input spec > * Test expressions incrementally ## Getting More Help > [card] [Community Discord](https://discord.gg/kAGEj25dCn) > > Real-time help and discussions > [card] [GitHub Issues](https://github.com/safedep/vet/issues) > > Report bugs or search existing issues > [card] [Documentation](/introduction) > > Guides and API reference > [card] [Email Support](mailto:support@safedep.io) > > Direct support for complex issues *** Can't find your question here? Check our [community page](/community) for more ways to get help! # Choose Your Path Source: https://docs.safedep.io/get-started/choose-your-path Start free with the open source tool that fits your use case. Add SafeDep Cloud when your team needs one view. You do not need all of SafeDep on day one. Start with one free tool that solves your problem today. Add SafeDep Cloud when your team needs shared visibility and control. This page shows you where to start. ## Start free Pick the task you want to do today. Everything in this list is free. Most items are open source tools; the cards say when an item is a cloud service instead. > [card] [Stop a malicious npm or pip install](/package-security/pmg/quickstart) > > PMG wraps your package manager and blocks known malicious packages before their code runs. Open source, no account. > [card] [Scan a repository before you merge](/governance/vet/quickstart) > > Vet scans your dependencies for malicious packages, vulnerabilities, and policy violations, locally or in CI. Open source, no account. > [card] [Check one dependency against the malware database](/governance/cloud/malware-analysis) > > Query SafeDep's known malicious packages database for a specific package through Vet. A free cloud service, no account needed. > [card] [Secure your AI coding agent](/ai-security/overview) > > Audit what agents read, write, and run, and discover AI tooling, with open source tools. The SafeDep MCP server adds package vetting for agents; it is a cloud service and needs a SafeDep Cloud account. > [card] [Generate an SBOM](/governance/xbom/quickstart) > > xBom builds a bill of materials that also detects AI libraries and SaaS usage in your code. Open source, no account. > [card] [Make your AI agent SafeDep-fluent](/get-started/safedep-skill) > > Install the SafeDep skill so your coding agent answers and acts from these docs. Open source, no account. ## Add SafeDep Cloud when the need is team-wide Move to SafeDep Cloud when you need to protect more than one developer, apply one policy across your organization, or answer questions from one place: which machines run PMG, what was blocked last week, which projects have critical vulnerabilities. SafeDep Cloud connects the same tools to a tenant that you can see and query. > [!NOTE] > > SafeDep Cloud is the hosted control plane. The open source tools keep working without it, and nothing above stops working when you add it. See the [pricing page](https://safedep.io/pricing) for what each plan includes. > [card] [Cloud Quickstart](/governance/cloud/quickstart) > > Create a tenant, sign in the safedep CLI, connect a source, and run your first query. > [card] [Connect your sources](/governance/cloud/sync) > > Feed GitHub, CI/CD, PMG, and MCP activity into one tenant. > [card] [Endpoint Hub](/governance/cloud/endpoint-hub/overview) > > See package activity and AI tooling across developer machines, CI runners, and agent sandboxes. > [card] [Talk to SafeDep](/governance/cloud/talk-to-safedep) > > Ask your tenant questions in plain English through your AI coding agent. # SafeDep CLI Tools Source: https://docs.safedep.io/get-started/cli-tools Which SafeDep command-line tool to use: Vet, PMG, Gryph, and the safedep CLI, and how they fit together. SafeDep ships several command-line tools. Each one solves a different supply-chain problem, and they run independently, so you install only what you need. This page helps you pick the right tool and points you to its setup guide. ## Which tool do I need? > [card] [Scan code for supply-chain risk](/governance/vet/quickstart) > > Use **Vet** to scan repositories, lockfiles, and SBOMs for malicious packages, known vulnerabilities, and policy violations. It is the engine behind SafeDep's CI/CD scanning. > [card] [Block malicious installs on my machine](/package-security/pmg/quickstart) > > Use **PMG**, a guard around `npm`, `pip`, and other package managers that blocks known-malicious packages before they install. No account or API key required. > [card] [Audit what my AI coding agent does](/ai-security/gryph-overview) > > Use **Gryph** to record every file read, write, and command your AI coding agent runs. It keeps a local audit log you can query. > [card] [Generate a Bill of Materials](/governance/xbom/quickstart) > > Use **xBom** to inventory dependencies plus AI and SaaS usage detected from your source code, as a CycloneDX BOM. > [card] [Deep-scan a package before using it](/package-security/scan/overview) > > Use **safedep package scan** to run an on-demand malware analysis of any package, IDE extension, or GitHub repository. Needs a SafeDep Cloud paid plan or trial. > [card] [Work with SafeDep Cloud](https://github.com/safedep/cli) > > Use **safedep**, the unified CLI for SafeDep Cloud: authentication, on-demand package scanning, endpoint telemetry queries, and AI agent hardening. It is new and still evolving. ## The tools at a glance | Tool | Solves | Needs an account? | Open source | | - | - | - | - | | **Vet** | Detect malicious and vulnerable dependencies in code and CI/CD | No (Cloud optional) | Yes | | **PMG** | Block malicious packages at install time on the dev machine | No | Yes | | **Gryph** | Local audit trail for AI coding agents | No (fully local) | Yes | | **xBom** | Generate a BOM enriched with AI and SaaS usage from source code | No | Yes | | **safedep** | On-demand package scanning, plus managing and querying SafeDep Cloud from the terminal | Yes (SafeDep Cloud) | Yes | > [!NOTE] > > Vet, PMG, and Gryph are free, open source, and work with no SafeDep account. The **safedep** CLI is the client for SafeDep Cloud's hosted features. See [pricing](https://safedep.io/pricing). ## How they relate * **Vet** is the scanning engine. It analyzes dependencies and produces risk reports, queries, and SBOMs. It runs standalone or syncs results to SafeDep Cloud. * **PMG** and **Gryph** are standalone, single-purpose guards. PMG works at package-install time, Gryph around AI coding agents. Neither needs Vet or a SafeDep account. * **safedep** is an emerging unified CLI that brings SafeDep Cloud's workflows (auth, [on-demand package scanning](/package-security/scan/overview), endpoint telemetry, agent hardening) to the terminal. It does not re-implement local scanning: repository analysis stays in Vet, and on-demand package analysis runs in SafeDep Cloud. > [!NOTE] > > These tools have no "v1 to v2" relationship. `safedep` is a new Cloud-focused CLI, not a replacement for `vet`. Vet stays the standalone scanner and the recommended starting point for most users. ## Install Each tool is on the SafeDep Homebrew tap. Vet, PMG, Gryph, and safedep are also published to npm; Vet, PMG, Gryph, and xBom ship as pre-built binaries. The most common installs: > [tab] Homebrew > > ```bash theme={null} > brew install safedep/tap/vet > brew install safedep/tap/pmg > brew install safedep/tap/gryph > brew install safedep/tap/xbom > brew install --cask safedep/tap/cli # the `safedep` command > ``` > [tab] npm > > ```bash theme={null} > npm install -g @safedep/vet > npm install -g @safedep/pmg > npm install -g @safedep/gryph > npm install -g @safedep/cli # the `safedep` command > ``` For every install method, current versions, and the full command surface, see each tool's repository: [Vet](https://github.com/safedep/vet), [PMG](https://github.com/safedep/pmg), [Gryph](https://github.com/safedep/gryph), [safedep](https://github.com/safedep/cli). ## Next steps > [card] [Vet Quickstart](/governance/vet/quickstart) > > Scan your first repository for supply-chain risk. > [card] [PMG Quickstart](/package-security/pmg/quickstart) > > Guard your package installs in minutes. > [card] [Gryph Overview](/ai-security/gryph-overview) > > Set up an audit trail for your AI coding agents. > [card] [xBom Quickstart](/governance/xbom/quickstart) > > Generate an enriched Bill of Materials from your code. > [card] [SafeDep Cloud Quickstart](/governance/cloud/quickstart) > > Onboard to the hosted platform for org-wide visibility. # Install the SafeDep Skill Source: https://docs.safedep.io/get-started/safedep-skill Add the SafeDep Agent Skill to Claude Code or any skills-capable AI coding agent. The [SafeDep skill](https://github.com/safedep/skills) makes your AI coding agent fluent in SafeDep. With the skill installed, the agent answers SafeDep questions from the official sources instead of memory, picks the right SafeDep tool for the task, and helps you install, configure, and use it. Answers stay current because the agent reads the live documentation, not its training data. ## Install > [tab] Claude Code > > Add the marketplace, then install the plugin: > > ```bash theme={null} > /plugin marketplace add safedep/skills > /plugin install safedep-agent-skills@safedep-agent-skills > ``` > > Turn on auto-update in Claude Code settings to stay on the current version. > [tab] Any agent > > Works with any agent that supports Agent Skills: > > ```bash theme={null} > npx skills add safedep/skills > ``` > > Run `npx skills update` to refresh it later. > [tab] Cursor > > Copy the skill into your project: > > ```bash theme={null} > git clone https://github.com/safedep/skills.git > cp -r skills/skills/safedep .cursor/skills/ > ``` > > Cursor discovers skills from `.cursor/skills/` on startup. ## Verify Ask your agent a SafeDep question: ```text theme={null} What does SafeDep PMG do? ``` The agent should load the skill, fetch the answer from docs.safedep.io, and cite the page it used. ## Set up the safedep CLI The skill answers product questions without an account. Questions about *your* data, such as "what did PMG block this week", run through the [safedep CLI](https://github.com/safedep/cli) against your [SafeDep Cloud tenant](/governance/cloud/quickstart). The skill tells the agent to check for the CLI and your sign-in state, and to hand a step back to you when it needs a human: **1. Install the CLI** The [CLI repository](https://github.com/safedep/cli#install) lists more options. ```bash Homebrew theme={null} brew install safedep/tap/cli ``` ```bash npm theme={null} npm install -g @safedep/cli ``` **2. Sign in** Sign-in opens a browser, so the agent asks you to run it. ```bash theme={null} safedep auth login ``` **3. Confirm the tenant** ```bash theme={null} safedep auth status ``` See [Authentication](/governance/cloud/authentication). > [card] [Talk to SafeDep](/governance/cloud/talk-to-safedep) > > Ask your supply chain questions in plain English. > [card] [Agentic Endpoint Investigation](/governance/cloud/endpoint-hub/agentic-investigation) > > Investigate package activity across your endpoints with an agent. # AI Governance Source: https://docs.safedep.io/governance/ai-governance Gain visibility into AI usage across your codebase and developer environments Developers integrate AI SDKs into application code and adopt AI-powered development tools, often without centralized oversight. This creates blind spots for security and compliance teams. `vet` provides two complementary capabilities to address this: 1. **Shadow AI in Code** detects AI and LLM SDK usage in your source code through static analysis and produces a CycloneDX SBOM with AI component evidence. It answers: *what AI services does your application call?* 2. **AI Tools Discovery** scans developer machines and project repositories to inventory AI coding agents, MCP servers, CLI tools, and IDE extensions. It answers: *what AI tools are developers using to write code?* Together, these give security teams a complete picture of AI usage across both the software supply chain and the development environment. > [card] [Shadow AI in Code](/governance/shadow-ai-detection) > > Detect AI SDK usage in source code and generate AI-enriched SBOMs > [card] [AI Tools Discovery](/ai-security/ai-tools-discovery) > > Discover AI coding agents, MCP servers, and IDE extensions on developer machines > [card] [MDM Deployment](/governance/vet/mdm/overview) > > Deploy vet across a fleet and add scheduled visibility tasks # Send Alerts from SafeDep Cloud Source: https://docs.safedep.io/governance/cloud/alerts Turn any safedep query exec result into a Slack, Discord, Teams, PagerDuty, or custom HTTP alert. Any SafeDep Cloud table you can query with `safedep query exec` can drive an alert. The recipe stays the same for every destination: 1. Write the SQL for the events you care about. 2. Run `safedep query exec -o json` to get rows. 3. Format the rows into your destination's payload shape. 4. `POST` to the webhook. The rest of this page is a **worked example**: PMG block events, formatted as a Slack message, sent to a Slack Incoming Webhook, every 5 minutes. Everything below is a stand-in: swap the query, the formatter, or the `curl` target for your own destination. ## Example: Slack alert for PMG blocks Every 5 minutes, a scheduled job queries SafeDep Cloud for packages PMG blocked in the last 5 minutes and posts a Slack message like: ``` 🛡️ PMG blocked 2 package(s) 🟡 COOLDOWN • lodash@0.1.0 • npm Endpoint: MacBook-Pro.local 🔴 MALICIOUS • safedep-test-pkg@0.1.3 • PyPI Endpoint: runnervmkkn4f ``` Both the package and endpoint are clickable: the package links to its SafeDep community report, the endpoint links to its page in SafeDep Cloud. ## Prerequisites You always need: * `safedep` CLI installed and signed in. See the [SafeDep Cloud Quickstart](/governance/cloud/quickstart). For the Slack + Python example below, you also need: * `python3` and `curl` on the host running the script. * A Slack Incoming Webhook URL. See Slack's [Sending messages using incoming webhooks](https://api.slack.com/messaging/webhooks). Confirm the CLI can reach SafeDep Cloud: ```bash theme={null} safedep auth status ``` ## Step 1: Write the query Save the SQL to a file so you can version it in git and rerun it: ```sql blocks.sql theme={null} SELECT package_guard_events.package_ecosystem, package_guard_events.package_name, package_guard_events.package_version, package_guard_events.package_action, package_guard_events.timestamp, endpoints.id, endpoints.identifier FROM package_guard_events JOIN endpoints ON endpoints.id = package_guard_events.invocation_id WHERE package_guard_events.package_action IN ( 'PMG_PACKAGE_ACTION_BLOCKED', 'PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED' ) ORDER BY package_guard_events.timestamp DESC ``` Two things to notice: * **`package_action` filter.** `PMG_PACKAGE_ACTION_BLOCKED` is a malicious-package block. `PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED` is a cooldown-window block (packages held back until they age past your cooldown threshold). * **`JOIN endpoints`.** Each block event was produced by a PMG invocation on some developer machine or CI runner. Joining `endpoints` gives you the endpoint's human-readable name (`endpoints.identifier`) and its ID (`endpoints.id`, used to build the Cloud deep-link). The `ON` clause is a required placeholder: SafeDep Cloud applies the real join from its catalog. See the [SQL reference](/reference/sql-query). Run it once to see the shape of the data: ```bash theme={null} safedep query exec -o json --sql-file blocks.sql --limit 5 ``` Enum columns (like `package_action` and `package_ecosystem`) return numeric ordinals in JSON; the formatter decodes them in Step 2. For the full schema, tables, and enum values, see the [SafeDep Cloud SQL reference](/reference/sql-query). ## Step 2: Format events for Slack Slack's Incoming Webhook takes a JSON payload with a `blocks` array. The script below reads rows from stdin, decodes the enum ordinals, builds one Slack section block per event, and prints the payload on stdout. Save this as `format.py`: ```python format.py theme={null} #!/usr/bin/env python3 """Read safedep query exec JSON on stdin, print a Slack payload on stdout.""" import json, sys from urllib.parse import quote ACTION = {1: ("🔴", "MALICIOUS"), 4: ("🟡", "COOLDOWN")} ECOSYSTEM = { 1: ("ECOSYSTEM_MAVEN", "Maven"), 2: ("ECOSYSTEM_NPM", "npm"), 3: ("ECOSYSTEM_PYPI", "PyPI"), 4: ("ECOSYSTEM_RUBYGEMS", "RubyGems"), 5: ("ECOSYSTEM_NUGET", "NuGet"), 6: ("ECOSYSTEM_CARGO", "Cargo"), 7: ("ECOSYSTEM_GO", "Go"), 8: ("ECOSYSTEM_GITHUB_ACTIONS", "GitHub Actions"), 9: ("ECOSYSTEM_PACKAGIST", "Packagist"), } rows = json.load(sys.stdin).get("rows", []) if not rows: sys.exit(0) # empty stdout, curl skips the POST def section(r): icon, reason = ACTION[r["package_guard_events.package_action"]] eco_enum, eco_label = ECOSYSTEM[r["package_guard_events.package_ecosystem"]] name, version = r["package_guard_events.package_name"], r["package_guard_events.package_version"] ep_id, ep_name = r["endpoints.id"], r["endpoints.identifier"] report = f"https://app.safedep.io/community/packages/{eco_enum}/{quote(name, safe='')}/{quote(version, safe='')}" endpoint = f"https://app.safedep.io/endpoints/{ep_id}" text = (f"{icon} *{reason}* • <{report}|`{name}@{version}`> • {eco_label}" f"\n\nEndpoint: <{endpoint}|`{ep_name}`>") return {"type": "section", "text": {"type": "mrkdwn", "text": text}} payload = {"blocks": [ {"type": "header", "text": {"type": "plain_text", "text": f"🛡️ PMG blocked {len(rows)} package(s)"}}, *[section(r) for r in rows], ]} json.dump(payload, sys.stdout) ``` Add ecosystems you use to the `ECOSYSTEM` dict; nothing else needs to change. ## Step 3: Post to Slack Pipe the query into the formatter and the formatter into `curl`: ```bash theme={null} export SLACK_WEBHOOK_URL='https://hooks.slack.com/services/...' safedep query exec -o json --sql-file blocks.sql --limit 10 \ | python3 format.py \ | curl -sS -X POST -H 'Content-Type: application/json' \ --data @- "$SLACK_WEBHOOK_URL" ``` If there are no matching events, `format.py` exits with empty stdout and `curl` sends nothing. On a successful post, Slack replies with `ok`. > [!NOTE] > > Slack caps a message at 50 blocks, so keep `--limit` around 10. See Slack's [block limits](https://api.slack.com/reference/block-kit/blocks). ## Step 4: Run it on a schedule To make this an alerting pipeline, filter to a rolling window and run periodically. The window and the schedule interval must match so events aren't dropped or duplicated. Save this as `safedep-alerts.sh` next to `format.py`. It's the same query as `blocks.sql`, plus one extra `AND` clause for the time window, an explicit `PATH` (schedulers run with a minimal `PATH`), and a skip when the window has no events (avoids Slack's `invalid_payload` on empty POSTs). ```bash safedep-alerts.sh theme={null} #!/usr/bin/env bash set -euo pipefail # Schedulers run with a minimal PATH. Add the location of `safedep` and `python3`. export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin" cd "$(dirname "$0")" # macOS / BSD date. On Linux: SINCE=$(date -u -d '5 minutes ago' '+%Y-%m-%dT%H:%M:%SZ') SINCE=$(date -u -v-5M '+%Y-%m-%dT%H:%M:%SZ') PAYLOAD=$(safedep query exec -o json --limit 10 --sql " SELECT package_guard_events.package_ecosystem, package_guard_events.package_name, package_guard_events.package_version, package_guard_events.package_action, package_guard_events.timestamp, endpoints.id, endpoints.identifier FROM package_guard_events JOIN endpoints ON endpoints.id = package_guard_events.invocation_id WHERE package_guard_events.package_action IN ( 'PMG_PACKAGE_ACTION_BLOCKED', 'PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED' ) AND package_guard_events.timestamp > '$SINCE' ORDER BY package_guard_events.timestamp DESC " | python3 format.py) [ -n "$PAYLOAD" ] && printf '%s' "$PAYLOAD" | curl -sS -X POST \ -H 'Content-Type: application/json' --data @- "$SLACK_WEBHOOK_URL" ``` Then wire it up with your OS's native scheduler: > [tab] macOS (launchd) > > On macOS, `cron` can't reach the keychain where `safedep auth login` > stores its OAuth token, so scheduled `safedep query exec` calls fail > with `not authenticated`. Use a **launchd user agent** instead: it runs > in your logged-in user session and inherits keychain access. > > Save this as `~/Library/LaunchAgents/io.safedep.alerts.plist`: > > ```xml io.safedep.alerts.plist highlight={20-20} theme={null} > > "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> > > > Label > io.safedep.alerts > > ProgramArguments > > /Users/you/safedep-alerts/safedep-alerts.sh > > > StartInterval > 300 > > EnvironmentVariables > > SLACK_WEBHOOK_URL > PASTE_YOUR_SLACK_WEBHOOK_URL_HERE > > > StandardOutPath > /tmp/safedep-alerts.log > StandardErrorPath > /tmp/safedep-alerts.log > > RunAtLoad > > > > ``` > > Load, verify, and tail the log: > > ```bash theme={null} > launchctl load ~/Library/LaunchAgents/io.safedep.alerts.plist > launchctl list | grep io.safedep.alerts > tail -f /tmp/safedep-alerts.log > ``` > > `RunAtLoad` fires the job immediately. `StartInterval` is in seconds > (`300` = 5 minutes) and must match the `-v-5M` window in the script. > > To stop it: > > ```bash theme={null} > launchctl unload ~/Library/LaunchAgents/io.safedep.alerts.plist > ``` > [tab] Linux (cron) > > On Linux, `cron` works fine for this use case. Install with > `crontab -e` and add: > > ``` > */5 * * * * SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..." /home/you/safedep-alerts/safedep-alerts.sh >> /tmp/safedep-alerts.log 2>&1 > ``` > > Change `date -u -v-5M ...` in the script to > `date -u -d '5 minutes ago' ...` (GNU date syntax). Keep the cron > interval (`*/5`) and the `SINCE` window in the script aligned. > > If you're on a desktop with `gnome-keyring` / `kwallet` and hit > "not authenticated" from cron, either run the script under a > systemd user timer (`systemctl --user enable --now safedep-alerts.timer`) > or unlock the keyring for the cron session. The design is stateless: no cursor file to keep in sync, no drift across restarts. `--limit 10` is set for Slack's 50-block ceiling. Events beyond the limit in a single window are silently dropped. For burstier traffic, raise `--limit` (the CLI allows up to 100) and page through the JSON `next_page_token`, sending one Slack message per page. ## Send to other destinations Only the last two things change: the payload shape (in `format.py`) and the URL (in `curl`). Any JSON-accepting HTTP endpoint works. > [card] [Discord](https://docs.discord.com/developers/resources/webhook#execute-webhook) > > Emit a simple content payload and POST to your channel's webhook URL. > [card] [Microsoft Teams](https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook) > > Create a channel Workflow with a webhook trigger and POST an Adaptive > Card payload to its URL. > [card] [PagerDuty](https://developer.pagerduty.com/docs/events-api-v2-overview) > > Emit an Events API v2 payload and POST to the enqueue endpoint. ## Query other events Swap `blocks.sql` for any question you can ask SafeDep Cloud: * **Insecure bypasses:** filter `package_guard_events` on `event_type = 'PMG_EVENT_TYPE_INSECURE_BYPASS'`. * **Endpoint activity:** `JOIN endpoints` and group by `endpoints.identifier` to see which machines produced the most events. * **Malicious packages across projects:** query `component_malicious_packages` with `is_verified = true`. See the [SafeDep Cloud SQL guide](/reference/sql-query) for the full schema, query syntax, and the paging model. # Authentication Source: https://docs.safedep.io/governance/cloud/authentication How SafeDep Cloud authentication works and how to authenticate the safedep CLI, vet, and CI/CD pipelines Every tool that talks to SafeDep Cloud authenticates with two values: a **tenant domain** (for example `your-company.safedep.io`) and a credential. The credential type depends on which API plane the tool calls: * **Data plane** (`api.safedep.io`): package insights, known-malicious package queries, and sync. Authenticates with an **API key**. * **Control plane** (`cloud.safedep.io`): tenant, policy, and management operations, including SQL queries and [on-demand package scans](/package-security/scan/overview). Authenticates with a **JWT** from an OAuth2 login. Generate API keys at [app.safedep.io/settings/api-keys](https://app.safedep.io/settings/api-keys). For request headers, OAuth2/OIDC endpoints, and rate limits, see the [API reference](/reference/api-introduction). For the full hostname list, see the [endpoints reference](/reference/endpoints). ## safedep CLI `safedep auth login` runs an OAuth2 device flow in your browser, selects a tenant, creates an API key, and stores the credentials in your OS keychain: ```bash theme={null} safedep auth login safedep auth status ``` For non-interactive environments, log in with a static API key instead of the device flow: ```bash theme={null} safedep auth login --api-key --tenant your-company.safedep.io ``` The key is read from `--api-key-value`, stdin (with `--from-stdin`), the `SAFEDEP_API_KEY` environment variable, or an interactive prompt, in that order. Work with multiple tenants using `--profile` and `safedep auth profile list`. See the [CLI command reference](https://github.com/safedep/cli/tree/main/docs/cmd) for all flags. > [!NOTE] > > API-key login covers data-plane commands only. [On-demand package scanning](/package-security/scan/overview) is a control-plane operation: it requires the OAuth2 device-flow session, and an API key cannot submit scans, by design. See [Scanning from CI and AI Agents](/package-security/scan/automation) for the reasoning and what this means for automation. ## vet vet uses an API key for scanning and [sync](/governance/cloud/sync): ```bash theme={null} vet auth configure --tenant your-company.safedep.io ``` You will be prompted to enter the API key. Verify the connection: ```bash theme={null} vet auth verify ``` Control plane commands under `vet cloud` use the OAuth2 device flow instead: ```bash theme={null} vet cloud login --tenant your-company.safedep.io vet cloud whoami ``` To log out, delete the stored credentials: `rm ~/.safedep/vet-auth.yml`. ## CI/CD pipelines Tools read credentials from environment variables, so pipelines need no interactive login: ```bash theme={null} export SAFEDEP_API_KEY=your-api-key export SAFEDEP_TENANT_ID=your-company.safedep.io ``` Store both as CI secrets. Across SafeDep docs, the secret names are `SAFEDEP_CLOUD_API_KEY` and `SAFEDEP_CLOUD_TENANT_DOMAIN`. [vet-action](https://github.com/safedep/vet-action) reads them through its `cloud-key` and `cloud-tenant` inputs instead of environment variables. For working pipeline configurations (GitHub Actions, GitLab, Jenkins, Azure DevOps), see [Cloud Sync](/governance/cloud/sync#sync-from-github-actions). ## Troubleshooting ### Identity not registered ``` ERRO[0001] Failed to execute whoami: rpc error: code = Unauthenticated desc = unauthenticated: Token auth failed: No user: record not found ``` Your identity is not registered with SafeDep Cloud. Sign up first: see the [quickstart](/governance/cloud/quickstart). ### Tenant not found ``` ERRO[0001] Failed to execute query: rpc error: code = Unknown desc = failed to resolve tenant: record not found ``` No tenant is configured. Set it with `vet auth configure --tenant ` or `vet cloud login --tenant `. If you've forgotten your tenant domain, run `vet cloud login` followed by `vet cloud whoami` to list the tenants you can access. ### Checking credentials ```bash theme={null} safedep auth status # safedep CLI session vet auth verify # vet API key vet cloud whoami # vet OAuth identity and tenants ``` > [card] [API Reference](/reference/api-introduction) > > Transport, request headers, OAuth2/OIDC, and rate limits > [card] [Cloud Quickstart](/governance/cloud/quickstart) > > Create a tenant and log in with the safedep CLI > [card] [Cloud Sync](/governance/cloud/sync) > > Send data to your tenant from vet, PMG, and endpoint scans > [card] [API Specification](https://buf.build/safedep/api) > > Canonical gRPC/ConnectRPC schemas and generated SDKs # Ingest Package Guard Events to CrowdStrike SIEM Source: https://docs.safedep.io/governance/cloud/crowdstrike-siem Forward PMG malicious-package and dependency-cooldown block events from SafeDep Cloud to a CrowdStrike SIEM HEC endpoint. This guide shows how to ingest SafeDep endpoint [Package Guard](/governance/cloud/endpoint-hub/package-guard) **block events** into CrowdStrike SIEM over [HEC (HTTP Event Collector)](https://developer.crowdstrike.com/ngsiem/data-ingestion/). Two block events are ingested: * Malicious package blocks (`PMG_PACKAGE_ACTION_BLOCKED`) * Dependency cooldown blocks (`PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED`) ## Prerequisites * ![SafeDep](https://img.logo.dev/safedep.io?token=pk_JMA7_TgCSx--JsncHKu2cA) A SafeDep Cloud tenant on the **Enterprise** plan. See [pricing](https://safedep.io/pricing). See the [SafeDep Cloud quickstart](/governance/cloud/quickstart). * PMG connected to SafeDep Cloud and syncing to your tenant. See [Enable cloud sync](/governance/cloud/endpoint-hub/package-guard#enable-cloud-sync). * The [safedep CLI](/get-started/cli-tools) authenticated to your tenant. See [Authentication](/governance/cloud/authentication). * ![CrowdStrike](https://img.logo.dev/crowdstrike.com?token=pk_JMA7_TgCSx--JsncHKu2cA) CrowdStrike SIEM (Falcon LogScale or Next-Gen SIEM) with an [HEC](https://developer.crowdstrike.com/ngsiem/data-ingestion/) endpoint. For Next-Gen SIEM, set up a HEC data connector. * Python 3.8 or later. ### Keys and URLs Collect these before you start: * `SAFEDEP_TOKEN`: a SafeDep Cloud API token. Get it with the safedep CLI: ```bash theme={null} safedep auth login # oauth login, then export SAFEDEP_TOKEN=$(safedep auth token) ``` * `SAFEDEP_TENANT_ID`: your SafeDep tenant domain, for example `your-company.safedep.io`. * `CROWDSTRIKE_HEC_URL`: your CrowdStrike HEC ingest URL, for example `https:///services/collector`. * `CROWDSTRIKE_HEC_TOKEN`: your CrowdStrike HEC token. ## Run the ingest script Download the ingest script. [Review it](https://github.com/safedep/docs/blob/main/downloads/ingest-sd-ngsiem.py) before you run it. ```bash theme={null} curl -O https://raw.githubusercontent.com/safedep/docs/main/downloads/ingest-sd-ngsiem.py ``` Set the environment variables and run the script: ```bash theme={null} export SAFEDEP_TOKEN=$(safedep auth token) export SAFEDEP_TENANT_ID=your-company.safedep.io export CROWDSTRIKE_HEC_URL=https:///services/collector export CROWDSTRIKE_HEC_TOKEN= python3 ingest-sd-ngsiem.py ``` The script polls the SafeDep Cloud API and sends new block events to CrowdStrike. Output: ```bash theme={null} 2026-09-17 13:30:19,947 starting: poll every 300s, backfill 24h, target https:///services/collector 2026-09-17 13:30:19,947 cycle: polling events since 2026-09-16T08:00:19.947653Z 2026-09-17 13:30:21,210 cycle: 8 event(s) sent to CrowdStrike HEC, next poll in 300s ``` ## Ingested Payload Each block event is sent to CrowdStrike as one HEC record, pretty-printed here but sent as a single line. ### Malicious package block ```json theme={null} { "event": { "eventId": "d790c54c-37b2-478c-9cfb-64c417325c45", "toolName": "pmg", "toolVersion": "0.29.0", "timestamp": "2026-09-16T15:58:04.594981Z", "endpointId": "01EXAMPLEENDPOINTID000000", "invocationId": "00000000-0000-0000-0000-000000000000", "endpointName": "web-01", "pmgEvent": { "eventType": "PMG_EVENT_TYPE_PACKAGE_DECISION", "packageDecision": { "packageVersion": { "package": { "ecosystem": "ECOSYSTEM_PYPI", "name": "safedep-test-pkg" }, "version": "0.0.4" }, "action": "PMG_PACKAGE_ACTION_BLOCKED", "analysisId": "01EXAMPLEANALYSISID0000000", "isMalware": true, "isVerified": true } } }, "sourcetype": "safedep:package-guard", "time": 1789574284.594981 } ``` ### Dependency cooldown block Cooldown events carry a `cooldown` object instead of the malware fields: ```json theme={null} { "event": { "eventId": "e6b01964-082e-40f8-a486-534c5a6013c1", "toolName": "pmg", "toolVersion": "0.24.2", "timestamp": "2026-09-10T11:12:55.105968Z", "endpointId": "01EXAMPLEENDPOINTID000001", "invocationId": "00000000-0000-0000-0000-000000000000", "endpointName": "web-02", "pmgEvent": { "eventType": "PMG_EVENT_TYPE_PACKAGE_DECISION", "packageDecision": { "packageVersion": { "package": { "ecosystem": "ECOSYSTEM_NPM", "name": "some-new-package" }, "version": "0.1.0" }, "action": "PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED", "cooldown": { "publishDate": "2026-09-09T23:21:08.303Z", "cooldownDays": 3, "daysRemaining": 3 } } } }, "sourcetype": "safedep:package-guard", "time": 1789031575.105968 } ``` ## Notes * **Token.** The token is short-lived. For a long run, refresh `SAFEDEP_TOKEN` with `safedep auth token` again before it expires. * **Cursor.** The position is saved to `cursor.json` next to the script, so a restart resumes where it stopped. Delete `cursor.json` to re-read from the backfill window. ## Environment variables | Variable | Required | Default | Description | | - | - | - | - | | `SAFEDEP_TOKEN` | yes | - | SafeDep OAuth token. Get it with `safedep auth token`. | | `SAFEDEP_TENANT_ID` | yes | - | Tenant domain, e.g. `your-company.safedep.io`. | | `SAFEDEP_CLOUD_URL` | no | `https://cloud.safedep.io` | SafeDep Cloud base URL. | | `CROWDSTRIKE_HEC_URL` | no | (unset) | HEC collector URL, e.g. `https:///services/collector`. Unset means log only. | | `CROWDSTRIKE_HEC_TOKEN` | no | (unset) | HEC ingest token. Required when `CROWDSTRIKE_HEC_URL` is set. | | `POLL_INTERVAL` | no | `300` | Seconds between poll cycles. | | `BACKFILL_HOURS` | no | `24` | First-run window in hours. | # Agentic Endpoint Investigation Source: https://docs.safedep.io/governance/cloud/endpoint-hub/agentic-investigation Investigate package activity and AI tooling across your developer endpoints with an AI coding agent and the safedep CLI. Your endpoints report their activity to [Endpoint Hub](/governance/cloud/endpoint-hub/overview): every package install [PMG](/package-security/pmg/overview) allowed or blocked, and the AI tooling `vet` discovered. When something needs investigation, you do not write queries yourself. You ask your AI coding agent. The agent turns your question into a tenant-scoped [SafeDep Cloud SQL](/reference/sql-query) query, runs it with the `safedep` CLI, and reports what it found. This guide gives you investigation playbooks: the question to ask, what the agent runs, and how to verify the answer. ## Before you start * Endpoints that sync data to your tenant. Set up [Package Guard sync](/governance/cloud/endpoint-hub/package-guard) for package events, and optionally [Inventory](/governance/cloud/endpoint-hub/inventory) for AI tooling. * The `safedep` CLI, signed in with `safedep auth login`. See [Install the safedep CLI](/governance/cloud/quickstart#install-the-safedep-cli) and [Authentication](/governance/cloud/authentication). * An AI coding agent with the [SafeDep skill](/get-started/safedep-skill) installed. > [!NOTE] > > The agent cannot sign in for you. Sign-in opens a browser and needs a human. If the agent reports an authentication error, run `safedep auth login` yourself, confirm with `safedep auth status`, and tell the agent to continue. ## How the agent investigates The agent works in a loop: 1. It discovers the queryable tables with `safedep query schema get`. The schema describes the tables, their columns, the allowed joins, and the query rules. 2. It writes a query and runs it with `safedep query exec`. 3. If the server rejects the query, the error says why. The agent corrects the query and retries. Every query is scoped to your authenticated tenant. The agent reads data; it cannot change it. Each answer traces back to a real query, so you can ask the agent to show the SQL it ran. The query language has no relative dates, so for questions like "in the last 30 days" the agent computes the cutoff timestamp from today's date. The playbooks below include the SQL the agent runs, collapsed by default since you do not need it to investigate. Expand it when you want to see or verify the details. For the query language, the full table list, and the query rules, see [SafeDep Cloud SQL](/reference/sql-query). ## Playbooks ### Check exposure to a compromised package A package you use was compromised upstream. Find out if any endpoint installed it. ```text theme={null} The npm package eslint-config-prettier was compromised. Was it installed on any of our endpoints in the last 30 days? Which versions, and was it blocked or allowed? ``` The agent runs a query like this: > [accordion] Show the SQL the agent runs > > ```sql theme={null} > SELECT endpoints.identifier, package_guard_events.package_version, > package_guard_events.package_action, package_guard_events.timestamp > FROM package_guard_events > JOIN endpoints ON endpoints.id = package_guard_events.invocation_id > WHERE package_guard_events.package_name = 'eslint-config-prettier' > AND package_guard_events.timestamp >= '2026-07-11T00:00:00Z' > ORDER BY package_guard_events.timestamp DESC > ``` Each row is one decision on one endpoint. `PMG_PACKAGE_ACTION_BLOCKED` means PMG stopped the install. `PMG_PACKAGE_ACTION_CONFIRMED` means a person approved it after a warning. An allowed install of a compromised version is your incident to respond to. ### Review what was blocked, and where ```text theme={null} What did PMG block across our endpoints this month? Group it by endpoint. ``` The agent filters `package_guard_events` on both block actions, bounds the time range to the month, and joins to `endpoints`: > [accordion] Show the SQL the agent runs > > ```sql theme={null} > SELECT endpoints.identifier, package_guard_events.package_name, > package_guard_events.package_ecosystem, package_guard_events.package_action, > package_guard_events.timestamp > FROM package_guard_events > JOIN endpoints ON endpoints.id = package_guard_events.invocation_id > WHERE package_guard_events.package_action IN ('PMG_PACKAGE_ACTION_BLOCKED', 'PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED') > AND package_guard_events.timestamp >= '2026-08-01T00:00:00Z' > ORDER BY package_guard_events.timestamp DESC > ``` `PMG_PACKAGE_ACTION_BLOCKED` is a block on a known malicious package. `PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED` is a block on a package too new to trust under the cooldown policy. Both stopped an install. A block on one endpoint is often the first visible event of a campaign. Follow up with the exposure playbook above for the same package across the fleet. ### Audit protection bypasses PMG records when a person bypasses protection. Review these regularly. ```text theme={null} Did anyone bypass PMG protection in the last two weeks? Show the endpoint, the package, and when it happened. ``` > [accordion] Show the SQL the agent runs > > ```sql theme={null} > SELECT endpoints.identifier, package_guard_events.package_name, > package_guard_events.timestamp > FROM package_guard_events > JOIN endpoints ON endpoints.id = package_guard_events.invocation_id > WHERE package_guard_events.event_type = 'PMG_EVENT_TYPE_INSECURE_BYPASS' > AND package_guard_events.timestamp >= '2026-07-27T00:00:00Z' > ORDER BY package_guard_events.timestamp DESC > ``` The related `PMG_EVENT_TYPE_SANDBOX_OVERRIDE` event records sandbox policy overrides. Ask the agent to check both. ### Find endpoints that stopped reporting An endpoint that stopped syncing is a blind spot: it still installs packages, and you no longer see them. ```text theme={null} Which endpoints have not synced in the last 30 days? ``` > [accordion] Show the SQL the agent runs > > ```sql theme={null} > SELECT endpoints.identifier, endpoints.endpoint_type, endpoints.last_sync_at > FROM endpoints > WHERE endpoints.last_sync_at < '2026-07-11T00:00:00Z' > ORDER BY endpoints.last_sync_at ASC > ``` An endpoint can stop reporting for good reasons, such as a decommissioned laptop. Confirm before you treat it as an incident. ### Get a current verdict on a suspect package Package Guard events record the decision PMG made at install time. Verdicts change: a package that passed last month may be known malware today. To judge a package during an investigation, get a current verdict. Two paths exist, and the agent should take the fast one first: ```text theme={null} An endpoint installed left-pad-utils 2.1.0 from npm last week. Is it safe? Check the known malicious packages database first. Run a full scan only if I ask for a deep dive. ``` The fast path checks SafeDep's [known malicious packages database](/governance/cloud/malware-analysis). It is free and answers in milliseconds: ```bash theme={null} vet scan --purl pkg:npm/left-pad-utils@2.1.0 --malware-query ``` The slow path is an [on-demand package scan](/package-security/scan/overview): a full malware analysis of the exact version. It takes minutes and draws down your plan's scan allowance. Use it when the database has no verdict and the package deserves a deep dive: ```bash theme={null} safedep package scan run "pkg:npm/left-pad-utils@2.1.0" -o json ``` The scan returns `malware`, `benign`, or `inconclusive`, with evidence. Treat `inconclusive` as needs-review. See [Scanning from CI and AI Agents](/package-security/scan/automation) for the scan contract. ### See what AI tooling runs on an endpoint If your endpoints also run [Inventory](/governance/cloud/endpoint-hub/inventory) scans, the same loop answers questions about AI tooling: ```text theme={null} Which MCP servers were observed on our endpoints, and on which machines? ``` > [accordion] Show the SQL the agent runs > > ```sql theme={null} > SELECT inventory_events.item_identity, endpoints.identifier > FROM inventory_events > JOIN endpoints ON endpoints.id = inventory_events.app > WHERE inventory_events.item_kind = 'INVENTORY_ITEM_KIND_MCP_SERVER' > ORDER BY inventory_events.item_identity > ``` Other item kinds cover coding agents, IDE extensions, and Agent Skills. ## Ask narrow questions Results return one page at a time, up to 100 rows. Do not ask the agent to dump a table and search the output. Ask a narrow question, and let the agent filter server-side: a package name, a time range, one endpoint, one event type. When you need totals, ask for counts; the agent aggregates with `GROUP BY` instead of paging through rows. ## Verify the answer Every agent answer maps to a query you can run yourself: 1. Ask the agent to show the SQL it ran. 2. Run it: `safedep query exec --sql ""`. 3. Compare the result with the agent's summary. If the agent's answer looks wrong, the query is the first place to look. A missing time bound or a wrong enum value changes the result silently. > [card] [SafeDep Cloud SQL](/reference/sql-query) > > The query language, full table list, and query rules. > [card] [Install the SafeDep Skill](/get-started/safedep-skill) > > Set up your AI coding agent for SafeDep. > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > Sync package events from your endpoints. > [card] [Talk to SafeDep](/governance/cloud/talk-to-safedep) > > Ask your tenant questions in plain English. # Review Package Blocks Across CI Pipelines Source: https://docs.safedep.io/governance/cloud/endpoint-hub/ci-package-blocks See every package that PMG blocked or held back on your CI runners, across all repositories, in SafeDep Cloud. PMG in CI blocks a malicious package and fails the job. One failed job shows one block. SafeDep Cloud shows the blocks from every pipeline in one place. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ## Prerequisites * PMG runs in your pipelines and syncs to your tenant: * In GitHub Actions, set the `api-key` and `tenant-id` inputs of the PMG action. See [PMG in GitHub Actions](/package-security/pmg/github-actions). * In other CI systems, run `pmg cloud sync` at the end of the job. See [Package Guard](/governance/cloud/endpoint-hub/package-guard#manual-sync). To find these jobs later, set `PMG_CLOUD_ENDPOINT_ID` as shown in [Other CI systems](#other-ci-systems). ## Review one pipeline **1. Open the endpoint list** Sign in to [app.safedep.io](https://app.safedep.io) and select **Endpoints**. In GitHub Actions, each repository is one endpoint by default. Set the `endpoint-id` input of the PMG action to change it. **2. Open the endpoint** Select the endpoint, then select **Package Events**. Each session shows the install command and its outcome, such as **Blocked** or **Success**. Each package row shows its action, such as **Blocked** or **Cooldown**. **3. Filter the events** Use **Package action** or **Session outcome** to show only the blocks. ![Package Events of a GitHub Actions endpoint in SafeDep Cloud with blocked, cooldown, and successful installs](https://mintcdn.com/safedep/OcmrdF-YkbEncxxA/images/cloud/ci-runner-package-events.png?fit=max\&auto=format\&n=OcmrdF-YkbEncxxA\&q=85\&s=9e88bf4f14de80062afd60bce2c98d11) ## Review all pipelines PMG records the CI provider for GitHub Actions jobs. This query lists the malicious package blocks and the cooldown holds in all GitHub Actions jobs: ```sql theme={null} SELECT endpoints.identifier, package_guard_events.package_name, package_guard_events.package_action, package_guard_events.timestamp FROM package_guard_events JOIN endpoints ON endpoints.id = package_guard_events.invocation_id WHERE package_guard_events.ci_provider = 'ENDPOINT_CI_PROVIDER_GITHUB_ACTIONS' AND package_guard_events.package_action IN ( 'PMG_PACKAGE_ACTION_BLOCKED', 'PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED') ORDER BY package_guard_events.timestamp DESC ``` Run it from **Query** in the sidebar, or with `safedep query exec --sql-file`. ![SafeDep Cloud query console with the package blocks in all GitHub Actions jobs](https://mintcdn.com/safedep/OcmrdF-YkbEncxxA/images/cloud/sql-ci-blocks.png?fit=max\&auto=format\&n=OcmrdF-YkbEncxxA\&q=85\&s=1a9df428f968f3a2e71ca8cb0be9d724) The console shows enum columns as numbers. In `package_action`, `1` is a malicious package block and `4` is a cooldown hold. ### Other CI systems PMG does not record the CI provider for other CI systems. To group their events, give each CI endpoint an ID with a common prefix. In the job, set `PMG_CLOUD_ENDPOINT_ID`, for example to `ci-jenkins-payments`. Then filter on the prefix: ```sql theme={null} SELECT endpoints.identifier, package_guard_events.package_name, package_guard_events.package_action, package_guard_events.timestamp FROM package_guard_events JOIN endpoints ON endpoints.id = package_guard_events.invocation_id WHERE endpoints.identifier LIKE 'ci-%' AND package_guard_events.package_action IN ( 'PMG_PACKAGE_ACTION_BLOCKED', 'PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED') ORDER BY package_guard_events.timestamp DESC ``` ## Next steps > [card] [Send Alerts from SafeDep Cloud](/governance/cloud/alerts) > > Send each new block to Slack or a webhook. > [card] [Find Where a Malicious Package Reached Your Organization](/governance/cloud/endpoint-hub/find-malicious-package) > > Find the endpoints and projects that a malicious package reached. # Find Where a Malicious Package Reached Your Organization Source: https://docs.safedep.io/governance/cloud/endpoint-hub/find-malicious-package Find each endpoint where PMG blocked a malicious package, and each project that depends on it, in SafeDep Cloud. When SafeDep flags a package as malicious, find the endpoints that tried to install it, the endpoints that installed it, and the projects that depend on it. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ## Prerequisites * PMG syncs to your tenant from developer machines and CI runners. See [Package Guard](/governance/cloud/endpoint-hub/package-guard). * Vet scans sync to your tenant. See [Cloud Sync](/governance/cloud/sync). * To run the queries from a terminal, sign in to the `safedep` CLI. See the [SafeDep Cloud Quickstart](/governance/cloud/quickstart). ## See recent blocks **1. Open the endpoint list** Sign in to [app.safedep.io](https://app.safedep.io) and select **Endpoints**. **2. Show only endpoints with a block** Turn on **Has Blocked Events**. The **Live Activity** panel shows recent events, blocks included, and the endpoint of each event. **3. Open an endpoint** Select the endpoint, then select **Package Events**. Each blocked package has a **Report** link to the analysis of the package. ![Endpoint list in SafeDep Cloud with the number of blocks on each endpoint and a Live Activity panel of recent events](https://mintcdn.com/safedep/OcmrdF-YkbEncxxA/images/cloud/endpoint-hub.png?fit=max\&auto=format\&n=OcmrdF-YkbEncxxA\&q=85\&s=ccd86b486aa6c8e142cf9654f9379faf) ## Find every endpoint that tried to install the package Select **Query** in the sidebar and run this query. Replace `ECOSYSTEM_PYPI` and `reqeusts` with the ecosystem and the name of the package. The query also finds the installs that a user confirmed after PMG flagged the package. ```sql theme={null} SELECT endpoints.identifier, package_guard_events.package_action, package_guard_events.package_version, package_guard_events.timestamp FROM package_guard_events JOIN endpoints ON endpoints.id = package_guard_events.invocation_id WHERE package_guard_events.package_action IN ( 'PMG_PACKAGE_ACTION_BLOCKED', 'PMG_PACKAGE_ACTION_CONFIRMED') AND package_guard_events.package_ecosystem = 'ECOSYSTEM_PYPI' AND package_guard_events.package_name = 'reqeusts' ORDER BY package_guard_events.timestamp DESC ``` To run the same query from a terminal, save it as `blocked.sql` and run `safedep query exec --sql-file blocked.sql`. ![SafeDep Cloud query console with the endpoints that tried to install one package](https://mintcdn.com/safedep/OcmrdF-YkbEncxxA/images/cloud/sql-blocked-packages.png?fit=max\&auto=format\&n=OcmrdF-YkbEncxxA\&q=85\&s=24d7c0e7735d165eb8ef55147a79c37f) In the `package_action` column, `1` is a block and `2` is an install that a user confirmed. PMG records an event when it blocks, holds back, or trusts a package, and when a user confirms the install of a flagged package. It does not record an event for each package that it allows. An install that happened before SafeDep flagged the package does not show here. To find those, check your projects. ## Find every project that depends on the package Filter on the ecosystem, the name, and each malicious version. A name alone also matches safe versions, and packages with the same name in other ecosystems. ```sql theme={null} SELECT projects.name, packages.name, packages.version FROM packages JOIN boms ON boms.id = packages.bom_id JOIN project_versions ON project_versions.id = boms.project_version_id JOIN projects ON projects.id = project_versions.project_id WHERE packages.ecosystem = 'ECOSYSTEM_PYPI' AND packages.name = 'reqeusts' AND packages.version IN ('2.32.6') ``` The query returns each project whose latest Vet scan has the package in its dependency tree. For the schema and more examples, see the [SQL query guide](/reference/sql-query). ## Next steps > [card] [Send Alerts from SafeDep Cloud](/governance/cloud/alerts) > > Send each new block to Slack or a webhook. > [card] [Review Package Blocks Across CI Pipelines](/governance/cloud/endpoint-hub/ci-package-blocks) > > See what PMG blocked on your CI runners. # Endpoint Inventory Source: https://docs.safedep.io/governance/cloud/endpoint-hub/inventory View AI tools, Agent Skills, MCP servers, and coding agents discovered on your endpoints in SafeDep Cloud Endpoint inventory shows what AI tooling is active across your endpoints (developer machines, CI runners, agent sandboxes). It is powered by `vet endpoint scan`, which runs locally to discover AI tools, Agent Skills, MCP servers, coding agents, and IDE extensions, then delivers them to SafeDep Cloud when credentials are configured. [Endpoint Inventory for AI Tools, Skills & CLI Utilities](https://www.youtube.com/embed/d_qsR2RR6eY) ## Prerequisites * `vet` [installed](/governance/vet/quickstart) * A SafeDep Cloud account with an API key and tenant domain (see [Cloud quickstart](/governance/cloud/quickstart)) ## Enable inventory sync **1. Configure SafeDep credentials** Run the interactive auth setup, passing your tenant domain as a flag: ```bash theme={null} vet auth configure --tenant ``` The tenant domain looks like `your-team.your-org.safedep.io` and is shown on your SafeDep Cloud settings page. You will be prompted to enter your **API key** interactively. Alternatively, set environment variables: ```bash theme={null} export SAFEDEP_API_KEY= export SAFEDEP_TENANT_ID= # e.g. your-team.your-org.safedep.io ``` Verify credentials are working: ```bash theme={null} vet auth verify ``` A successful response means Vet can reach SafeDep Cloud. If verification fails, check that your API key and tenant domain are correct. **2. Run an endpoint scan** ```bash theme={null} vet endpoint scan ``` ```text Example output theme={null} Discovered 6 item(s) across 3 app(s) ┌────────────────┬──────────────────┬───────────────┬─────────┬──────────────────────────────────────────────────┐ │ TYPE │ NAME │ APP │ SCOPE │ DETAIL │ ├────────────────┼──────────────────┼───────────────┼─────────┼──────────────────────────────────────────────────┤ │ Coding Agent │ Claude Code │ Claude Code │ System │ /home/user/.claude/settings.json │ │ MCP Server │ my-server │ Claude Code │ System │ stdio: npx my-server │ │ CLI Tool │ Claude Code │ Claude Code │ System │ /usr/local/bin/claude v2.1.0 │ │ Coding Agent │ Cursor │ Cursor │ System │ /home/user/.cursor │ │ Agent Skill │ golang-pro │ claude-code │ Project │ /home/user/project/.claude/skills/golang-pro │ │ Agent Skill │ security-review │ Global Skills │ System │ /home/user/.agents/skills/security-review │ └────────────────┴──────────────────┴───────────────┴─────────┴──────────────────────────────────────────────────┘ ``` `vet endpoint scan` delivers discovered items to SafeDep Cloud in the background. The command waits up to 30 seconds for delivery; if the timeout is reached, any undelivered items are retried automatically on the next run. > [!TIP] > > Without credentials, `vet endpoint scan` still runs and prints the local table. No data leaves the machine. **3. View inventory in SafeDep Cloud** Open [app.safedep.io](https://app.safedep.io), select **Endpoint Hub** in the sidebar, and pick your endpoint. Your endpoint appears in the list by your machine's hostname. Open the **Inventory** tab to see discovered items. ![SafeDep Cloud Endpoint Hub Inventory tab](https://mintcdn.com/safedep/ogk6d7nSNW0qSm9p/images/endpoint-hub/endpoint-hub-inventory.png?fit=max\&auto=format\&n=ogk6d7nSNW0qSm9p\&q=85\&s=1f28a91557913fead366c0f6e01f8bf3) > [!TIP] > > If your endpoint is not listed, confirm credentials with `vet auth verify` and re-run the scan. ## Common scan options * **Project scope only:** `vet endpoint scan --scope project -D /path/to/repo`: limits discovery to project-level configs (e.g. `.mcp.json`, `CLAUDE.md`). * **System scope only:** `vet endpoint scan --scope system`: skips project configs; faster on large repositories. * **AI tools only:** `vet endpoint scan --kind ai-tool`: discovers coding agents, MCP servers, CLI tools, IDE extensions, and project config files; skips skill directories. * **Agent skills only:** `vet endpoint scan --kind agent-skill`: discovers agent skill directories only. * **JSON report:** `vet endpoint scan --report-json inventory.json`: writes a local file in addition to syncing. * **CI/CD:** Set `SAFEDEP_API_KEY` and `SAFEDEP_TENANT_ID` as pipeline secrets. Ephemeral runners (e.g. GitHub-hosted) register as a new endpoint per run; self-hosted runners on a persistent host update the same endpoint. * **Suppress table output:** `vet endpoint scan --silent`: runs and syncs without printing the local table. ## Review AI tools across your team Open an endpoint in **Endpoints** and select **AI Tools**. The tab lists the coding agents, MCP servers, and other AI tools from the last scan. ![AI Tools tab of an endpoint in SafeDep Cloud with two coding agents and three MCP servers](https://mintcdn.com/safedep/OcmrdF-YkbEncxxA/images/cloud/endpoint-ai-tools.png?fit=max\&auto=format\&n=OcmrdF-YkbEncxxA\&q=85\&s=7ce610286f434292b23b3a48a25e1791) To see one kind of tool on all endpoints, run a query. This query lists the MCP servers: ```sql theme={null} SELECT endpoints.identifier, inventory_events.app, inventory_events.item_identity FROM inventory_events JOIN endpoints ON endpoints.id = inventory_events.invocation_id WHERE inventory_events.item_kind = 'INVENTORY_ITEM_KIND_MCP_SERVER' ``` > [!NOTE] > > Endpoint Hub and SQL queries need the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ## Next steps > [card] [AI Tools Discovery](/ai-security/ai-tools-discovery) > > Learn what gets discovered and how scopes work > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > Track package installs across your endpoints # Endpoint Scan Catalog Source: https://docs.safedep.io/governance/cloud/endpoint-hub/inventory-catalog Catalog of all inventory items collected from endpoint scans ## Scanner Kinds `vet endpoint scan` runs two independent scanners, each covering a different class of signals. | Kind | What it finds | | - | - | | `ai-tool` | MCP servers, coding agents, CLI tools, IDE extensions, project config files | | `agent-skill` | Agent skill directories inside well-known skill paths | ## Item Types Each discovered item is classified as one of the following types: | Type | Description | | - | - | | `mcp_server` | Model Context Protocol server entry found in a config file | | `coding_agent` | Coding agent detected via a system-level config directory or installed binary | | `cli_tool` | AI CLI binary found on `$PATH`, version-verified by executing with a version flag | | `ai_extension` | AI-related IDE extension detected from installed extension manifests | | `project_config` | AI tool instruction or config file found in a project repository | | `agent_skill` | Skill subdirectory found inside a well-known agent skills path | ## Scopes | Scope | Base path | | - | - | | `system` | User home directory (global configs and binaries) | | `project` | Project directory (default: cwd, override with `-D`) | ## What Gets Scanned ### MCP Server Config Files MCP server entries are read from JSON config files at well-known paths for each supported application. > [accordion] Claude Code > > **System scope** > > | Path | > | - | > | `~/.claude/settings.json` | > | `~/.claude/projects/*/settings.json` | > | `~/.claude.json` | > | `~/.claude/plugins/cache/**/.mcp.json` | > > **Project scope** > > | Path | > | - | > | `/.mcp.json` | > | `/.claude/settings.json` | > [accordion] Cursor > > **System scope** > > | Path | > | - | > | `~/.cursor/mcp.json` | > > **Project scope** > > | Path | > | - | > | `/.cursor/mcp.json` | > [accordion] Windsurf > > **System scope only** > > | Path | > | - | > | `~/.codeium/windsurf/mcp_config.json` | > [accordion] Antigravity / Google Gemini CLI > > **System scope** > > | Path | > | - | > | `~/.gemini/antigravity/mcp_config.json` | > [accordion] VS Code > > **System scope** > > | Platform | Path | > | - | - | > | Linux | `~/.config/Code/User/mcp.json` | > | macOS | `~/Library/Application Support/Code/User/mcp.json` | > | Windows | `%APPDATA%\Code\User\mcp.json` | > > **Project scope** > > | Path | > | - | > | `/.vscode/mcp.json` | > | `/.vscode/mcpservers.json` | > | `/.vscode/mcp_config.json` | ### Project Config Files Project-level instruction and rules files are reported as `project_config` items. | Application | Path | | - | - | | Claude Code | `/CLAUDE.md` | | Cursor | `/.cursorrules` | | Cursor | `/.cursor/rules/*` | ### CLI Tools AI CLI binaries are discovered by searching `$PATH` for known names. Each candidate is executed with a version flag and its output is matched against a known pattern to confirm it is the expected tool. | Tool | Binary(s) | Verification | | - | - | - | | Claude Code CLI | `claude` | Output matches `claude v` | | Cursor CLI | `cursor` | Semver on first line of `--version` | | Windsurf CLI | `windsurf` | Semver on first line of `--version` | | Antigravity / Gemini CLI | `antigravity`, `ag-kit` | Semver on first line of `--version` | | VS Code CLI | `code` | Semver on first line of `--version` | | Aider | `aider` | Output contains `aider v` | | GitHub Copilot | `gh` | `github/gh-copilot` in `gh extension list` | | Amazon Q | `q`, `amazon-q` | Output contains `amazon` or `aws` + semver | ### IDE Extensions Extension manifests are read from the following directories for each supported IDE distribution. Entries are matched against a curated list of known AI extension identifiers. **Extension directories scanned:** ``` ~/.vscode/extensions/ ~/.vscode-oss/extensions/ ~/.cursor/extensions/ ~/.windsurf/extensions/ ~/.antigravity/extensions/ ``` **Recognized AI extensions:** | Extension ID | Tool | | - | - | | `github.copilot` | GitHub Copilot | | `github.copilot-chat` | GitHub Copilot Chat | | `sourcegraph.cody-ai` | Cody | | `continue.continue` | Continue | | `tabnine.tabnine-vscode` | Tabnine | | `amazonwebservices.amazon-q-vscode` | Amazon Q | | `saoudrizwan.claude-dev` | Cline | | `rooveterinaryinc.roo-cline` | Roo Code | | `codeium.codeium` | Codeium | | `supermaven.supermaven` | Supermaven | ### Agent Skills The `agent-skill` scanner checks for skill subdirectories inside well-known paths for each supported agent. Every subdirectory found is reported as one `agent_skill` item. > [accordion] System-scope skill paths > > Resolved relative to the user home directory (`~/`). > > | Agent(s) | Path | > | - | - | > | amp, kimi-cli, replit, universal | `.config/agents/skills` | > | cline, warp | `.agents/skills` | > | antigravity | `.gemini/antigravity/skills` | > | augment | `.augment/skills` | > | bob | `.bob/skills` | > | claude | `.claude/skills` | > | codebuddy | `.codebuddy/skills` | > | commandcode | `.commandcode/skills` | > | crush | `.config/crush/skills` | > | goose | `.config/goose/skills` | > | opencode | `.config/opencode/skills` | > | continue | `.continue/skills` | > | copilot | `.copilot/skills` | > | codex | `.codex/skills` | > | cursor | `.cursor/skills` | > | deepagents | `.deepagents/agent/skills` | > | factory | `.factory/skills` | > | firebender | `.firebender/skills` | > | gemini | `.gemini/skills` | > | iflow | `.iflow/skills` | > | junie | `.junie/skills` | > | kilocode | `.kilocode/skills` | > | kiro | `.kiro/skills` | > | kode | `.kode/skills` | > | mcpjam | `.mcpjam/skills` | > | mux | `.mux/skills` | > | openclaw | `.openclaw/skills` | > | openhands | `.openhands/skills` | > | pi | `.pi/agent/skills` | > | qoder | `.qoder/skills` | > | qwen | `.qwen/skills` | > | roo | `.roo/skills` | > | snowflake cortex | `.snowflake/cortex/skills` | > | trae | `.trae/skills` | > | trae-cn | `.trae-cn/skills` | > | vibe | `.vibe/skills` | > | windsurf | `.codeium/windsurf/skills` | > | zencoder | `.zencoder/skills` | > | neovate | `.neovate/skills` | > | pochi | `.pochi/skills` | > | adal | `.adal/skills` | > | Claude plugins | `.claude/plugins/cache////skills/` | > | Claude marketplace | `.claude/plugins/marketplaces//plugins/

/skills/` | > [accordion] Project-scope skill paths > > Resolved relative to the project directory. > > | Agent(s) | Path | > | - | - | > | amp, kimi-cli, replit, universal, antigravity, cline, warp, codex, cursor, deepagents, firebender, gemini-cli, github-copilot, opencode | `.agents/skills` | > | augment | `.augment/skills` | > | bob | `.bob/skills` | > | claude | `.claude/skills` | > | codebuddy | `.codebuddy/skills` | > | commandcode | `.commandcode/skills` | > | continue | `.continue/skills` | > | cortex | `.cortex/skills` | > | crush | `.crush/skills` | > | factory | `.factory/skills` | > | goose | `.goose/skills` | > | iflow | `.iflow/skills` | > | junie | `.junie/skills` | > | kilocode | `.kilocode/skills` | > | kiro | `.kiro/skills` | > | kode | `.kode/skills` | > | mcpjam | `.mcpjam/skills` | > | mux | `.mux/skills` | > | neovate | `.neovate/skills` | > | openhands | `.openhands/skills` | > | pi | `.pi/skills` | > | pochi | `.pochi/skills` | > | qoder | `.qoder/skills` | > | qwen | `.qwen/skills` | > | roo | `.roo/skills` | > | trae | `.trae/skills` | > | vibe | `.vibe/skills` | > | windsurf | `.windsurf/skills` | > | zencoder | `.zencoder/skills` | > | adal | `.adal/skills` | > | openclaw | `skills/` | ## MCP Server Details For each discovered MCP server, the following fields are captured: | Field | Description | | - | - | | Transport | `stdio`, `sse`, or `streamable_http` | | Command (stdio) | Binary path and arguments | | URL (HTTP) | Server endpoint URL | | EnvVarNames | Names of environment variables referenced (values not captured) | | HeaderNames | Names of HTTP headers referenced (values not captured) | | AllowedTools | Explicit tool allowlist if configured | | AllowedResources | Explicit resource allowlist if configured | > [card] [Endpoint Hub](/governance/cloud/endpoint-hub/overview) > > What Endpoint Hub covers across your fleet. > [card] [Inventory](/governance/cloud/endpoint-hub/inventory) > > Discover AI tooling on each endpoint. > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > Track package installs across endpoints. > [card] [AI Tools Discovery](/ai-security/ai-tools-discovery) > > Find AI agents and MCP servers in use. # MCP Advisor Source: https://docs.safedep.io/governance/cloud/endpoint-hub/mcp-advisor Review the packages your AI coding agents checked through the SafeDep MCP server, per endpoint in SafeDep Cloud MCP Advisor lists the packages your AI coding agents checked through the [SafeDep MCP server](/ai-security/mcp-server) and the verdict each one got. Once the MCP server is set up, SafeDep records an advisory each time an agent vets a package, with no extra configuration. > [!NOTE] > > MCP Advisor is a SafeDep Cloud feature and requires [endpoint sync](/governance/cloud/sync). If your endpoint has no **Advisor** tab, it is not enabled for your tenant yet. Contact the [SafeDep team](/community) to join early access. ## Prerequisites * Configure the [SafeDep MCP server](/ai-security/mcp-server) in your AI coding agent. * Have a SafeDep Cloud tenant ID and API key (see the [Cloud quickstart](/governance/cloud/quickstart)). > [!TIP] > > The SafeDep CLI is the fastest way to configure the MCP server: `npx @safedep/cli setup mcp install`. ## View advisories **1. Open Endpoint Hub** Go to [app.safedep.io](https://app.safedep.io) and select **Endpoint Hub** in the sidebar. **2. Pick an endpoint** Choose the endpoint from the list. **3. Open the Advisor tab** Select the **Advisor** tab to see that endpoint's advisories. The tab shows summary counts, then the advisory list. ### Summary counts | Card | Counts | | - | - | | Advisories | All advisories for this endpoint | | Malicious | Packages flagged as malicious | | Suspicious | Packages showing suspicious signals | | Vulnerable | Packages with known vulnerabilities | | Clean | Packages that came back safe | | Last advisory | When the most recent advisory was recorded | ### Advisory list Each row is one package an agent asked about: | Column | Description | | - | - | | Package | Name, version, and ecosystem | | Verdict | The verdict SafeDep returned (see [Verdicts](#verdicts)) | | Agent | The AI coding agent that asked | | Analysed | When the advisory was recorded | Filter by verdict or date range, for example only Malicious results in the last week. Select a row to see the package, the verdict, the MCP call, and the source endpoint. ## Verdicts | Verdict | Meaning | | - | - | | Safe | No known security issues | | Suspicious | Signals suggest the package may be risky | | Malicious | Confirmed malicious by SafeDep | | Vulnerable | Has one or more known vulnerabilities | | Newly registered | Published very recently, a common trait of malicious packages | | Unknown | Not enough information to classify it | ## Related > [card] [SafeDep MCP Server](/ai-security/mcp-server) > > Configure the MCP server that produces these advisories. > [card] [Endpoint Hub](/governance/cloud/endpoint-hub/overview) > > Browse all the views available for your endpoints. > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > See package installs captured by PMG on each endpoint. > [card] [Endpoint](/concepts/endpoint) > > What an endpoint is and what it reports. # Endpoint Hub Source: https://docs.safedep.io/governance/cloud/endpoint-hub/overview Visibility into AI tooling and package activity across your developer machines, CI runners, and agent sandboxes Endpoint Hub gives you visibility into what is running across your **endpoints**: developer machines, CI runners, and agent sandboxes. It brings together three views in SafeDep Cloud: **Inventory** (the AI tooling found on each endpoint), **Package Guard** (package installs and usage over time), and **MCP Advisor** (packages your AI coding agents vetted through the SafeDep MCP server). Each view is powered by a SafeDep tool that reports activity to the cloud. ## What Endpoint Hub covers ### Inventory Inventory shows the AI tooling active on each endpoint: coding agents, MCP servers, Agent Skills, CLI tools, and IDE extensions. It is powered by `vet endpoint scan`, which discovers these locally and delivers them to SafeDep Cloud when credentials are configured. ### Package Guard Package Guard shows package installs and usage across your endpoints as a timeline of events. It runs on [PMG](/package-security/pmg/quickstart), the open-source Package Manager Guard CLI that intercepts package manager commands and syncs the activity to SafeDep Cloud. ### MCP Advisor MCP Advisor shows the packages your AI coding agents checked through the [SafeDep MCP server](/ai-security/mcp-server) and the verdict each one received. SafeDep records an advisory each time an agent vets a package. ## How it works Inventory and Package Guard follow the same model: an open source CLI runs on the endpoint and, once SafeDep Cloud credentials are configured, syncs its findings to your tenant. MCP Advisor needs no sync, since the MCP server records advisories as agents use it. You browse each endpoint under **Endpoint Hub** in the [app.safedep.io](https://app.safedep.io) sidebar. Without SafeDep Cloud credentials, the local tools still run and no data leaves the machine. ## Get started > [card] [Inventory](/governance/cloud/endpoint-hub/inventory) > > Discover AI tools, Agent Skills, MCP servers, and coding agents on your endpoints > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > Track package installs and usage across your endpoints > [card] [MCP Advisor](/governance/cloud/endpoint-hub/mcp-advisor) > > Review packages your AI coding agents vetted through the SafeDep MCP server > [card] [Find Where a Malicious Package Reached Your Organization](/governance/cloud/endpoint-hub/find-malicious-package) > > Find the endpoints and projects that a malicious package reached > [card] [Review Package Blocks Across CI Pipelines](/governance/cloud/endpoint-hub/ci-package-blocks) > > See what PMG blocked on your CI runners # Package Guard Source: https://docs.safedep.io/governance/cloud/endpoint-hub/package-guard Monitor and control package installations across your endpoints using SafeDep Cloud Package Guard shows package installs and usage across your endpoints. It runs on [PMG](/package-security/pmg/quickstart), SafeDep's open-source Package Manager Guard CLI that intercepts package manager commands and syncs the activity to SafeDep Cloud. [Endpoint Hub Tour: Track endpoints & drill into Package Guard events](https://www.youtube.com/embed/IbSvB6AwA2A) ## Prerequisites * Install PMG using the [quickstart](/package-security/pmg/quickstart), or [deploy it with your MDM](/package-security/pmg/mdm/overview) on a macOS, Linux, or Windows fleet * Have a SafeDep Cloud tenant ID and API key (see [Cloud quickstart](/governance/cloud/quickstart)) ## Enable cloud sync **1. Run the PMG setup installer** ```bash theme={null} pmg setup install ``` ```text Example output theme={null} █▀█ █▀▄▀█ █▀▀ From SafeDep (github.com/safedep/pmg) █▀▀ █░▀░█ █▄█ version: v0.9.0 commit: c3a351 ✓ PMG aliases installed successfully Installed to: /home/user/.pmg.rc Config at: /home/user/.config/safedep/pmg Restart your terminal or source your shell to use the new aliases ``` **2. Enable cloud sync in the PMG config** ```bash theme={null} pmg config set cloud.enabled true ``` **3. Login to SafeDep Cloud** ```bash theme={null} pmg cloud login ``` Enter your **tenant ID** and **API key** when prompted. **4. Sync to SafeDep Cloud** With cloud sync enabled, PMG syncs automatically as you use it (see [Automatic sync](#automatic-sync) below). To push local activity immediately, run: ```bash theme={null} pmg cloud sync ``` ## Automatic sync Once cloud sync is enabled, PMG syncs events on its own, so you don't need to run `pmg cloud sync` by hand. At the end of each PMG invocation, PMG drains its local event log to SafeDep Cloud in a short-lived detached process, so your command returns immediately. This applies whether you invoke PMG directly (`pmg npm install ...`) or indirectly through the shell aliases and path shims installed by `pmg setup install`, which route plain `npm`, `pip`, and other package manager commands through PMG. To avoid syncing on every command, auto-sync is gated by a per-host cooldown. The cooldown timestamp updates on every attempt, success or failure, so a temporarily unreachable cloud endpoint won't make every command retry. Auto-sync is on by default. Tune or disable it under `cloud.auto_sync` in the PMG config: ```yaml theme={null} cloud: enabled: true auto_sync: enabled: true # set to false to disable automatic sync min_interval: 15m # example: minimum gap between sync attempts timeout: 5m # example: hard timeout for a single sync attempt ``` PMG ships with sensible defaults for `min_interval` and `timeout`. See the [PMG config template](https://github.com/safedep/pmg/blob/main/config/config.template.yml) for the current values. > [!WARNING] > > Disable auto-sync in ephemeral environments such as CI runners and throwaway VMs. The detached process may be torn down before it finishes draining. Run an explicit `pmg cloud sync` at job-end instead. ## Manual sync Run `pmg cloud sync` to push local events immediately instead of waiting for the next automatic sync: * **In CI/CD pipelines:** Disable auto-sync and add `pmg cloud sync` as a post-step after PMG runs, so events are flushed before the runner is torn down. * **Forcing an immediate push:** When you don't want to wait out the cooldown, for example right after a large dependency update. ## View package events in SafeDep Cloud After syncing, open [app.safedep.io](https://app.safedep.io), select **Endpoint Hub** in the sidebar, and pick your endpoint to see the **Package Events** timeline. ![SafeDep Cloud Endpoint Hub page showing package events](https://mintcdn.com/safedep/kFLohBCeAZegdeLe/images/pmg-cloud-sync.png?fit=max\&auto=format\&n=kFLohBCeAZegdeLe\&q=85\&s=496edbd55e360cd4d257ec76302f9a0f) ## Next steps > [card] [PMG Quickstart](/package-security/pmg/quickstart) > > Install PMG and learn the basics > [card] [Find Where a Malicious Package Reached Your Organization](/governance/cloud/endpoint-hub/find-malicious-package) > > Find the endpoints and projects that a malicious package reached > [card] [Review Package Blocks Across CI Pipelines](/governance/cloud/endpoint-hub/ci-package-blocks) > > See what PMG blocked on your CI runners # Cloud FAQ Source: https://docs.safedep.io/governance/cloud/faq Frequently asked questions about SafeDep Cloud authentication and usage ## Authentication Errors ### User Not Found **Error Message:** ``` ERRO[0001] Failed to execute whoami: rpc error: code = Unauthenticated desc = unauthenticated: Token auth failed: No user: record not found ``` **Cause:** The user account is not registered with SafeDep Cloud. **Solution:** **1. Register Account** Follow the [quickstart guide](/governance/cloud/quickstart) to register with SafeDep Cloud **2. Verify Registration** Ensure you've completed the full onboarding process including tenant creation **3. Check Email Verification** Verify your email address if required during registration ### Tenant Not Found **Error Message:** ``` ERRO[0001] Failed to execute query: rpc error: code = Unknown desc = failed to resolve tenant: record not found ``` **Cause:** The tenant is not properly configured in Vet, or the tenant domain is incorrect. **Solution:** > [tab] Configure Tenant > > ```bash theme={null} > vet auth configure --tenant > ``` > [tab] Alternative Method > > ```bash theme={null} > vet cloud login --tenant > ``` > [tab] Find Your Tenant > > If you've forgotten your tenant domain: > > ```bash theme={null} > vet cloud login > vet cloud whoami # Shows your identity and accessible tenants > ``` ## API and Connectivity Issues ### Rate Limiting **Error Message:** ``` ERRO[0001] Request failed: rpc error: code = ResourceExhausted desc = rate limit exceeded ``` **Solution:** * Back off briefly and retry. SafeDep enforces per-second rate limits, so a short pause clears the error (see the [API reference](/reference/api-introduction#rate-limiting) for the current limits) * Reduce the frequency of API calls and use batch operations where possible * Contact support for increased rate limits if needed ### Network Connectivity **Error Message:** ``` ERRO[0001] Failed to connect: dial tcp: lookup api.safedep.io: no such host ``` **Solution:** * Check internet connectivity * Verify DNS resolution for `api.safedep.io` * Check firewall settings and proxy configuration * Ensure HTTPS traffic on port 443 is allowed ### SSL/TLS Issues **Error Message:** ``` ERRO[0001] Failed to connect: x509: certificate verify failed ``` **Solution:** * Update your system's CA certificates * Check system clock accuracy * Verify no proxy is interfering with SSL * Try updating Vet to the latest version ## Configuration Issues ### Invalid API Key **Error Message:** ``` ERRO[0001] Authentication failed: invalid API key ``` **Solution:** **1. Generate New Key** Create a new API key in your SafeDep Cloud tenant settings **2. Update Configuration** ```bash theme={null} export SAFEDEP_API_KEY=your-new-api-key vet auth configure --tenant your-tenant ``` **3. Verify Permissions** Ensure the API key has the necessary permissions for your operations ### Expired Tokens **Error Message:** ``` ERRO[0001] Token expired: please re-authenticate ``` **Solution:** ```bash theme={null} # Re-authenticate with device flow vet cloud login --tenant your-tenant # Verify authentication vet cloud whoami ``` ### Configuration File Issues **Error Message:** ``` ERRO[0001] Failed to load config: permission denied ``` **Solution:** * Check file permissions on Vet configuration directory * Ensure user has write access to `~/.config/vet/` * Try running with appropriate permissions * Clear and recreate configuration if corrupted ## Data Sync Issues ### Sync Failures **Error Message:** ``` WARN[0001] Failed to sync data to cloud: project not found ``` **Solution:** * Verify project name and version are correctly specified * Check that tenant has permissions for data sync * Ensure API key includes sync permissions * Retry with proper project identification ### Missing Data **Issue:** Scanned data doesn't appear in SafeDep Cloud **Solution:** **1. Check Sync Flags** Ensure `--report-sync` is included in your scan command **2. Verify Project Info** ```bash theme={null} vet scan -D . --report-sync \ --report-sync-project "your-project" \ --report-sync-project-version "main" ``` **3. Check Authentication** ```bash theme={null} vet auth verify ``` ### Query Failures **Error Message:** ``` ERRO[0001] Query execution failed: syntax error ``` **Solution:** * Verify SQL syntax is correct * Check table and column names in schema * Use `safedep query schema list` to view available tables * Ensure proper quoting for identifiers with special characters ## GitHub Actions Issues ### Secret Configuration **Issue:** GitHub Action fails with authentication errors **Solution:** **1. Check Secrets** Verify these secrets are set in your repository: * `SAFEDEP_CLOUD_API_KEY` * `SAFEDEP_CLOUD_TENANT_DOMAIN` **2. Update Workflow** ```yaml theme={null} - name: Run vet uses: safedep/vet-action@v1 with: cloud: true cloud-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} cloud-tenant: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} ``` ### Action Version Issues **Issue:** Action fails with "unknown parameter" errors **Solution:** * Update to the latest version of vet-action * Check the action documentation for parameter changes * Verify you're using supported parameters for your action version ## Performance Issues ### Slow Scans **Issue:** Scans take too long to complete **Solution:** * Use path exclusions to skip irrelevant directories * Scan specific manifest files instead of entire directories * Adjust timeout settings for malware analysis * Use JSON dump workflow for repeated analysis ### Memory Issues **Issue:** Vet runs out of memory during scans **Solution:** * Scan smaller directory trees * Use exclusions to skip large dependency directories * Increase available memory in CI/CD environments * Process large monorepos in batches ## Getting Additional Help > [card] [GitHub Issues](https://github.com/safedep/vet/issues) > > Report bugs and request features > [card] [Documentation](/governance/cloud/quickstart) > > Setup guides > [card] [Community Support](https://discord.gg/kAGEj25dCn) > > Join our Discord community for help > [card] [Contact Support](mailto:support@safedep.io) > > Direct support ## Common Debugging Commands ### Check Authentication Status ```bash theme={null} vet cloud whoami ``` ### Verify API Configuration ```bash theme={null} vet auth verify ``` ### Test Cloud Connectivity ```bash theme={null} vet cloud ping ``` ### Clear Configuration ```bash theme={null} rm ~/.safedep/vet-auth.yml ``` ### Re-authenticate ```bash theme={null} vet cloud login --tenant your-tenant ``` ### View Detailed Logs ```bash theme={null} vet --debug scan -D . --report-sync ``` # Malware Analysis Source: https://docs.safedep.io/governance/cloud/malware-analysis Detect malicious packages in your dependencies by querying SafeDep's known malicious packages database > [!NOTE] > > Malware analysis is available for free. No API key is required to query SafeDep's known malicious packages database. See [pricing](https://safedep.io/pricing) for SafeDep Cloud features. Check your open source dependencies against SafeDep's continuously updated database of known malicious packages using [Vet](https://github.com/safedep/vet). Vet queries SafeDep's threat intelligence service, which is populated through continuous static and dynamic analysis of packages from public registries. > [!NOTE] > > This page covers the **fast path**: a free lookup against SafeDep's database of known malicious packages, built into Vet, PMG, and the SafeDep MCP server. It answers in milliseconds but only covers packages SafeDep has already analyzed. To run a **new analysis** of a specific component (any package version, an IDE extension, or a GitHub repository), use [On-Demand Package Scanning](/package-security/scan/overview), an independent paid feature. Vet itself no longer submits packages for analysis. On-demand scanning moved to `safedep package scan`. ## Supported Ecosystems > [card] npm > > JavaScript and TypeScript packages > [card] PyPI > > Python packages and wheels > [card] Go Modules > > Go language modules > [card] RubyGems > > Ruby packages and gems > [card] GitHub Actions > > GitHub Action workflows > [card] VS Code Extensions > > Visual Studio Code extensions ## Requirements Install the latest version of [Vet](https://github.com/safedep/vet/#installation). > [!NOTE] > > No API key is required. Querying known malicious packages works out of the box, with no SafeDep Cloud onboarding. A SafeDep Cloud account is optional and enables cloud features such as report sync and higher rate limits. See the [SafeDep Cloud Quickstart](/governance/cloud/quickstart). ## Repository Scanning ### Basic Malware Scanning Enable malware analysis with the `--malware-query` flag: ```bash theme={null} vet scan -D /path/to/code --malware-query ``` Because Vet performs a lookup against known malicious packages, results are returned quickly, which works well for pull requests and CI/CD pipelines. > [!NOTE] > > The `--malware` flag is a deprecated alias for `--malware-query` and behaves identically. It will be removed in a future release. ### Specific Manifest Scanning Scan individual package manifest files: ```bash theme={null} # npm projects vet scan -M package-lock.json --malware-query # Python projects vet scan -M requirements.txt --malware-query # Go projects vet scan -M go.mod --malware-query # Ruby projects vet scan -M Gemfile.lock --malware-query ``` ### PURL-Based Scanning Scan specific packages using Package URLs: ```bash theme={null} vet scan --purl pkg:npm/llm-oracle@1.0.2 --malware-query ``` ![Malware analysis results for llm-oracle package](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet-malysis-llm-oracle.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=d82d51432119f69fb9fb2636ef3dfe82) ## Visual Studio Code Extensions Scan locally installed VS Code extensions: ```bash theme={null} vet scan --vsx --malware-query ``` > [!WARNING] > > VS Code extension scanning is supported only for local developer machines, not in CI/CD environments. ## GitHub Actions Integration ### vet-action Enable malicious package protection in GitHub repositories using [vet-action](https://github.com/safedep/vet-action): ```yaml theme={null} name: Malware Protection on: pull_request: branches: [ main ] jobs: malware-scan: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run malware analysis uses: safedep/vet-action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` > [!NOTE] > > Known malicious package detection does not require an API key. SafeDep Cloud configuration (`cloud`, `cloud-key`, `cloud-tenant`) is optional and only enables cloud reporting and sync. See the [vet-action documentation](https://github.com/safedep/vet-action?tab=readme-ov-file#cloud-mode) for cloud mode. ### Pull Request Integration When enabled, Vet scans changed packages for malware and provides results directly in pull requests: ![vet malware analysis in GitHub PR](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet-action-malysis-1.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=65d9f9ce9240be1b2cc35b7c04871a2c) Expand comments to view detailed package analysis results: ![Detailed malware analysis results in PR](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet-action-malysis-2.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=19a909b404c9eaf7fb33e8f021714f60) ## Understanding Results ### Classification Levels * **SAFE**: No malicious behavior detected * **SUSPICIOUS**: Potentially risky patterns identified * **MALICIOUS**: Confirmed malicious behavior found ### How Packages Are Analyzed SafeDep continuously analyzes packages from public registries and records the results in its known malicious packages database. Vet queries this database during a scan. The analysis behind these records combines: > [accordion] Static Analysis > > * Code pattern analysis > * Suspicious function detection > * Obfuscation identification > [accordion] Behavioral Analysis > > * Network communication patterns > * File system access patterns > * Process execution analysis > [accordion] Metadata Analysis > > * Package metadata anomalies > * Publisher reputation analysis > * Distribution pattern analysis ## CI/CD Integration Examples ### GitLab CI ```yaml theme={null} stages: - security malware-scan: stage: security image: ghcr.io/safedep/vet:latest script: - vet scan -D . --malware-query --report-json malware-report.json artifacts: reports: security: malware-report.json ``` ### Jenkins Pipeline ```groovy theme={null} pipeline { agent any stages { stage('Malware Scan') { steps { sh 'vet scan -D . --malware-query --report-json malware-results.json' archiveArtifacts artifacts: 'malware-results.json' } } } } ``` ## Troubleshooting > [accordion] Legitimate packages are flagged > > * Review the analysis details > * Contact SafeDep support with the package details > * Use exceptions management for temporary overrides > [accordion] A package is not flagged as malicious > > * Only packages already present in SafeDep's known malicious packages database are reported. Packages not yet analyzed are not flagged. > * Ensure you are using the latest version of Vet > * Check network connectivity to SafeDep Cloud > [card] [On-Demand Package Scanning](/package-security/scan/overview) > > Run an on-demand analysis of a package, IDE extension, or GitHub repository not yet in the database > [card] [vet-action Documentation](https://github.com/safedep/vet-action?tab=readme-ov-file#cloud-mode) > > Complete GitHub Actions integration guide > [card] [SafeDep Cloud Setup](/governance/cloud/quickstart) > > Optional cloud features such as report sync and higher rate limits > [card] [Report Issues](https://github.com/safedep/vet/issues) > > Report bugs or request features for malware analysis # SafeDep Cloud Source: https://docs.safedep.io/governance/cloud/overview The control plane, data lake, and intelligence layer that runs SafeDep's open source tools across a team or an organization. SafeDep Cloud is the software supply chain security platform built on SafeDep's open source tools. Every feature of [PMG](/package-security/pmg/overview), [Vet](/governance/vet/overview), and [xBom](/governance/xbom/overview) is open source. You can read the code and verify what each tool does before you run it. One developer needs only the tools. A team can deploy the tools by hand and write its own reporting. SafeDep Cloud does this work for a team or an organization: * **Control plane.** Connect the tools on developer machines, CI runners, and agent sandboxes to one tenant. [Endpoint Hub](/governance/cloud/endpoint-hub/overview) shows each endpoint and what the tools on it blocked or found. * **Data lake.** Keep package events, scan results, policy violations, and AI tool inventory in one place. Query them with [SQL](/reference/sql-query) from the console, the `safedep` CLI, or the API. An [AI agent](/governance/cloud/talk-to-safedep) can use the same queries to answer questions about your supply chain. * **Intelligence layer.** Run [on-demand scans](/package-security/scan/overview) of packages, extensions, and repositories, and get the [Threat Intel Feed](/threat-intel/overview). You own your data. The [SafeDep Cloud API](/reference/api-introduction) gives you full access to it, so you can build your own integrations. See the [pricing page](https://safedep.io/pricing) for what each plan includes. ## Set up Cloud > [card] [SafeDep Cloud Quickstart](/governance/cloud/quickstart) > > Create a tenant and connect your first project in minutes. > [card] [Authentication](/governance/cloud/authentication) > > Cloud authentication methods and API access patterns. ## Govern across your fleet > [card] [Cloud Sync](/governance/cloud/sync) > > Sync Vet scan data and policy violations to Cloud for centralized query and reporting. > [card] [Endpoint Hub](/governance/cloud/endpoint-hub/overview) > > See AI tooling and package activity across developer machines, CI runners, and agent sandboxes. > [card] [Cloud Policy](/governance/cloud/policy/overview) > > Block and trust packages, set the cooldown, and choose what fails a pull request check, for the whole tenant. > [card] [Malware Analysis](/governance/cloud/malware-analysis) > > Detect malicious packages in your dependencies with Cloud code analysis. > [card] [Plans & Pricing](https://safedep.io/pricing) > > Compare the Free, Team, and Enterprise plans. # Malicious Package Exclusions Source: https://docs.safedep.io/governance/cloud/package-exclusions Manage package exclusions for malicious package analysis in SafeDep Cloud > [!WARNING] > > Malicious Package Exclusions are deprecated. Package rules of the [cloud policy](/governance/cloud/policy/overview) replace them: a trust entry with the scope `malware` waives a malware verdict for one package. Exclusions get no new features, and a later release removes them. SafeDep Cloud does not copy your exclusions. PMG with `cloud.policy` on ignores them. The pull request check still applies them. To move an exclusion, see [Trust a Package](/governance/cloud/policy/trust-a-package#move-from-malicious-package-exclusions). > [!NOTE] > > Malicious Package Exclusions are available in the SafeDep Cloud **Team** and **Enterprise** plans. > See [pricing](https://safedep.io/pricing). > > Only tenant owners can create, edit, or delete exclusions. If you can view package analysis results but cannot manage an exclusion, contact your tenant owner. Malicious Package Exclusions let your tenant suppress specific package findings from malicious package analysis after review. Use them when your team has reviewed a package and decided it is expected in your environment, so SafeDep stops surfacing the same finding repeatedly. Exclusions are tenant-specific: a package trusted in one SafeDep Cloud tenant is not automatically trusted in another. An exclusion does not mark a package as globally safe. It suppresses the finding only for the package identity you excluded (ecosystem, name, and version) within your tenant. ## Where Exclusions Are Respected Exclusions act as a tenant-level source of truth across SafeDep tools and integrations connected to SafeDep Cloud. This currently includes: * SafeDep Cloud package analysis views in `app.safedep.io` * GitHub App * `vet` in cloud mode * `vet-action` in cloud mode ## When To Use An Exclusion Use an exclusion when: * a package repeatedly appears as suspicious or malicious and your team has already reviewed it * you want to reduce noise without disabling malicious package protection * you want to trust a package temporarily by setting an expiry date Do not use exclusions as a workaround for packages SafeDep has already verified as malicious. ## What An Exclusion Applies To Each exclusion is scoped to a package ecosystem, name, and version. You can also add a reason and an optional expiry date for temporary exceptions. Malicious Package Exclusions apply only to malicious package analysis. They do not change vulnerability findings or other SafeDep checks. ## Create An Exclusion From Settings The main place to manage exclusions is the SafeDep Cloud settings page: **1. Navigate to Settings** Go to [app.safedep.io/settings/package-exclusions](https://app.safedep.io/settings/package-exclusions) **2. Create Exclusion** Click **Create Exclusion** **3. Fill Details** Fill in the package details **4. Save** Save the exclusion The page shows your existing exclusions in a table and a **Create Exclusion** button in the top-right corner. ![Malicious Package Exclusions settings page showing the exclusions table and Create Exclusion button](https://mintcdn.com/safedep/XfEFBVwRR4JjISJP/images/exclusions/exclusions-page.png?fit=max\&auto=format\&n=XfEFBVwRR4JjISJP\&q=85\&s=bff56649870a0696c7929170b280a084) ### Fields When creating an exclusion, SafeDep Cloud asks for: * **Ecosystem**: The package ecosystem, such as npm or PyPI * **Package Name**: The package to exclude * **Version**: The specific version to exclude * **Reason**: Why your team is excluding this package * **Expires At**: Optional expiry date for temporary exceptions Use `0` in the **Version** field to exclude all versions of a package. ![Create Exclusion drawer in SafeDep Cloud showing ecosystem, package name, version, reason, and expiry fields](https://mintcdn.com/safedep/XfEFBVwRR4JjISJP/images/exclusions/exclusions-page-create-exclusion.png?fit=max\&auto=format\&n=XfEFBVwRR4JjISJP\&q=85\&s=94d5f57537418a021eb7b61e044ba11d) ## Create Or Manage An Exclusion From Package Analysis You can also start from a package analysis result: **1. Open Package Result** Open a malicious package result in SafeDep Cloud **2. Create or Manage** Use the header action to create or manage an exclusion Depending on the current state, SafeDep Cloud shows one of these actions: * **Create Exclusion** if no exclusion exists yet * **Manage Exclusion** if an exclusion already exists for that package and version This is a convenient path when you are already investigating a package and want to create or review an exclusion without navigating back to Settings. ![Package analysis page showing the Create Exclusion action](https://mintcdn.com/safedep/XfEFBVwRR4JjISJP/images/exclusions/package-analysis-create-exclusion-button.png?fit=max\&auto=format\&n=XfEFBVwRR4JjISJP\&q=85\&s=c6cb1febbe70eaf7bae02d80833c8fdb) ![Package analysis page showing the Manage Exclusion action](https://mintcdn.com/safedep/XfEFBVwRR4JjISJP/images/exclusions/package-analysis-manage-exclusion-button.png?fit=max\&auto=format\&n=XfEFBVwRR4JjISJP\&q=85\&s=207a772a972f313cb83992588fb6694d) ## Manage Existing Exclusions The exclusions table helps you review and maintain the exclusions already configured in your tenant. Each row shows the ecosystem, package name, version, reason, current status, expiry date, and available actions for that exclusion. You can filter exclusions by: * ecosystem * package name * version * expiry status * expiry date From the table, you can also: * edit an exclusion * delete an exclusion * review the reason and expiry date attached to each exclusion * quickly see whether an exclusion is active or close to expiring from the status badge ![Exclusions table row actions menu showing Edit Exclusion and Delete Exclusion](https://mintcdn.com/safedep/XfEFBVwRR4JjISJP/images/exclusions/exclusions-page-row-actions.png?fit=max\&auto=format\&n=XfEFBVwRR4JjISJP\&q=85\&s=f8cc22bbffd98482c5b121bea5a2d928) ### Edit An Exclusion Use **Edit Exclusion** when you need to change: * the version * the reason * the expiry date * the package identity This is useful when an exclusion started as a short-term exception and later needs to be extended, narrowed, or documented more clearly. ### Delete An Exclusion Delete an exclusion when you want malicious package analysis to apply normally again. After you delete an exclusion, later scans or package analysis results may surface that package again if it is still detected as suspicious or malicious. ## How Exclusions Work SafeDep Cloud applies exclusions using the package identity you provide. ### Exact Version Vs All Versions Version is matched exactly. Enter `4.17.21` to exclude only that version, or `0` to exclude all versions. (`0` is a special value meaning "all versions," not the literal version `0`.) If both an exact-version exclusion and an all-version exclusion could match, the exact version takes precedence. ### Expiry An exclusion with an expiry date stops applying automatically after the expiry time passes. This is useful for temporary investigation windows, migrations, and short-lived exceptions. ### Verified Malicious Packages SafeDep Cloud does not allow exclusions for packages it has already verified as malicious. If you try to create or update such an exclusion, SafeDep Cloud returns an error instead of saving it. ## What To Expect After Adding An Exclusion After an exclusion is added: * future malicious package analysis for that package stops surfacing the excluded result across SafeDep tools and integrations that respect tenant exclusions * the exclusion remains listed on the settings page so authorized users can review, update, or delete it later * you may need to refresh the page or rerun the scan to confirm the updated behavior If you later delete the exclusion or let it expire, the package can reappear in analysis results. ## Troubleshooting ### I can see the page, but I cannot create an exclusion Exclusion management is currently limited to tenant owners. If the button is disabled, ask your tenant owner to create or manage the exclusion for you. ### I see a paywall instead of the exclusions table Malicious Package Exclusions are available in the SafeDep Cloud Team and Enterprise plans. Upgrade your plan or contact your SafeDep representative if you need access. ### Why did my exclusion stop working? The most common reasons are: * the exclusion expired * the package ecosystem, name, or version does not match the current finding * you may need to refresh the page or rerun the relevant scan to confirm the latest result state If SafeDep blocks you while creating or updating an exclusion, check whether the package has already been verified as malicious. ### When should I use version `0`? Use version `0` when you want to exclude all versions of a package instead of just one specific version. ## Next Steps > [card] [GitHub App](/governance/integrations/github) > > See how SafeDep respects exclusions in GitHub pull request checks > [card] [Malware Analysis](/governance/cloud/malware-analysis) > > Learn how SafeDep Cloud analyzes packages for malicious behavior > [card] [Authentication](/governance/cloud/authentication) > > Configure access to your SafeDep Cloud tenant > [card] [Cloud FAQ](/governance/cloud/faq) > > Find answers to common SafeDep Cloud questions # Audit Changes to the Cloud Policy Source: https://docs.safedep.io/governance/cloud/policy/audit-policy-changes See who changed the cloud policy, when and how, with audit events, policy revisions and the email notices to Owners and Admins. SafeDep Cloud keeps three records of each change to the cloud policy: an audit event for each admin action, a policy revision for each publish, and an email to the Owners and Admins for each risky publish. Use them to review changes and to answer an auditor. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). Reading audit events needs the Admin role. ## List the audit events ```bash theme={null} safedep audit event list --since 7d --action policy. ``` Each event names the actor, the action, the resource, the result, the time and details such as the revision. Each admin action writes one event, in the same transaction as the action. So an action that failed and rolled back writes no event. These are the actions of the cloud policy: | Action | Resource kind | When | | - | - | - | | `policy.change.create`, `policy.change.update`, `policy.change.sync`, `policy.change.delete` | `policy_change` | An Admin works on a draft | | `policy.change.publish` | `policy_change` | An Admin publishes a change. The details hold the revision and the change direction. | | `policy.rule.create`, `policy.rule.update`, `policy.rule.delete` | `package_rule` | An Admin creates, changes or deletes one package rule | | `policy.rule.bulk_create` | `policy_change` | An Admin creates block entries from a file. One event covers all of them. | | `policy.endpoint_label.set`, `policy.endpoint_label.delete` | `endpoint` | An Admin sets or deletes `custom/` labels on an endpoint | | `policy.project_label.set`, `policy.project_label.delete` | `project` | An Admin sets or deletes `custom/` labels on a project | Filter the list: ```bash theme={null} # Only the package rule actions safedep audit event list --action policy.rule. # The events of one policy change safedep audit event list --resource policy_change/18 # The events of one person safedep audit event list --actor alice ``` `--actor` matches the actor id or the display name exactly. ## Review the revisions Each publish makes one policy revision. A user with the ReadOnly role or a higher role can read them: ```bash theme={null} safedep policy revision list safedep policy revision show 47 ``` A revision shows who published it, when, from which change, its change direction, and the policy settings document at that revision. To see the package rules that were active at a revision: ```bash theme={null} safedep policy rule list --at-revision 47 ``` The revisions show which policy SafeDep Cloud served on a date. The applied revision that an endpoint reports is a record of what the endpoint said. It is not proof, because until endpoint enrollment ships, a holder of the tenant API key can report for any endpoint. ## Email notices Every Owner and Admin of the tenant gets an email after some publishes, such as a publish that loosens the policy. To get the emails, give the person the Owner or Admin role in the tenant. To check a publish that an email names, run `safedep policy revision show` with the revision of the email. For which publishes send an email and what it holds, see [Notices](/concepts/policy-revisions#notices). ## Retention SafeDep Cloud keeps audit events for at least one year, and policy revisions and package rules for the life of the tenant. See [Cloud Policy Limits](/reference/cloud-policy-limits#retention). ## Next steps > [card] [Policy Revisions and Changes](/concepts/policy-revisions) > > Change direction and notices. > [card] [Roll Back a Change](/governance/cloud/policy/roll-back-a-change) > > Undo a publish with a new revision. > [card] [Command Reference](https://github.com/safedep/cli/tree/main/docs/cmd) > > Every flag of `safedep audit event list`. # Block a Package During an Incident Source: https://docs.safedep.io/governance/cloud/policy/block-a-package Block a malicious package, a version range or a list of packages for every endpoint and project of your tenant with the safedep CLI. Use a block entry when a package is a threat to your tenant and you cannot wait for an MDM push. The block reaches every pull request check at once, and each PMG endpoint after its next policy fetch. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan and the Admin role. See [pricing](https://safedep.io/pricing). ## Block one package ```bash theme={null} safedep policy rule create --block pkg:npm/evil --vers '>=1.2.0' \ --reason "IR-2291 credential stealer" --ticket IR-2291 ``` * The selector is a PURL. Without a version or `--vers`, the block selects every version. * `--vers` takes a range, as `'>=1.2.0'`. Quote it, because the shell reads `>`. * `--reason` is required. PMG shows it in the block message. The pull request check shows it on a private repository only. * `--ticket` and `--requested-by` are optional. Tools never receive them. The command creates the rule and publishes a new policy revision at once. It prints the rule id, such as `r_9c1x4kq7dm`. Each decision of the rule cites that id. ## Block a namespace A block entry can use a prefix that ends with `/*` or `.*`: ```bash theme={null} safedep policy rule create --block 'pkg:npm/@evil-scope/*' --reason "IR-2300 hijacked scope" ``` A prefix has no version. Use `--vers` to limit it to a range. A prefix such as `pkg:npm/*` selects every package of an ecosystem and stops every install of it, and the command warns you. ## Block a list of packages Write one selector on each line of a file. A line can add a range after a space. A line that starts with `#` is a comment. ```text iocs.txt theme={null} # IR-2300 campaign pkg:npm/evil-one pkg:npm/evil-two vers:npm/>=2.0.0 pkg:pypi/evil-three@0.4.1 ``` ```bash theme={null} safedep policy rule create --block -f iocs.txt --reason "IR-2300 campaign" --ticket IR-2300 ``` The file holds at most 1,000 selectors. All of them go into one policy revision. Use `-f -` to read the list from standard input. ## Block for one group only By default a rule attaches to the policy base and applies to every endpoint and project. To block for the subjects of one policy override, add `--override NAME`: ```bash theme={null} safedep policy rule create --block pkg:npm/legacy-sdk --reason "Not allowed in payment services" \ --override payments ``` ## Check the block 1. List the endpoints that did not apply the new revision yet. Use the revision number that the create command printed: ```bash theme={null} safedep endpoint list --applied-revision '<48' ``` 2. List the decisions of the rule: ```bash theme={null} safedep policy decision list --rule r_9c1x4kq7dm ``` Every Owner and Admin of the tenant gets an email about the new block. A block stops new installs. It does not remove copies that are already installed. To find the endpoints that have the package, see [Find a Malicious Package](/governance/cloud/endpoint-hub/find-malicious-package). ## How fast a block reaches PMG PMG fetches the policy in the background after a command, at most once every 5 minutes. So the first install after a block can still use the previous policy. To fetch at once on one machine, run `pmg cloud sync`. ## Remove the block ```bash theme={null} safedep policy rule delete r_9c1x4kq7dm --reason "IR-2291 closed" ``` The delete loosens the policy and publishes a new revision. The rule stays in the history of the revisions. ## Next steps > [card] [Package Rules](/concepts/package-rules) > > Selectors, prefixes and how a block beats a trust entry. > [card] [Explain a Decision](/governance/cloud/policy/explain-a-decision) > > Find the rule behind a block. > [card] [Audit Policy Changes](/governance/cloud/policy/audit-policy-changes) > > See who added or removed a rule. > [card] [Command Reference](https://github.com/safedep/cli/tree/main/docs/cmd) > > Every flag of `safedep policy rule`. # Explain a Policy Decision Source: https://docs.safedep.io/governance/cloud/policy/explain-a-decision Find the package rule or the setting that blocked an install in PMG or failed a pull request check, with the decision log and the citation. Each decision that PMG or the pull request check makes with the cloud policy carries a citation: the policy revision, the revision of the SafeDep default policy, and the package rule or the setting that decided. Use the citation to answer "why was this package blocked?" for one endpoint or one pull request. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). A user with the ReadOnly role or a higher role can read the decision log. ## Read the citation where the decision happened **In PMG.** A block entry of the cloud policy stops the install with a message that names the rule. This example comes from the PMG tests: ```text theme={null} pmg: blocked pkg:npm/evil@1.2.4 by the policy of your tenant rule r_9c1 · policy revision 48 · default policy revision 12 · IR-2291 credential stealer To ask for an exception, send the rule id and the reason to your security admin. They can run: safedep policy rule show r_9c1 ``` **In a pull request check.** A failing check shows a policy block with the revision, the settings and the rule of each finding. See [What the check shows](/governance/cloud/policy/pull-request-checks#what-the-check-shows). ## Show the rule ```bash theme={null} safedep policy rule show r_9c1x4kq7dm ``` The output shows the selector, the effect, the scopes, the reason, the ticket, the requester, where the rule attaches, its expiry, its author, and the revisions that added and removed it. ## List the decisions `safedep policy decision list` lists the decisions of the tenant, newest first. Each row names the tool, the package, the outcome, the rule or the setting that decided, the revision and the place of the decision. The decisions of one package rule: ```bash theme={null} safedep policy decision list --rule r_9c1x4kq7dm ``` The installs that the cloud cooldown blocked in the last day: ```bash theme={null} safedep policy decision list --path package_admission.cooldown.min_age --since 1d ``` The decisions about one package, in all its versions, on one endpoint: ```bash theme={null} safedep policy decision list --package pkg:npm/lodash --endpoint 01KR0EKN6PMW0ZRFRN992H1PKX ``` Other filters: | Filter | Keeps | | - | - | | `--tool pmg` or `--tool pull-request-check` | The decisions of one tool | | `--outcome blocked`, `failed` or `allowed` | Blocked installs, failed checks, or packages that a trust entry allowed | | `--revision N` | The decisions that applied revision N | | `--override NAME` | The decisions of one policy override: a field that it set, or a rule that attaches to it | | `--project ID` | The decisions of the checks of one project | | `--since` and `--until` | A time window, as `7d` or `12h` | The `--package` filter takes a PURL with no version. The name must match the stored name exactly, with the same case. ## What is not in the decision log * A decision with no citation: a block by the malware analysis alone, a block by the PMG `blocked_packages` list, and a cooldown block when the cooldown came from the PMG config and not from the cloud policy. * A PMG decision that PMG did not sync yet. PMG syncs its events to SafeDep Cloud with `cloud.enabled` on. See [Package Guard](/governance/cloud/endpoint-hub/package-guard). ## Show the policy of one subject To see the value of each setting for one endpoint or project, and the layer that set it: ```bash theme={null} safedep endpoint policy show arjuns-mbp safedep project policy show acme/payments-api --field scan_gate.fail_on ``` The output also shows the revision that each tool applied, and the exceptions that it reported, such as a field that a managed config file locks. ## Next steps > [card] [Policy Resolution](/concepts/policy-resolution) > > Layers, policy overrides and the resolved policy. > [card] [Trust a Package](/governance/cloud/policy/trust-a-package) > > Act on a block that was wrong. > [card] [Command Reference](https://github.com/safedep/cli/tree/main/docs/cmd) > > Every flag of `safedep policy decision list`. # Cloud Policy Source: https://docs.safedep.io/governance/cloud/policy/overview Set one policy for your tenant in SafeDep Cloud: block and trust packages, set the dependency cooldown, and choose what fails a pull request check. The cloud policy is one [policy](/concepts/policy) for your tenant in SafeDep Cloud. A security admin changes it with the [safedep CLI](/get-started/cli-tools), and PMG and the pull request checks apply it. You change the policy of the whole fleet with no new MDM package. > [!NOTE] > > The cloud policy needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ## What the cloud policy controls * **Package rules.** Block a package for the whole tenant, or trust one package after a false positive. See [Package Rules](/concepts/package-rules). * **Dependency cooldown.** Hold back package versions that are younger than a minimum age. * **Pull request checks.** Choose the lowest vulnerability severity that fails a check. You can set a value for the whole tenant, or for a group of endpoints or projects with a policy override. See [Policy Resolution](/concepts/policy-resolution). ## What enforces each part | Part of the policy | PMG | Pull request check | Vet | | - | - | - | - | | Block entries | Enforces | Enforces | Not yet | | Trust entries, scope `malware` | Enforces | Enforces | Not yet | | Trust entries, scope `cooldown` | Enforces | Not supported | Not yet | | Trust entries, scope `vulnerability` | Not applicable | Enforces | Not yet | | Dependency cooldown (`package_admission.cooldown.min_age`) | Enforces | Not supported | Not yet | | Scan gate (`scan_gate.fail_on`, `scan_gate.fail_on_attacks`) | Not applicable | Enforces, with exceptions | Not yet | The [settings reference](/reference/cloud-policy-settings) gives the exceptions of each setting. ## Who can change the policy A user with the ReadOnly role or a higher role can read the policy, its revisions and its decisions. Only an Admin can create, edit, publish or delete a policy change, create or change a package rule, or set a label. Only an Admin can read the audit events. ## How a change reaches the tools 1. An Admin edits the policy with `safedep policy edit`. The edit makes a draft, a policy change. 2. The Admin reads the preview with `safedep policy change show`. 3. The Admin publishes the change. The publish makes a new policy revision. 4. The next pull request check of each project uses the new revision. PMG on each endpoint applies it after its next policy fetch. A package rule skips the draft: `safedep policy rule create` publishes at once. See [Policy Revisions and Changes](/concepts/policy-revisions). ## Set up the tools > [card] [Apply the cloud policy in PMG](/package-security/pmg/cloud-policy) > > Turn on `cloud.policy` in PMG on developer machines and CI runners. > [card] [Pull request checks](/governance/cloud/policy/pull-request-checks) > > Use the policy in the GitHub App and the Bitbucket app. ## Guides > [card] [Quickstart](/governance/cloud/policy/quickstart) > > Publish your first policy with the safedep CLI. > [card] [Block a Package](/governance/cloud/policy/block-a-package) > > Block a package for the whole tenant during an incident. > [card] [Trust a Package](/governance/cloud/policy/trust-a-package) > > Trust a package after a false positive. > [card] [Set a Cooldown](/governance/cloud/policy/set-a-cooldown) > > Set the dependency cooldown for the tenant or for a group. > [card] [Target a Group](/governance/cloud/policy/target-a-group) > > Label endpoints and projects and write a policy override. > [card] [Fail Pull Request Checks](/governance/cloud/policy/pull-request-checks) > > Choose the severities that fail a check for a group of projects. > [card] [Roll Back a Change](/governance/cloud/policy/roll-back-a-change) > > Restore a setting from an old revision. > [card] [Explain a Decision](/governance/cloud/policy/explain-a-decision) > > Find the rule or setting that blocked a package or failed a check. > [card] [Audit Policy Changes](/governance/cloud/policy/audit-policy-changes) > > See who changed the policy, and when. ## Reference > [card] [Cloud Policy Settings](/reference/cloud-policy-settings) > > Each setting, its type and its default. > [card] [Cloud Policy Limits](/reference/cloud-policy-limits) > > Limits, retention and known gaps. # Fail Pull Request Checks on Chosen Severities Source: https://docs.safedep.io/governance/cloud/policy/pull-request-checks Use the cloud policy to choose which vulnerability severities fail the SafeDep pull request check for a group of projects, on GitHub and Bitbucket. The pull request check of the [SafeDep GitHub App](/governance/integrations/github) and the [Bitbucket app](/governance/integrations/bitbucket-app) reads the cloud policy of your tenant. Both apps use the same check, so one policy applies to repositories on both forges. There is no separate setting in each app. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan and the Admin role. See [pricing](https://safedep.io/pricing). The app must scan the repositories for your tenant. ## What the check reads | Part of the policy | What the check does | | - | - | | `scan_gate.fail_on` | Fails on a vulnerability at or above this severity: `critical`, `high`, `medium`, `low` or `info`. The SafeDep default policy sets `high`. | | `scan_gate.fail_on_attacks` | With `report`, the check reports a malware verdict that is not verified and does not fail on it. With `fail` (the default), the check also reports it and does not fail on it yet. | | Block entries | Fail the check when the pull request adds a package that they select. | | Trust entries, scope `vulnerability` | Waive the vulnerabilities of the package that they select. | | Trust entries, scope `malware` | Waive a malware verdict that is not verified. | Verified malware always fails the check. No setting and no trust entry changes that. The check also fails on a risky license, by a fixed rule of the check that the policy does not control yet. The check does not apply a dependency cooldown. The check still applies the [Malicious Package Exclusions](/governance/cloud/package-exclusions) of your tenant. When an exclusion selects a package version, the check does not report an unverified malware verdict for that version. Verified malware still fails the check. PMG with `cloud.policy` on ignores exclusions. `info` is a partial value: the vulnerability data has no info grade, so the check ranks a vulnerability with no severity as info. ## Fail on medium for a group of projects 1. Label the projects of the group. A repository is a project: ```bash theme={null} safedep project label set acme/payments-api acme/ledger PAY/settlement --label custom/criticality=high ``` If a repository has no project yet, create it with `safedep project sync OWNER/REPOSITORY --source github`. Use `--source bitbucket` for a Bitbucket repository. The CLI needs `--source` when your tenant links both GitHub and Bitbucket. 2. Open the policy settings document and add a policy override: ```bash theme={null} safedep policy edit -m "payments: fail on medium" ``` ```yaml theme={null} overrides: - name: payments priority: 200 description: Stricter gate for payment services selector: matchLabels: {custom/criticality: high} spec: scan_gate: fail_on: medium ``` 3. Preview the change. The preview counts the projects that the policy override reaches, and how many of them can enforce `medium`: ```bash theme={null} safedep policy change show 18 ``` 4. Publish it: ```bash theme={null} safedep policy change publish 18 -m "payments: fail on medium" ``` Use the change number that `safedep policy edit` printed. The next check of each project uses the new revision. To set the gate for every project of the tenant, set `scan_gate.fail_on` in the policy base instead. To target one forge, select on `scm/forge`, as in `matchLabels: {scm/forge: bitbucket}`. ## Waive one vulnerable package To pass a check that fails on a vulnerability that you accept, create a trust entry with the scope `vulnerability`: ```bash theme={null} safedep policy rule create --trust pkg:npm/minimist@1.2.5 --scope vulnerability \ --reason "Not reachable in our build, S-91" --expires 30d ``` The trust entry waives every vulnerability of the versions that it selects, also a vulnerability that is published later. ## What the check shows A failing check shows a policy block above the package report: * On GitHub, in the comment of the SafeDep app and in the output of the check run. * On Bitbucket, in the comment of the SafeDep app. The build status of the commit links to the pull request. The block names the policy revision, each setting that the check read and the layer that set it, and each failing, waived and reported finding with the rule that decided it. This example comes from the SafeDep test data: ```markdown theme={null} **SafeDep policy: failed** Policy: tenant revision 47 · SafeDep default policy revision 1 | Setting | Value | Set by | Coverage | | --- | --- | --- | --- | | `scan_gate.fail_on` | MEDIUM | policy override "payments" (selects `custom/criticality=high`) | ENFORCE | | Package | Finding | Result | Rule | | --- | --- | --- | --- | | `left-padd 1.0.0` | block entry `r_9c1x4kq7dm` | Failing | "typosquat of left-pad" | | `lodash 4.17.20` | CVE-2021-23337 (high) | Failing | `scan_gate.fail_on` | | `minimist 1.2.5` | CVE-2021-44906 (critical) | Waived | trust entry `r_trust` (VULNERABILITY), expires 2026-12-03 | Fixed rule of the check: `risky-oss-licenses` Ask your security admin. They can run `safedep project policy show acme/payments-api` ``` * A passing check shows no policy block. * On a public repository, the block shows the rule id of a package rule, not its reason. * When the tenant has no policy revision, the block names only the SafeDep default policy. ## When the check does not use your policy * **The repository has no project.** The check resolves the policy with the `scm/` labels of the repository. The policy base, the package rules of the policy base and the policy overrides that select `scm/` labels apply. A `custom/` label needs a project. Run `safedep project sync OWNER/REPOSITORY --source github`, or `--source bitbucket` for a Bitbucket repository. * **The installation is not linked to a tenant, or the plan of the tenant has no cloud policy.** The SafeDep default policy applies alone. * **SafeDep Cloud cannot read the policy.** The check retries, and then fails with an error. It never falls back to the default policy, because the default policy can be looser than yours. A failed check stops a merge only when the forge requires the check. ## Next steps > [card] [Explain a Decision](/governance/cloud/policy/explain-a-decision) > > List the checks that a rule or a setting failed. > [card] [Target a Group](/governance/cloud/policy/target-a-group) > > Labels and selectors for projects. > [card] [GitHub App](/governance/integrations/github) > > Install the SafeDep GitHub App. > [card] [Bitbucket App](/governance/integrations/bitbucket-app) > > Install and link the Bitbucket app. # Cloud Policy Quickstart Source: https://docs.safedep.io/governance/cloud/policy/quickstart Publish your first cloud policy with the safedep CLI, then see PMG and a pull request check apply it. In this tutorial you publish the first policy of your tenant with the safedep CLI. The policy holds back package versions that are younger than 7 days, and fails pull request checks on vulnerabilities of medium severity or higher. Then you see PMG and a pull request check apply it. > [!NOTE] > > The cloud policy needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ## Before you start * You have the Admin role in a SafeDep Cloud tenant. * The [safedep CLI](/get-started/cli-tools) is installed. * To see the effect in PMG: [PMG](/package-security/pmg/quickstart) is installed on a machine, and you have an API key of the tenant from [app.safedep.io/settings/api-keys](https://app.safedep.io/settings/api-keys). * To see the effect in a pull request check: the [GitHub App](/governance/integrations/github) or the [Bitbucket app](/governance/integrations/bitbucket-app) scans a repository for your tenant. **1. Log in** ```bash theme={null} safedep auth login ``` The command opens a login page in your browser. If you have access to more than one tenant, it asks you to pick one. Run `safedep auth status` to see the tenant of the session. **2. Show the policy** ```bash theme={null} safedep policy show ``` The output shows the head revision of the policy, the open policy changes, the number of package rules, the SafeDep default policy and the policy overrides. A new tenant has no revision yet. Its policy is the SafeDep default policy alone. **3. Edit the policy** ```bash theme={null} safedep policy edit -m "First policy: 7-day cooldown, fail on medium" ``` The command opens the policy settings document in your editor. The comments at the top show the layers of the policy. The document lists each field that you can set as a commented line, with its allowed values and its value now. To set a field, remove the `# ` at the start of its line and of the lines of its parents. Make the `base` section of the document hold these values: ```yaml theme={null} base: package_admission: cooldown: min_age: 7d scan_gate: fail_on: medium ``` The policy base applies to every endpoint and project of the tenant. Save the file and close the editor. The command saves a policy change on the server and prints its number. Nothing applies yet. This tutorial uses change 1. Use the number that the command printed. **4. Preview the change** ```bash theme={null} safedep policy change show 1 ``` The preview lists each field that changes, its old and new value, and its change direction: * `scan_gate.fail_on` shows `-` as the old value and `medium` as the new value. The `-` means that no revision of your tenant set the field, so the value `high` of the SafeDep default policy applied. SafeDep Cloud compares `medium` with `high`. A lower severity fails more checks, so this field tightens. * `package_admission.cooldown.min_age` also shows `-` as the old value. The SafeDep default policy does not set it either. A field with no value on one side counts as a change that loosens, because SafeDep Cloud cannot know what each tool did without it. So the change loosens as a whole. The preview also counts the projects that the change reaches, and how many of them can enforce each value. **5. Publish the change** ```bash theme={null} safedep policy change publish 1 -m "First policy: 7-day cooldown, fail on medium" ``` The change loosens the policy, so the command asks you to confirm. Every Owner and Admin of the tenant gets an email about the publish. The publish makes a new policy revision. To see it, run: ```bash theme={null} safedep policy revision list ``` **6. See the policy in PMG** On a machine with PMG, connect PMG to your tenant and turn on the cloud policy: ```bash theme={null} pmg config set cloud.enabled true pmg cloud login pmg config set cloud.policy true pmg cloud sync ``` `pmg cloud login` asks for the tenant ID and the API key. `pmg cloud sync` fetches the policy at once. If `pmg config set` prints `key not found`, your config file has no `cloud` section. Run `pmg config edit` and add this section to the file: ```yaml theme={null} cloud: enabled: true policy: true ``` Save the file and run `pmg cloud login` and `pmg cloud sync`. You can also run `pmg setup install` and then the `pmg config set` commands again. `pmg setup install` adds the missing keys of the PMG template to your config file. It also installs the PMG PATH shims, and on macOS and Linux the shell aliases. Then run: ```bash theme={null} pmg setup doctor ``` The cloud policy check names your tenant and the revision that PMG applied. PMG now holds back each package version that is younger than 7 days. To see the revision that each endpoint applied, run `safedep endpoint list`. **7. See the policy in a pull request check** Open a pull request that adds a package with a vulnerability of medium severity, in a repository that the app scans. The check fails. The comment of the SafeDep app starts with a block titled **SafeDep policy: failed**. The block names your tenant revision, the `scan_gate.fail_on` setting with the value `MEDIUM`, and the vulnerability that failed the check. You published a policy, and two tools apply it. The policy base applies to every endpoint and project. To set other values for a group, see [Target a Group](/governance/cloud/policy/target-a-group). ## Next steps > [card] [Block a Package](/governance/cloud/policy/block-a-package) > > Block a package for the whole tenant. > [card] [Target a Group](/governance/cloud/policy/target-a-group) > > Set other values for a group of endpoints or projects. > [card] [Policy Revisions and Changes](/concepts/policy-revisions) > > What happens between an edit and a publish. > [card] [Apply the cloud policy in PMG](/package-security/pmg/cloud-policy) > > Settings, cache and offline behavior of PMG. # Roll Back a Policy Change Source: https://docs.safedep.io/governance/cloud/policy/roll-back-a-change Restore settings, and optionally package rules, from an old revision of the cloud policy with a new policy change. A rollback does not delete a revision. It makes a new policy change that takes values from an old revision, and its publish makes a new revision with a higher number. The history stays complete. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan and the Admin role. See [pricing](https://safedep.io/pricing). ## Find the revision to restore ```bash theme={null} safedep policy revision list ``` The list shows each revision, who published it, its change direction and its message. To read the settings of one revision: ```bash theme={null} safedep policy revision show 46 ``` ## Create the rollback change Restore one capability, such as `scan_gate`: ```bash theme={null} safedep policy change create --from-revision 46 --capability scan_gate -m "Revert fail_on to high" ``` * `--capability` names a capability to restore: `scan_gate` or `package_admission`. Give it more than once for more capabilities. Without it, the change restores every capability. * For each restored capability, the policy base and every policy override take their values from revision 46. A policy override that did not exist then loses the fields of the restored capabilities. * Package rules stay as they are now. To restore the set of package rules of revision 46 as well, add `--package-rules revision`. The change then deletes the rules that came after revision 46, and creates again the rules that were removed after it, with new rule ids. A rule whose expiry at revision 46 is now in the past does not come back. The restore never keeps more package rules than the old revision had. The command prints the number of the new change and its change direction. ## Preview and publish ```bash theme={null} safedep policy change show 20 safedep policy change publish 20 -m "Revert fail_on to high" ``` Use the change number that the create command printed. The preview warns when the rollback drops fields of a policy override. A rollback that loosens the policy asks you to confirm it. Every Owner and Admin of the tenant gets an email about the rollback, also when it tightens the policy. ## Undo one package rule To undo one block or trust entry, you do not need a rollback. Delete the rule: ```bash theme={null} safedep policy rule delete r_9c1x4kq7dm --reason "Block added by mistake" ``` ## Next steps > [card] [Policy Revisions and Changes](/concepts/policy-revisions) > > Revisions, change direction and stale changes. > [card] [Audit Policy Changes](/governance/cloud/policy/audit-policy-changes) > > Find the publish that you want to undo. # Set the Dependency Cooldown from the Cloud Source: https://docs.safedep.io/governance/cloud/policy/set-a-cooldown Set the minimum age of a package version for every PMG endpoint of your tenant, or for a group of endpoints, with the cloud policy. The [PMG dependency cooldown](/package-security/pmg/dependency-cooldown) holds back package versions that are younger than a set age. The cloud policy sets this age for every PMG endpoint of your tenant with no change to each machine. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan and the Admin role. See [pricing](https://safedep.io/pricing). Each endpoint needs PMG with [`cloud.policy` on](/package-security/pmg/cloud-policy). The setting is `package_admission.cooldown.min_age`. PMG applies it. The pull request check does not apply a cooldown yet. ## Set the cooldown for the tenant 1. Open the policy settings document: ```bash theme={null} safedep policy edit -m "Cooldown 5 days" ``` 2. Set the value in the policy base: ```yaml theme={null} base: package_admission: cooldown: min_age: 5d ``` The value is a duration, as `5d` or `120h`, from 0 to 365 days. PMG rounds it up to whole days. `0` turns the cooldown off. 3. Save the file, close the editor, and publish the change that the command created: ```bash theme={null} safedep policy change show 18 safedep policy change publish 18 -m "Cooldown 5 days" ``` Use the change number that `safedep policy edit` printed. A shorter cooldown loosens the policy, and so does the first cooldown that you set, because no layer set the field before. For a change that loosens, the publish asks you to confirm it. ## Set the cooldown for a group of endpoints Add a policy override with a selector. This override sets a longer cooldown on macOS endpoints: ```yaml theme={null} overrides: - name: macs priority: 100 description: Longer cooldown on macOS laptops selector: matchLabels: {reported/os: darwin} spec: package_admission: cooldown: min_age: 7d ``` To select a group that you choose, give its endpoints a `custom/` label first. See [Target a Group](/governance/cloud/policy/target-a-group). ## Exempt one package To install a new version of one package before the cooldown ends, create a trust entry with the scope `cooldown`: ```bash theme={null} safedep policy rule create --trust pkg:npm/my-internal-sdk --scope cooldown \ --reason "First-party SDK, tested on release" --expires 90d ``` ## What the cloud value changes in PMG When the policy sets the cooldown, PMG uses the cloud value instead of `dependency_cooldown.enabled` and `dependency_cooldown.days` in its config file and in `PMG_*` environment variables. PMG refuses `--skip-dependency-cooldown`. The skip list in the PMG config still applies. One exception: under `global_lockdown: true`, a managed config file that sets `dependency_cooldown.enabled` or `dependency_cooldown.days` keeps its value, and PMG reports the field as locked. See [Apply the Cloud Policy in PMG](/package-security/pmg/cloud-policy). ## Check the value on one endpoint ```bash theme={null} safedep endpoint policy show arjuns-mbp --field package_admission.cooldown.min_age ``` The output shows the value, the layer that set it, and the exceptions that PMG reported, such as a locked field. ## Next steps > [card] [Hold Back Newly Published Versions](/package-security/pmg/dependency-cooldown) > > How the PMG cooldown works. > [card] [Target a Group](/governance/cloud/policy/target-a-group) > > Label endpoints and write a policy override. > [card] [Explain a Decision](/governance/cloud/policy/explain-a-decision) > > List the installs that the cooldown blocked. # Target a Group of Endpoints or Projects Source: https://docs.safedep.io/governance/cloud/policy/target-a-group Label endpoints and projects, then write a policy override that sets other policy values for them. A policy override sets other values for the endpoints and projects that its label selector matches. This guide labels a group, writes a policy override for it, and checks the result. For the rules of resolution, see [Policy Resolution](/concepts/policy-resolution) and [Labels](/concepts/labels). > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan and the Admin role. See [pricing](https://safedep.io/pricing). ## Choose the labels Each subject already has some labels: * An endpoint with PMG has `reported/os` and `reported/arch`, such as `reported/os=darwin`. * A project that is bound to a repository has `scm/forge`, `scm/owner` and `scm/repo`. For any other group, set a `custom/` label. For a policy override that loosens the policy, select on `custom/`, `scm/` or `safedep.io/` labels only. An endpoint sends its own `reported/` labels, so SafeDep Cloud cannot check them. ## Label projects 1. Find the projects. A repository is a project: ```bash theme={null} safedep project list --source github ``` If a repository is not in the list, create its project with `safedep project sync OWNER/REPOSITORY --source github`. Use `--source bitbucket` for a Bitbucket repository. The CLI needs `--source` when your tenant links both GitHub and Bitbucket. 2. Set the label on each project, by its exact name: ```bash theme={null} safedep project label set acme/payments-api acme/ledger --label custom/criticality=high ``` ## Label endpoints 1. Find the endpoints: ```bash theme={null} safedep endpoint list --search laptop ``` 2. Set the label. An endpoint is its id, a unique prefix of the id, or a hostname that `safedep endpoint list` showed: ```bash theme={null} safedep endpoint label set arjuns-mbp --label custom/team=release ``` A label change makes no policy revision. It applies at the next policy fetch of each endpoint, and at the next pull request check of each project. ## Write the policy override 1. Open the policy settings document: ```bash theme={null} safedep policy edit -m "payments: fail on medium" ``` 2. Add a policy override under `overrides`: ```yaml theme={null} overrides: - name: payments priority: 200 description: Stricter gate for payment services (CUST-412) selector: matchLabels: {custom/criticality: high} spec: scan_gate: fail_on: medium package_admission: cooldown: min_age: 7d ``` * `name` uses lowercase letters, digits and hyphens. Each name is unique. * `priority` is a number from 1 to 1,000,000. Each priority is unique. When two policy overrides match a subject and set one field, the higher priority wins. * `spec` holds only the fields that the policy override changes. * Leave out `id` for a new policy override. The server sets it. Keep the `id` of an existing policy override when you edit or rename it. A selector can also use `matchExpressions`, with the operators `In`, `NotIn`, `Exists` and `DoesNotExist`: ```yaml theme={null} selector: matchExpressions: - {key: reported/os, operator: In, values: [darwin, linux]} - {key: custom/team, operator: Exists} ``` 3. Save the file and close the editor. 4. Preview and publish the change that the command created: ```bash theme={null} safedep policy change show 18 safedep policy change publish 18 -m "payments: fail on medium" ``` Use the change number that `safedep policy edit` printed. A new policy override counts as a change that loosens, because it can move subjects to a looser result. So the publish asks you to confirm it. ## Check the result Before you publish, list the subjects that the selector matches: ```bash theme={null} safedep project list --selector custom/criticality=high safedep endpoint list --selector custom/criticality=high ``` `--selector` takes the selector as text. Separate the terms with commas, as in `custom/team=release,reported/os=darwin`. Every term must hold. A term can be `key=value`, `key!=value`, `key in (a,b)`, `key notin (a,b)`, `key` or `!key`. After you publish, show the policy of one subject and the layer that set each value: ```bash theme={null} safedep project policy show acme/payments-api --field scan_gate.fail_on ``` ## If the publish stops When another Admin published a change to the policy settings after you created your change, the publish stops, because your change is stale. Sync the change, read the preview again, and publish: ```bash theme={null} safedep policy change sync 18 safedep policy change show 18 safedep policy change publish 18 -m "payments: fail on medium" ``` The sync moves the base of the change to the head revision and keeps your settings as you wrote them. Your settings can undo the change of the other Admin, so read the preview before you publish. ## Select one endpoint for a short time A selector can name one endpoint by `safedep.io/endpoint-id`. Such a policy override needs an expiry: ```yaml theme={null} overrides: - name: debug-arjun priority: 900 description: No cooldown on one laptop while we debug a build (S-102) expires_at: 2026-12-01T00:00:00Z selector: matchLabels: {safedep.io/endpoint-id: 01KR0EKN6PMW0ZRFRN992H1PKX} spec: package_admission: cooldown: min_age: 0s ``` The selector takes the full endpoint id that `safedep endpoint list --output json` shows. After its expiry, the policy override matches no subject. ## Next steps > [card] [Fail Pull Request Checks](/governance/cloud/policy/pull-request-checks) > > Use a policy override on the scan gate of a group of projects. > [card] [Set a Cooldown](/governance/cloud/policy/set-a-cooldown) > > Set the cooldown for a group of endpoints. > [card] [Labels](/concepts/labels) > > Prefixes, sources and selectors. # Trust a Package After a False Positive Source: https://docs.safedep.io/governance/cloud/policy/trust-a-package Create a trust entry in the cloud policy to waive a malware, cooldown or vulnerability verdict for one package, with a reason and an expiry. Use a trust entry when your team reviewed a package and decided that a verdict is wrong for your tenant. A trust entry waives the verdicts of its scopes for one package until it expires. It replaces [Malicious Package Exclusions](/governance/cloud/package-exclusions). PMG with the cloud policy ignores exclusions. The pull request check still applies them. > [!NOTE] > > This guide needs the SafeDep Cloud Team or Enterprise plan and the Admin role. See [pricing](https://safedep.io/pricing). ## Create the trust entry ```bash theme={null} safedep policy rule create --trust pkg:pypi/foo@1.0.3 --scope malware \ --reason "False positive, S-88" --expires 30d --requested-by data-eng ``` * The selector names one package. Add a version in the PURL, or a range with `--vers`, to trust only some versions. A trust entry cannot use a prefix. * `--scope` names the verdicts to waive. Give it more than once, or use `all`. See [Choose the scope](#choose-the-scope). * `--expires` is required. It takes a duration, as `30d`, or a date, as `2027-01-26`. The expiry is at most 90 days from now. * `--reason` is required. The command warns that the rule loosens the policy, creates the rule and publishes a new policy revision. Every Owner and Admin of the tenant gets an email about it. ## Choose the scope | Scope | Use it when | Where it applies | | - | - | - | | `malware` | SafeDep marks the package as malicious or suspicious, and you reviewed it | PMG and the pull request check | | `cooldown` | You must install a new version before the dependency cooldown ends, such as your own SDK | PMG | | `vulnerability` | A pull request check fails on a vulnerability that you accept for this package | The pull request check | Choose the narrowest scope. `--scope all` expands to the scopes that exist now. A scope that a later release adds does not apply to this rule. A trust entry never waives a verdict of **verified** malware, whatever its scope. A trust entry also never skips the malware analysis. If a block entry selects the same package, the block entry wins. ## Extend or end the trust To extend the trust entry, give a new expiry. A later expiry loosens the policy: ```bash theme={null} safedep policy rule update r_a41b7c9xkd --expires 90d --reason "Reviewed again for Q1" ``` To list the trust entries that expire soon: ```bash theme={null} safedep policy rule list --effect trust --expiring 7d ``` To end the trust now, delete the rule. The delete tightens the policy: ```bash theme={null} safedep policy rule delete r_a41b7c9xkd --reason "Upstream fixed the false positive" ``` An expired trust entry no longer applies. PMG drops it at its expiry also when the endpoint is offline. ## Move from Malicious Package Exclusions Trust entries with the scope `malware` replace Malicious Package Exclusions. SafeDep Cloud does not copy exclusions into the cloud policy. For each exclusion that you still need, create a trust entry: | Exclusion field | Trust entry | | - | - | | Ecosystem, package name | The PURL, as `pkg:npm/name` | | Version | A version in the PURL. For the version `0` (all versions), give no version. | | Reason | `--reason` | | Expires At | `--expires`. A trust entry needs an expiry of at most 90 days. | PMG with `cloud.policy` on ignores the exclusions and applies only the trust entries. The pull request check still applies the exclusions. ## Next steps > [card] [Package Rules](/concepts/package-rules) > > Trust scopes and the verified malware guard. > [card] [Explain a Decision](/governance/cloud/policy/explain-a-decision) > > List the installs that a trust entry allowed. > [card] [Malicious Package](/concepts/malicious-package) > > How SafeDep classifies a package as malicious. > [card] [Command Reference](https://github.com/safedep/cli/tree/main/docs/cmd) > > Every flag of `safedep policy rule`. # SafeDep Cloud Quickstart Source: https://docs.safedep.io/governance/cloud/quickstart Create a SafeDep Cloud tenant, authenticate the safedep CLI, connect a data source, and run your first query SafeDep Cloud aggregates findings from SafeDep tools into a tenant you can query and govern from one place. The [`safedep` CLI](https://github.com/safedep/cli) is the command line client for your tenant: it handles login, endpoint fleet visibility, and SQL queries over synced data. This guide takes you from a new account to your first query. ## Create your tenant **1. Create an account** Sign up at [app.safedep.io](https://app.safedep.io/). **2. Create a tenant** Complete onboarding and create your tenant. Note the **tenant domain** (for example `your-company.safedep.io`). Tools use it to identify your tenant. > [!NOTE] > > You do not need to create an API key by hand. `safedep auth login` creates one during login. CI/CD integrations that need a static key can generate one at [app.safedep.io/settings/api-keys](https://app.safedep.io/settings/api-keys). ## Install the safedep CLI > [tab] Homebrew > > ```bash theme={null} > brew install safedep/tap/cli > ``` > [tab] npm > > ```bash theme={null} > npm install -g @safedep/cli > ``` Prebuilt binaries for Linux, macOS, and Windows are on the [releases page](https://github.com/safedep/cli/releases). ## Log in ```bash theme={null} safedep auth login ``` The command runs an OAuth device flow in your browser, selects a tenant you have access to, creates an API key, and stores the credentials in your OS keychain. Confirm the session: ```bash theme={null} safedep auth status ``` For static API key login, credential profiles, and non-interactive use, see the [authentication guide](/governance/cloud/authentication) and the [CLI command reference](https://github.com/safedep/cli/tree/main/docs/cmd). ## Connect a data source A new tenant is empty until a tool syncs data into it. Pick the source that matches what you want to see: > [card] [Repository scans](/governance/cloud/sync) > > Sync packages, vulnerabilities, and policy violations from `vet scan`, locally or in CI/CD > [card] [Package installs](/governance/cloud/endpoint-hub/package-guard) > > Track package manager activity on developer machines with PMG > [card] [AI tool inventory](/governance/cloud/endpoint-hub/inventory) > > Discover coding agents, MCP servers, and Agent Skills on endpoints with `vet endpoint scan` > [card] [GitHub App](/governance/integrations/github) > > Scan pull requests with zero setup and link the installation to your tenant Once PMG or `vet endpoint scan` reports from a machine, check your fleet from the CLI: ```bash theme={null} safedep endpoint status ``` ## Query your data Query your tenant's aggregated inventory and findings with SQL: projects, packages, endpoints, and security findings enriched with threat intelligence (vulnerabilities, EPSS, CISA KEV, OpenSSF Scorecard). For example, find your top remediation targets by critical CVE count: ```bash theme={null} safedep query exec --sql " SELECT packages.name, COUNT(DISTINCT vulnerabilities.vuln_id) AS critical_vulns FROM packages JOIN component_vulnerabilities ON component_vulnerabilities.component_id = packages.id JOIN vulnerabilities ON vulnerabilities.vuln_id = component_vulnerabilities.vulnerability_id WHERE vulnerabilities.severity_rating = 'CRITICAL' GROUP BY packages.name ORDER BY critical_vulns DESC" --limit 15 ``` > [!NOTE] > > Prefer a UI? Run the same queries from the web console at [app.safedep.io](https://app.safedep.io). See the [SQL query guide](/reference/sql-query) for the full schema, query rules, and worked examples: severity breakdowns, EPSS enrichment, malware findings, endpoint audit trails, and more. ## Next steps > [card] [Authentication Guide](/governance/cloud/authentication) > > Cloud authentication methods and API access patterns > [card] [Malware Analysis](/governance/cloud/malware-analysis) > > Detect malicious packages in your dependencies with Cloud code analysis > [card] [Cloud FAQ](/governance/cloud/faq) > > Answers to common questions > [card] [API Documentation](/reference/api-introduction) > > Integrate SafeDep Cloud with your own systems # Cloud Sync Source: https://docs.safedep.io/governance/cloud/sync How vet, PMG, and vet endpoint scan send data to your SafeDep Cloud tenant, and how to set up each source Your SafeDep Cloud tenant receives data from more than one tool. Each source syncs through its own path and shows up in a different part of the product: | Source | What it sends | Where it appears | | - | - | - | | [`vet scan`](#sync-vet-scan-results) | Packages, vulnerabilities, and policy violations per project | Projects and the [SQL query tables](/reference/sql-query) | | [PMG](#sync-package-events-from-pmg) | Package install and usage events from endpoints | [Endpoint Hub › Package Guard](/governance/cloud/endpoint-hub/package-guard) | | [`vet endpoint scan`](#sync-ai-tool-inventory) | AI tools, coding agents, MCP servers, and Agent Skills found on endpoints | [Endpoint Hub › Inventory](/governance/cloud/endpoint-hub/inventory) | | [GitHub App](/governance/integrations/github) | Pull request scan results from repositories it is installed on | Projects | Every source needs SafeDep Cloud credentials: a tenant domain and an API key. New to Cloud? Start with the [quickstart](/governance/cloud/quickstart). This page covers `vet scan` sync in full. PMG and endpoint inventory sync have their own setup guides, summarized below. ## Sync vet scan results `vet scan --report-sync` uploads scan results to your tenant, grouped by project and version. ### Prerequisites vet needs SafeDep Cloud credentials before it can sync. The fastest path is the guided setup, which walks through account, tenant, and credentials in one command: ```bash theme={null} vet cloud quickstart ``` [SafeDep Cloud Quickstart](https://www.youtube.com/embed/ykSiP547xuA) Already onboarded? See the [authentication guide](/governance/cloud/authentication#vet) to configure vet with an existing tenant and API key. ### Sync a scan ```bash theme={null} vet scan -M /path/to/package-lock.json --report-sync \ --report-sync-project my-project \ --report-sync-project-version my-project-version ``` * `--report-sync-project`: project identifier. Use a consistent convention, like the repository path (`github.com/org/repo`), so names stay unique across teams. * `--report-sync-project-version`: project version, typically a branch, tag, or commit Scan a whole repository the same way: ```bash theme={null} vet scan -D /path/to/repository \ --report-sync \ --report-sync-project github.com/org/repo \ --report-sync-project-version main ``` > [!NOTE] > > The examples use `package-lock.json`, but vet supports many package manifest formats and code analysis. ### Separate environments The version field also separates environments. Sync the same project as `production`, `staging`, or a feature branch name, then compare them side by side in SafeDep Cloud: ```bash theme={null} vet scan -D . \ --report-sync \ --report-sync-project myapp \ --report-sync-project-version staging ``` ### Enforce policy while syncing Sync and policy enforcement run in the same scan. Add a policy suite and `--filter-fail` to gate the pipeline while results still sync to your tenant: ```bash theme={null} vet scan -D . \ --policy-suite policy.yml \ --filter-fail \ --report-sync \ --report-sync-project critical-app \ --report-sync-project-version main ``` `--policy-suite` takes a v2 policy file (see the [example in the vet repository](https://github.com/safedep/vet/blob/main/samples/policy-v2.yml)); `--filter-fail` exits non-zero on a violation. The older `--filter-suite` format is documented in the [policy reference](/reference/policy-as-code). ### Review violations across projects Select **Policy Violations** in [app.safedep.io](https://app.safedep.io). The page lists the violations from all synced projects, with the component, the check, and the rule. Filter by project, version, check, or date range. ![Policy Violations page in SafeDep Cloud with vulnerability violations from three projects](https://mintcdn.com/safedep/OcmrdF-YkbEncxxA/images/cloud/policy-violations.png?fit=max\&auto=format\&n=OcmrdF-YkbEncxxA\&q=85\&s=718a4e7147e667cb007ab9f6cf915d92) > [!NOTE] > > The Policy Violations page needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ### Sync from GitHub Actions [vet-action](https://github.com/safedep/vet-action) syncs automatically when its cloud inputs are set. Add `SAFEDEP_CLOUD_API_KEY` and `SAFEDEP_CLOUD_TENANT_DOMAIN` as [GitHub Actions secrets](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions), then enable cloud sync in your workflow: ```yaml theme={null} - name: Run vet uses: safedep/vet-action@v1 with: cloud: true cloud-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} cloud-tenant: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} ``` vet-action sets project identification from the repository: the project name is `${{ github.repository }}` and the version is `${{ github.ref_name }}`. ### Sync from other CI systems The pattern is the same on any CI system: provide `SAFEDEP_API_KEY` and `SAFEDEP_TENANT_ID` as environment variables and run `vet scan` with the `--report-sync` flags. See [CI/CD & Platform Integrations](/governance/integrations/overview) for the full GitLab and Bitbucket guides. > [tab] GitLab CI > > ```yaml theme={null} > stages: > - security > > security-scan: > stage: security > image: ghcr.io/safedep/vet:latest > script: > - vet scan -D . --report-sync --report-sync-project $CI_PROJECT_PATH --report-sync-project-version $CI_COMMIT_REF_NAME > variables: > SAFEDEP_API_KEY: $SAFEDEP_API_KEY > SAFEDEP_TENANT_ID: $SAFEDEP_TENANT_ID > only: > - main > - develop > - merge_requests > ``` > [tab] Jenkins > > ```groovy theme={null} > pipeline { > agent any > > environment { > SAFEDEP_API_KEY = credentials('safedep-api-key') > SAFEDEP_TENANT_ID = credentials('safedep-tenant-id') > } > > stages { > stage('Security Scan') { > steps { > sh """ > vet scan -D . \ > --report-sync \ > --report-sync-project ${env.JOB_NAME} \ > --report-sync-project-version ${env.BRANCH_NAME} > """ > } > } > } > } > ``` > [tab] Azure DevOps > > ```yaml theme={null} > trigger: > branches: > include: > - main > - develop > > variables: > - group: safedep-credentials > > jobs: > - job: SecurityScan > displayName: 'Security Scan and Sync' > pool: > vmImage: 'ubuntu-latest' > > steps: > - script: | > vet scan -D . \ > --report-sync \ > --report-sync-project $(Build.Repository.Name) \ > --report-sync-project-version $(Build.SourceBranchName) > displayName: 'Run vet security scan' > env: > SAFEDEP_API_KEY: $(safedep-api-key) > SAFEDEP_TENANT_ID: $(safedep-tenant-id) > ``` ### What gets synced > [accordion] Package information > > * Discovered packages and versions > * Dependency relationships and metadata > * Package manifest locations and types > [accordion] Security findings > > * Vulnerability information and severity levels > * OpenSSF Scorecard metrics > * License compliance data > * Malware analysis results (if enabled) > [accordion] Policy violations > > * Policy rule violations and details > * Exception applications and status > [accordion] Project context > > * Project identification and versioning > * Scan timestamps and environment info > * Git commit information (when available) ## Sync package events from PMG [PMG](/package-security/pmg/overview) intercepts package manager commands on the endpoint and records each install as an event. With cloud sync enabled, PMG drains its local event log to your tenant automatically after each invocation, and `pmg cloud sync` pushes events immediately. Setup, login, and auto-sync tuning live on the Package Guard page: > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > Enable PMG cloud sync and view package events in Endpoint Hub ## Sync AI tool inventory `vet endpoint scan` discovers AI tooling on a machine (coding agents, MCP servers, CLI tools, IDE extensions, Agent Skills) and delivers the inventory to your tenant when vet has credentials configured. > [card] [Endpoint Inventory](/governance/cloud/endpoint-hub/inventory) > > Enable inventory sync and browse discovered AI tooling in Endpoint Hub ## Query synced data Once data lands in your tenant, query it with `safedep query exec` or the web console. The [quickstart](/governance/cloud/quickstart#query-your-data) has a worked example, and the [SQL query guide](/reference/sql-query) covers the full schema, join model, and queries across vulnerabilities, licenses, malware findings, and endpoint events. ## Troubleshooting > [accordion] Sync failures > > * Verify the API key and tenant configuration (`vet auth verify`) > * Check network connectivity to SafeDep Cloud > * Ensure project names don't contain invalid characters > [accordion] Missing data > > * Confirm `--report-sync` and the project flags are set > * Check that the scan completed successfully > * Verify the project name and version identifiers match what you expect > [accordion] Authentication issues > > * Verify the API key has sync permissions > * Check the tenant domain configuration > * Confirm credentials are set correctly in your CI/CD environment > [card] [Cloud Quickstart](/governance/cloud/quickstart) > > Set up the safedep CLI and run your first query > [card] [Authentication Guide](/governance/cloud/authentication) > > SafeDep Cloud authentication methods > [card] [Endpoint Hub](/governance/cloud/endpoint-hub/overview) > > AI tooling and package activity across your endpoints > [card] [vet-action Documentation](https://github.com/safedep/vet-action) > > Complete GitHub Actions integration guide # Talk to SafeDep Source: https://docs.safedep.io/governance/cloud/talk-to-safedep Ask your supply chain questions in plain English and let an AI agent answer from your SafeDep Cloud tenant using the safedep CLI. Install the SafeDep skill and your AI coding agent can answer questions about your tenant in plain English. Ask "which projects have critical vulnerabilities?" and the agent translates it into a [SafeDep Cloud SQL](/reference/sql-query) query, runs it through the `safedep` CLI, and hands back the result. You skip the SQL and the schema lookup. [Talk to SafeDep](https://www.youtube.com/embed/-AVog8VLWes) ## Prerequisites * A [SafeDep Cloud tenant](/governance/cloud/quickstart) with data synced from your tools. The agent can only answer what your tenant holds, so [connect at least one source](/governance/cloud/sync) first. * The `safedep` CLI installed and signed in. Run `safedep auth login`, then `safedep auth status` to confirm the tenant. See the [authentication guide](/governance/cloud/authentication). * An AI coding agent that supports skills, such as Claude Code. ## Install the skill Install the SafeDep skill in your agent. See [Install the SafeDep Skill](/get-started/safedep-skill) for Claude Code, Cursor, and other agents. ## Ask a question Type your question the way you would ask a teammate: ```text theme={null} How many projects are being monitored? ``` The agent loads the SafeDep skill, writes a tenant-scoped query, runs `safedep query exec`, and replies with the count. Every answer traces back to a real query, so you can ask the agent to show the SQL it ran. Questions that map cleanly to your synced data: | Ask | Reads from | | - | - | | How many projects are we monitoring? | Projects | | Which projects have critical vulnerabilities? | Projects, packages, vulnerabilities | | Any malicious packages blocked across dev endpoints last week? | [Package Guard events](/governance/cloud/endpoint-hub/package-guard) | | Which developer machines are running PMG? | [Endpoints](/governance/cloud/endpoint-hub/inventory) | | Which endpoints have not synced in 30 days? | Endpoints | ## Write your own queries The skill runs the same query interface you can drive by hand. To see the full table list, join edges, and query rules, read [SafeDep Cloud SQL](/reference/sql-query). When an agent answer looks off, run the query yourself with `safedep query exec` and compare. > [!NOTE] > > Queries are scoped to your authenticated tenant. The agent never sees data outside it, and you never write a tenant filter yourself. > [card] [Agentic Endpoint Investigation](/governance/cloud/endpoint-hub/agentic-investigation) > > Investigation playbooks for developer endpoints: exposure checks, block reviews, bypass audits. # Usage & On-Demand Billing Source: https://docs.safedep.io/governance/cloud/usage-billing How SafeDep Cloud seat allowances and usage-based on-demand billing work, and the CLI commands to inspect and manage them. Paid SafeDep Cloud plans include a monthly usage allowance for metered features. This page explains how the allowance is counted, what happens when you reach it, and how to opt in to usage-based billing beyond it. > [!NOTE] > > The commands on this page use the `safedep` CLI. New to it? See [SafeDep CLI Tools](/get-started/cli-tools) for what it is and how to install it. ## How allowances work A metered feature's monthly allowance is a per-seat amount multiplied by your subscription's seats, pooled across the whole tenant. Any member can consume from the shared pool. There is no per-user split. The allowance resets each billing period. [On-demand package scans](/package-security/scan/overview) are metered this way today. Per-seat amounts and unit prices are listed on the [pricing page](https://safedep.io/pricing). ## Check your usage ```bash theme={null} safedep subscription ondemand status ``` The output shows, per metered feature: * **Included limit and consumed**: the pooled allowance for the current period and how much of it is used. * **Period end**: when the allowance resets. * **Overage**: units consumed beyond the allowance this period, and their billed value, when on-demand billing is enabled. It also shows the account-level state: whether on-demand billing is enabled, whether a payment method is on file, and the payment posture. ## What happens at the allowance limit * **On-demand billing disabled** (the default): requests beyond the allowance are denied until the period resets or you add seats. * **On-demand billing enabled**: usage beyond the allowance is billed per unit, up to a monthly spending cap. ## Enable on-demand billing Prerequisites: an active paid subscription with a payment method on file. Add a payment method through the billing portal if needed: ```bash theme={null} safedep subscription portal open ``` Then opt in: ```bash theme={null} safedep subscription ondemand enable --accept-terms ``` The `--accept-terms` flag records your acceptance of the on-demand billing [terms](https://safedep.io/terms/), including the terms version, for the tenant account. Without the flag, the command prints the terms location and makes no change. ## The spending cap On-demand billing has a monthly spending cap that bounds how much overage can be billed in a period. When the cap is reached, further over-allowance requests are denied until the period resets, so a runaway automation cannot create an unbounded bill. The default cap is listed on the [pricing page](https://safedep.io/pricing). Contact [support](mailto:support@safedep.io) to adjust it. ## Disable on-demand billing ```bash theme={null} safedep subscription ondemand disable ``` Overage billing stops and the included allowance limits apply again. Usage already billed in the current period remains payable. ## Invoices and payment methods The billing portal handles payment methods, invoices, and billing history: ```bash theme={null} safedep subscription portal open ``` > [card] [On-Demand Package Scanning](/package-security/scan/overview) > > The metered feature this page's allowances apply to. > [card] [Pricing](https://safedep.io/pricing) > > Plans, per-seat allowances, and unit prices. # CycloneDX SBOM Source: https://docs.safedep.io/governance/cyclonedx-sbom Generate a Software Bill of Materials (SBOM) with security metadata using Vet `vet` supports [CycloneDX v1.6](https://cyclonedx.org/docs/1.6/json) SBOM generation. The generated SBOM lists all packages and their dependencies, including security metadata: detected vulnerabilities, malware, and license information. ## Quick Start Generate an SBOM with a custom application name: ```bash theme={null} vet scan -D /path/to/project \ --report-cdx report.cdx.json \ --report-cdx-app-name myproject ``` > [!NOTE] > > The `--report-cdx-app-name` parameter is optional. If omitted, Vet will use a default application name. ## What's Included in the SBOM The generated CycloneDX SBOM contains: > [card] Package Inventory > > Complete list of all direct and transitive dependencies > [card] Vulnerability Data > > Known vulnerabilities from OSV database and other sources > [card] License Information > > License identifiers and compliance data for each component > [card] Malware Detection > > Results from malware analysis and threat detection ## Advanced Usage ### Custom Application Metadata Provide detailed metadata about your application: ```bash theme={null} vet scan -D /path/to/project \ --report-cdx myapp-v1.2.3.cdx.json \ --report-cdx-app-name "MyApplication" ``` ### Combined with Other Reports Generate multiple report formats simultaneously: ```bash theme={null} vet scan -D /path/to/project \ --report-cdx sbom.cdx.json \ --report-json results.json \ --report-markdown report.md \ --report-cdx-app-name "production-app" ``` ### Integration with CI/CD > [tab] GitHub Actions > > ```yaml theme={null} > name: Generate SBOM > on: [push, pull_request] > > jobs: > sbom: > runs-on: ubuntu-latest > steps: > - uses: actions/checkout@v4 > > - name: Generate SBOM > run: | > docker run --rm -v "$PWD:/app" ghcr.io/safedep/vet:latest \ > scan -D /app \ > --report-cdx /app/sbom.cdx.json \ > --report-cdx-app-name "${{ github.repository }}" > > - name: Upload SBOM > uses: actions/upload-artifact@v4 > with: > name: sbom > path: sbom.cdx.json > ``` > [tab] GitLab CI > > ```yaml theme={null} > generate-sbom: > image: ghcr.io/safedep/vet:latest > script: > - vet scan -D . --report-cdx sbom.cdx.json --report-cdx-app-name "$CI_PROJECT_NAME" > artifacts: > reports: > cyclonedx: sbom.cdx.json > paths: > - sbom.cdx.json > expire_in: 30 days > ``` ## Sample SBOMs > [card] [Chat Server SBOM](/downloads/chat-server.cdx.json) > > Example SBOM for a Node.js chat application > [card] [Express.js SBOM](/downloads/express.cdx.json) > > Example SBOM for an Express.js web application ## SBOM Analysis and Consumption ### Viewing SBOM Content Install the [CycloneDX CLI](https://github.com/CycloneDX/cyclonedx-cli) (a .NET global tool) to validate and convert your SBOM: ```bash theme={null} dotnet tool install --global CycloneDX # Validate SBOM cyclonedx validate --input-file sbom.cdx.json # Convert to other formats cyclonedx convert --input-file sbom.cdx.json --output-file sbom.xml --output-format xml ``` ### Integration with Security Tools Many security tools can consume CycloneDX SBOMs: * **Dependency Track**: Import SBOMs for vulnerability monitoring * **FOSSA**: License compliance analysis * **Snyk**: Security scanning and monitoring * **JFrog Xray**: Artifact analysis and security scanning ## Naming Convention Use a consistent pattern for SBOM filenames: ``` {app-name}-{version}-{environment}.cdx.json myapp-1.2.3-production.cdx.json ``` ## Troubleshooting > [accordion] Large SBOM Files > > For projects with many dependencies, SBOMs can become large. Consider: > > * Filtering out development dependencies in production SBOMs > * Using compressed storage formats > * Implementing SBOM splitting for microservices > [accordion] Missing Components > > If components are missing from your SBOM: > > * Ensure all package manifest files are included in the scan > * Check that Vet supports your package manager > * Verify dependencies are properly declared in manifest files > [accordion] Validation Errors > > If SBOM validation fails: > > * Check the CycloneDX schema version compatibility > * Verify all required fields are present > * Use cyclonedx-cli for detailed validation errors > [card] [CycloneDX Documentation](https://cyclonedx.org/docs/1.6/json/) > > Learn more about the CycloneDX v1.6 JSON specification > [card] [Vet Repository](https://github.com/safedep/vet) > > Explore Vet's complete SBOM generation capabilities > [card] [Dependency Inventory](/governance/vet/dependency-inventory) > > Learn how to create accurate dependency inventories # Bitbucket Pipes Source: https://docs.safedep.io/governance/integrations/bitbucket Native Bitbucket Cloud integration for SafeDep > [!NOTE] > > Prefer a setup with minimal manual configuration? The [Bitbucket Cloud App](/governance/integrations/bitbucket-app) is a hosted SafeDep app that scans pull requests with no pipeline to configure or run. SafeDep integrates with **Bitbucket Cloud** via [Bitbucket Pipes](https://bitbucket.org/product/features/pipelines/integrations), so you can add dependency scanning to any Bitbucket CI/CD pipeline. ## Prerequisites > [card] Bitbucket Account > > Bitbucket account with access to your project > [card] Repository > > A source code repository to integrate SafeDep in `pipelines`. ## Quick Start ### 1. Enable CI on Your Project If you don't already have a `bitbucket-pipelines.yml`, create one ```bash theme={null} touch bitbucket-pipelines.yml ``` ### 2. Add SafeDep in your pipeline ```yaml theme={null} image: atlassian/default-image:3 pipelines: default: - step: name: Run vet pipe script: - pipe: safedep/vet-pipe:v1.2.0 ``` That's it. Default values are used for dependency scanning. For policy customization and [SafeDep Cloud](/governance/cloud/sync) integration, see the [Inputs](#inputs), [Policy](#policy-customization), and [Cloud Sync](#cloud-sync) sections. ### On Pull Request `vet-pipe` includes a feature to scan only the packages changed within a **Pull Request**. However, this functionality relies on environment variables (such as `BITBUCKET_PR_DESTINATION_BRANCH`) that are only populated when using Bitbucket's `pull-requests` pipeline trigger. To enable changed packages scanning for **PRs** while still supporting **Push** and **Merge** events, you must configure both the `pull-requests` and `default` (or branches) triggers. The most efficient way to implement this without code redundancy is as follows: ```yml theme={null} image: atlassian/default-image:3 definitions: steps: - step: &safedep-vet-pipe name: "Execute Vet Scan Pipe" script: - pipe: safedep/vet-pipe:v1.2.0 pipelines: branches: main: - step: *safedep-vet-pipe pull-requests: '**': - step: *safedep-vet-pipe ``` ## Reports `vet-pipe` supports [Bitbucket Native Code Insights Reports](https://support.atlassian.com/bitbucket-cloud/docs/code-insights/). Each **Pull Request** or **Push** gets a report, and **findings** are attached to their respective files and visible in the Bitbucket UI. ![Bitbucket UI Demo Annotations](https://mintcdn.com/safedep/5F3GnnR7FfESs3e6/images/bitbucket-ui-demo-annotations.png?fit=max\&auto=format\&n=5F3GnnR7FfESs3e6\&q=85\&s=7f3ae8c9e2839cdf02c0b74b6c208c9e) ## Inputs `vet-pipe` accepts the following variables. ### Cloud Sync > [!NOTE] > > Cloud Sync requires a subscription to [SafeDep Cloud](/governance/cloud/overview). [Cloud Sync](https://docs.safedep.io/governance/cloud/sync#cloud-sync) synchronizes scan data and policy violations with SafeDep Cloud for centralized analysis, query and reporting. Set the following variables to enable cloud sync: ```yml theme={null} image: atlassian/default-image:3 pipelines: default: - step: name: Run vet pipe script: - pipe: safedep/vet-pipe:v1.2.0 variables: CLOUD: "true" CLOUD_KEY: $CLOUD_KEY CLOUD_TENANT: $CLOUD_TENANT ``` You can generate your `CLOUD_KEY` and `CLOUD_TENANT` values from [https://app.safedep.io](https://app.safedep.io) To create these: * Sign Up / Login to [https://app.safedep.io](https://app.safedep.io) * Create your **Tenant** * Go to **Settings** * Go to **API Keys** * Then create `API Key` ### Policy Customization > [!NOTE] > > Policy customization is optional. SafeDep Pipe comes with default policies. [Policy as Code](https://docs.safedep.io/reference/policy-as-code#what-is-policy-as-code) treats security policies as configuration files evaluated by tools to make runtime decisions. To use your own policies, specify them with the `POLICY` variable. See [Policy as Code](/reference/policy-as-code) for more details. ```yml theme={null} image: alpine:latest pipelines: default: - step: name: "Run Vet Scan" script: - pipe: safedep/vet-pipe:v1.2.0 variables: POLICY: "./safedep/policy.yml" ``` > [!NOTE] > > When a policy violation occurs, the pipeline fails. To overwrite this, set `SKIP_FILTER_CI_FAIL: "true"` in **variables**, to skip **fail** when a policy violation happens. ### Other Inputs See the [`vet-pipe` Bitbucket repo](https://bitbucket.org/safedep/vet-pipe/) for more detail about other available inputs. ## Artifact Each [`vet`](https://github.com/safedep/vet) execution produces a `vet-report.json` file via the `--report-json` flag. To make this file downloadable, set the `artifacts` property in `bitbucket-pipelines.yml`: ```yaml theme={null} - step: name: "Run Vet Scan" script: - pipe: safedep/vet-pipe:v1.2.0 artifacts: - vet-report.json ``` This file will be available to download at **Pipelines > Select a Pipeline > Artifacts** in the Bitbucket UI. ## Support Raise an issue on the [vet-pipe GitHub repo](https://github.com/safedep/vet-bitbucket-pipe/issues) or the [vet-pipe Bitbucket mirror](https://bitbucket.org/safedep/vet-pipe/). # Bitbucket Cloud App Source: https://docs.safedep.io/governance/integrations/bitbucket-app Install the SafeDep app for Bitbucket Cloud and link your workspace to scan pull requests for supply-chain risk. The SafeDep app for Bitbucket Cloud scans pull requests for supply-chain risk directly in Bitbucket. It is a hosted service built on [Atlassian Forge](https://developer.atlassian.com/platform/forge/), so unlike [Bitbucket Pipes](/governance/integrations/bitbucket) there is no pipeline to configure or run yourself. * Scans newly introduced or updated dependencies on every pull request * Protects against malicious open source packages, known vulnerabilities, and risky licenses * Free for public repositories. Private (commercial) repositories need a [SafeDep subscription](https://safedep.io/pricing) * Reports to your [SafeDep Cloud](/governance/cloud/overview) tenant for centralized policy and reporting across repositories ## How it works The Forge app is a thin forwarder: it sends pull request events to SafeDep Cloud, which runs the scan and posts the results back to Bitbucket. The app holds no scan logic and makes no decisions on its own. Two safe defaults apply until you act: * An installed app does nothing until the workspace is **linked** to a SafeDep tenant. * A linked workspace scans nothing until you **enable repositories**. New links start with an empty selection (default deny). Some actions in this guide run from the SafeDep side. Each shows two paths: the **SafeDep console** at [app.safedep.io](https://app.safedep.io) and the **safedep CLI**. ## Prerequisites > [card] Bitbucket workspace > > A Bitbucket Cloud workspace where you are an admin. Installing a Forge app and linking the workspace need admin access. > [card] SafeDep Cloud account > > A SafeDep Cloud tenant. Follow the [Cloud Quickstart](/governance/cloud/quickstart) to sign up and create one. > [card] safedep CLI (optional) > > Needed only for the CLI path. The [`safedep` CLI](/get-started/cli-tools) installed, and logged in with `safedep auth login` ([authentication](/governance/cloud/authentication)). ## Step 1: Install the app > [!NOTE] > > The app is in early access. Install it with the installation link below. The Atlassian Marketplace listing is coming. > [!WARNING] > > A Bitbucket Cloud Forge app installs at the workspace level. You must be a workspace admin to install it. 1. Open the [SafeDep app installation link](https://developer.atlassian.com/console/install/eeb66bc9-cae4-4606-abb7-97854a77672e?signature=AYABeNgkco8ssLhE8kqOVbe4FQsAAAADAAdhd3Mta21zAEthcm46YXdzOmttczp1cy13ZXN0LTI6NzA5NTg3ODM1MjQzOmtleS83MDVlZDY3MC1mNTdjLTQxYjUtOWY5Yi1lM2YyZGNjMTQ2ZTcAuAECAQB4IOp8r3eKNYw8z2v%2FEq3%2FfvrZguoGsXpNSaDveR%2FF%2Fo0BBBzUyKkOoOa4hk817f%2B1sAAAAH4wfAYJKoZIhvcNAQcGoG8wbQIBADBoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDB4sU9EZWhdzpc3RrgIBEIA716z3L%2FGiDmxErAFYrW6KaL3%2B%2BmX6ZOf7%2Fp1D%2B5ctLIYt7fDtXep%2FOEjAEsE5DjbCqp%2BXAF8hZ2NTeJ0AB2F3cy1rbXMAS2Fybjphd3M6a21zOmV1LXdlc3QtMTo3MDk1ODc4MzUyNDM6a2V5LzQ2MzBjZTZiLTAwYzMtNGRlMi04NzdiLTYyN2UyMDYwZTVjYwC4AQICAHijmwVTMt6Oj3F%2B0%2B0cVrojrS8yZ9ktpdfDxqPMSIkvHAFgvz4G7XtKQzuDYpnT7J3qAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM6Vv9ozURpDaBj9ToAgEQgDvm430uuNf143RTJM2FV3Pp%2F3aBd9zf5OThrtV9L%2FQexO4v%2FADmC4YI6RT3DDeyWswldyZEZsHWyqOFkwAHYXdzLWttcwBLYXJuOmF3czprbXM6dXMtZWFzdC0xOjcwOTU4NzgzNTI0MzprZXkvNmMxMjBiYTAtNGNkNS00OTg1LWI4MmUtNDBhMDQ5NTJjYzU3ALgBAgIAeLKa7Dfn9BgbXaQmJGrkKztjV4vrreTkqr7wGwhqIYs5ARkiEygdQdaWwaohI8WY4G4AAAB%2BMHwGCSqGSIb3DQEHBqBvMG0CAQAwaAYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAzyrzmb4i%2Fo9SmcN7kCARCAOyZtnQCQbRTwY463sxcbUt2DKDiCUyBcoM8QIPKD%2FejhjjNrQcAKPtsIM%2FlJvzexWhJwkqLydnA5zkYdAgAAAAAMAAAQAAAAAAAAAAAAAAAAAN7cwa40QLP6j60bfUQw7VD%2F%2F%2F%2F%2FAAAAAQAAAAAAAAAAAAAAAQAAADI8mC%2B1BfhRCcUZyqhZKqujFHOOFamQw%2Bm9a1FrKHxqvSdAl3DpB5AL4Iy6QR7W5cZBZVMY29pK0XIqWRfg6Mvq4kc%3D\&product=bitbucket). 2. Select the workspace to install into and confirm. You can also start the install from the SafeDep console. Open **Setup**, and select **Install Bitbucket App**. ![Install Bitbucket App button in the SafeDep console, under Setup then Integrations](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/1-install-bitbucket-app-from-dashboard.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=f4105c4ad987e4a3c9a9e24aaf8c4997) Installing the app adds a **SafeDep** page to your workspace settings. ## Step 2: Link your workspace Linking pairs the Bitbucket workspace with your SafeDep tenant. A short-lived, single-use **link code** proves that the same person controls both sides. > [tab] SafeDep console > > Generate a link code: > > 1. Open **Setup**. > 2. On the **Bitbucket App** card, select **Link a workspace**. > 3. Copy the code from the panel. > > ![Link a Bitbucket workspace panel in the SafeDep console, with the link code and its expiry](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/2-copy-link-code.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=f7a2338c2d98ca453e29664cdef72674) > > The panel shows the time left before the code expires. Select **Issue a new code** to replace it. A new code invalidates the earlier one. > > Redeem the code in Bitbucket: > > 1. In Bitbucket, select the settings icon, then **Workspace settings**. > > ![Bitbucket settings menu with Workspace settings under Bitbucket Administration](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/3-go-to-settings-then-workspace-settings.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=3846795901027a00eb9a193374a3f6d7) > > 2. In the sidebar, under **Forge Apps**, select **SafeDep**. > > ![SafeDep entry under Forge Apps in the Bitbucket workspace settings sidebar](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/4-find-safedep-app-in-bitbucket-console.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=d871eed1350ca1fcf5d54937fb88d408) > > 3. Paste the code in **Link code**, then select **Link workspace**. > > ![SafeDep page in Bitbucket workspace settings with the link code pasted](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/5-past-code-in-bitbucket-console.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=9f9a9b21699a246e899568938db228d8) > > Keep the console panel open. Wait until the workspace links successfully. > [tab] safedep CLI > > Generate a link code: > > ```bash theme={null} > safedep integration bitbucket link create > ``` > > The command prints the code and its expiry. The code is single-use and shown once. Running the command again generates a new code and invalidates every earlier unredeemed one, so re-running is the way to start over. > > Redeem the code in Bitbucket: > > 1. In Bitbucket, select the settings icon, then **Workspace settings**. > 2. In the sidebar, under **Forge Apps**, select **SafeDep**. > 3. Paste the code in **Link code**, then select **Link workspace**. > > The page shows the linked tenant when the redeem succeeds. Verify from the CLI: > > ```bash theme={null} > safedep integration bitbucket link list > ``` ## Step 3: Enable repositories for scanning A fresh link scans nothing. The workspace has a scan scope, `selected` (the default) or `all`: * **`selected`**: only repositories on the allowlist are scanned. * **`all`**: every repository in the workspace is scanned. > [tab] SafeDep console > > 1. Open **Setup**, then **Integrations**. The **Bitbucket App** card shows **Connected**. > > 2. Select **Manage repositories**. > > ![Bitbucket App card in the SafeDep console, connected, with the Manage repositories button](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/6-safedep-console-see-connected-and-manage-repositories.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=a32dfe34d4b9c4c98789d1af1df53563) > > 3. Set **Scan scope** to **All repositories** or **Selected**. > > 4. For **Selected**, turn on the toggle for each repository to scan. Turn a toggle off to stop scanning that repository. > > ![Bitbucket repositories panel with the scan scope and per repository toggles](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/7-select-repositoreis-and-enable-them-for-scaning.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=7ca4f528eab82c8d684ecc0873225dcf) > > Optionally, select **Sync to Projects** to list the enabled repositories under Projects. > [tab] safedep CLI > > List the workspace's repositories with their UUIDs and current state: > > ```bash theme={null} > safedep integration bitbucket repository list > ``` > > Enable specific repositories by UUID: > > ```bash theme={null} > safedep integration bitbucket allowlist update --scope selected \ > --enable 9a2b3c4d-0000-0000-0000-000000000001 > ``` > > Or scan the whole workspace: > > ```bash theme={null} > safedep integration bitbucket allowlist update --scope all > ``` > > Use `--disable` to remove a repository from the allowlist. Switching scope does not change the stored allowlist, so moving from `all` back to `selected` restores your earlier selection. > > > [accordion] Optional: sync repositories as SafeDep projects > > > > Adopt enabled Bitbucket repositories as SafeDep **projects** so scan results are organized per project in your tenant. > > > > ```bash theme={null} > > safedep project sync my-workspace/my-repo --source bitbucket > > ``` > > > > Select by name (`workspace/repository`) or by the immutable repository UUID from `repository list`. The UUID flag implies the Bitbucket source, so `--source` is not needed: > > > > ```bash theme={null} > > safedep project sync --repository-uuid 9a2b3c4d-0000-0000-0000-000000000001 > > ``` > > > > The sync is idempotent: repeating it returns the same project for the same repository. When you sync by name and your tenant has both a GitHub installation and a Bitbucket workspace linked, pass `--source bitbucket` explicitly. ## Step 4: Scan a pull request Open or update a pull request on an enabled repository. The app scans changed dependencies and reports on: * [Malicious / Suspicious packages](/governance/cloud/malware-analysis) * Vulnerabilities * Risky licenses Results appear in the pull request as a comment from the SafeDep app, and the full report is available in your SafeDep Cloud tenant. ![Comment from the SafeDep app on a Bitbucket pull request with the report summary and package details](https://mintcdn.com/safedep/obRSkvJc_TiAN1_P/images/bitbucket/8-pull-request-scanning-example.png?fit=max\&auto=format\&n=obRSkvJc_TiAN1_P\&q=85\&s=89772ef244d7644745902e9f533bd029) ## Set the gate with the cloud policy The check reads the [cloud policy](/governance/cloud/policy/overview) of your tenant when the tenant has the Team or Enterprise plan. The policy decides the lowest vulnerability severity that fails the check, and its block and trust entries apply to the packages of the pull request. Verified malware always fails the check. With no cloud policy, the SafeDep default policy applies: the check fails on critical and high vulnerabilities. The GitHub App reads the same policy, so one policy covers both forges. To target Bitbucket projects only, select on the `scm/forge=bitbucket` label. The check sets the build status of the commit. A failing check shows a policy block at the top of the pull request comment. The block names the policy revision and the rule or setting that failed each finding. See [Fail Pull Request Checks](/governance/cloud/policy/pull-request-checks). ## Unlink or uninstall Uninstall the SafeDep app from **Workspace settings**, under **Installed apps**, in Bitbucket. Uninstalling revokes the workspace link and deletes the workspace credential SafeDep holds. To connect again later, reinstall the app and link with a fresh code. > [!NOTE] > > Unlinking from the SafeDep side (CLI or console) without uninstalling the app is planned. ## Troubleshooting | Symptom | Cause and fix | | - | - | | "Could not link" on the settings page | The code is wrong, expired, or already used. Generate a new code and retry: select **Issue a new code** in the console, or run `safedep integration bitbucket link create`. Link codes are single-use and short-lived. | | Settings page says the workspace is already linked | A workspace links to one tenant at a time. Uninstall and reinstall the app to link it to a different tenant. | | Repeated failed link attempts are rejected | Redeems are rate limited per workspace. Wait a few minutes and retry with a fresh code. | | `repository list` reports the workspace as not accessible | The workspace credential is missing or expired. Open the SafeDep settings page in Bitbucket once to refresh it, then retry. | | A pull request gets no comment or status | Confirm the repository is enabled. In the console, select **Manage repositories**. In the CLI, `safedep integration bitbucket repository list` shows each repository's state and the workspace scan scope. | | `project scan create` fails with "Project not scannable" | On-demand scans are not available for Bitbucket projects yet. See limitations below. | ## Limitations * **On-demand scans** (`safedep project scan create`) are not available for Bitbucket projects yet. Pull request scanning is the scan path today. * **Merge checks** (blocking a merge on a failing scan) are not available yet. * The app authenticates to Bitbucket with a workspace-wide credential issued by Atlassian. Per-repository credentials are not part of the Forge model. # DefectDojo Integration Source: https://docs.safedep.io/governance/integrations/defectdojo Integrate Vet with DefectDojo for centralized vulnerability tracking and management `vet` integrates with [DefectDojo](https://github.com/DefectDojo/django-DefectDojo) to export vulnerabilities, policy violations, and other findings. Each scan is reported as a new engagement in DefectDojo. ## Prerequisites > [card] Docker & Docker Compose > > Required for running DefectDojo locally > [card] DefectDojo Instance > > Either local or cloud-hosted DefectDojo installation > [card] Vet CLI > > Install Vet following the quickstart guide > [card] API Access > > DefectDojo API key for authentication If you don't have Vet installed yet, follow the [quickstart guide](/governance/vet/quickstart) to get started. ## Quick Setup with Docker The steps below use Docker Compose to run DefectDojo locally and scan the [demo-client-python](https://github.com/safedep/demo-client-python) repository as a worked example. ### Setup DefectDojo **1. Clone DefectDojo** Download the DefectDojo repository: ```bash theme={null} git clone https://github.com/DefectDojo/django-DefectDojo.git --depth 1 cd django-DefectDojo ``` **2. Start Services** Launch DefectDojo with Docker Compose: ```bash theme={null} docker compose up -d ``` > [!NOTE] > > This will take a while as it builds images and downloads dependencies. **3. Get Admin Password** Retrieve the admin password from the logs: ```bash theme={null} docker compose logs initializer | grep "Admin password:" ``` > [!NOTE] > > The initializer container runs migrations and creates initial data, which may take several minutes. **4. Access DefectDojo** Navigate to `http://localhost:8080` and login with: * **Username**: `admin` * **Password**: (from previous step) ![DefectDojo Login](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/defect-dojo-integration/dd-1-login.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=b925e220475eccc1a93ee6a6e8d286a7) ### Configure Your Project **1. Create Product** Create a new product called `demo-client-python` and note the product ID: ![DefectDojo Add Product](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/defect-dojo-integration/dd-2-add-product.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=7819b8b4dd84cd493cd3001a1c5500fd) ![DefectDojo Product ID](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/defect-dojo-integration/dd-3-observe-product-id.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=672f362fc7f0180e7511506e3b187201) **2. Generate API Key** Navigate to `http://localhost:8080/api/key-v2` to generate an API key for Vet integration. **3. Set Environment Variable** Configure the API key for Vet usage: ```bash theme={null} export DEFECT_DOJO_APIV2_KEY= ``` ## Scanning with Vet Now you can scan a project and send results to DefectDojo: ```bash theme={null} vet scan --github https://github.com/safedep/demo-client-python \ --filter-suite /path/to/your/policy-suite.yml \ --report-defect-dojo \ --defect-dojo-host-url http://localhost:8080/ \ --defect-dojo-product-id ``` Each scan creates a new engagement in DefectDojo; policy violations are reported as findings and visible in DefectDojo's dashboard. > [!WARNING] > > Currently, Vet reports only policy violations to DefectDojo. Support for reporting vulnerabilities and malicious package information is planned in [GitHub issue #430](https://github.com/safedep/vet/issues/430). ## Advanced Configuration ### Custom Policy Suites Example policy suite for DefectDojo integration: ```yaml theme={null} # defectdojo-policy.yml name: DefectDojo Security Policy description: Comprehensive policy for DefectDojo integration filters: - name: critical-vulnerabilities value: | vulns.critical.size() > 0 - name: high-risk-packages value: | vulns.high.size() > 3 - name: license-violations value: | !licenses.exists(p, p in ["MIT", "Apache-2.0", "BSD-3-Clause"]) - name: unmaintained-packages value: | scorecard.scores.Maintained < 5 ``` ### CI/CD Integration > [tab] GitHub Actions > > ```yaml theme={null} > name: Security Scan to DefectDojo > on: [push, pull_request] > > jobs: > security-scan: > runs-on: ubuntu-latest > steps: > - uses: actions/checkout@v4 > > - name: Run vet security scan > run: | > vet scan -D . \ > --filter-suite .github/security-policy.yml \ > --report-defect-dojo \ > --defect-dojo-host-url ${{ secrets.DEFECT_DOJO_URL }} \ > --defect-dojo-product-id ${{ secrets.DEFECT_DOJO_PRODUCT_ID }} > env: > DEFECT_DOJO_APIV2_KEY: ${{ secrets.DEFECT_DOJO_API_KEY }} > ``` > [tab] GitLab CI > > ```yaml theme={null} > security-scan: > image: ghcr.io/safedep/vet:latest > script: > - vet scan -D . > --filter-suite security-policy.yml > --report-defect-dojo > --defect-dojo-host-url $DEFECT_DOJO_URL > --defect-dojo-product-id $DEFECT_DOJO_PRODUCT_ID > variables: > DEFECT_DOJO_APIV2_KEY: $DEFECT_DOJO_API_KEY > ``` ### Multiple Projects For organizations with multiple projects, create separate products in DefectDojo: ```bash theme={null} # Project A vet scan -D ./project-a \ --report-defect-dojo \ --defect-dojo-product-id 1 # Project B vet scan -D ./project-b \ --report-defect-dojo \ --defect-dojo-product-id 2 ``` ## Troubleshooting > [accordion] API Key Issues > > If authentication fails: > > * Verify the API key is correctly set in the environment > * Check that the API key has sufficient permissions > * Ensure the DefectDojo URL is accessible from your environment > [accordion] Product ID Errors > > If the product ID is invalid: > > * Verify the product exists in DefectDojo > * Check that you have access to the specified product > * Ensure the product ID is numeric, not the product name > [accordion] No Findings Reported > > If no findings appear in DefectDojo: > > * Confirm that policy violations exist in your scan > * Check the Vet scan output for errors > * Verify the DefectDojo integration is properly configured > [card] [DefectDojo Documentation](https://documentation.defectdojo.com/) > > Learn more about DefectDojo features and configuration > [card] [Policy as Code Guide](/reference/policy-as-code) > > Create effective security policies for DefectDojo integration > [card] [Vet GitHub Issues](https://github.com/safedep/vet/issues/430) > > Track progress on enhanced DefectDojo integration features > [card] [Demo Repository](https://github.com/safedep/demo-client-python) > > Use the demo repository to test your DefectDojo integration # GitHub App Source: https://docs.safedep.io/governance/integrations/github Set up the SafeDep GitHub App to scan pull requests for supply-chain risk. The [SafeDep GitHub App](https://github.com/apps/safedep) scans pull requests for supply-chain risk directly in GitHub. It is a hosted service run by SafeDep, so unlike the [GitHub Action](https://github.com/safedep/vet-action) there is nothing to configure or run yourself: it activates immediately after installation. * Zero-configuration installation with immediate visibility of security findings * Protects against malicious open source packages, known vulnerabilities, and risky licenses * Free for public open source repositories. Private (commercial) repositories need a [SafeDep subscription](https://safedep.io/pricing) * Optionally link the installation to your [SafeDep Cloud](/governance/cloud/overview) tenant for centralized policy and reporting across repositories ## How to Install 1. Navigate to [SafeDep GitHub App](https://github.com/apps/safedep) 2. Click *Install* 3. Follow the instructions to install the app in your GitHub organization or repository ## How to Use The SafeDep GitHub App automatically scans pull requests for open source dependency changes. Newly introduced or updated dependencies are checked for vulnerabilities and malware. ### Reports ![GitHub App Report Demo](https://mintcdn.com/safedep/bmKYGdrg5odg4UQV/images/github-app-report-demo.png?fit=max\&auto=format\&n=bmKYGdrg5odg4UQV\&q=85\&s=0e975f183937fe694d8cdbfe5d12efe9) On every pull request, the app scans updated packages and reports on: * [Malicious / Suspicious](/governance/cloud/malware-analysis) * [Vulnerabilities](#appendix) * [Risky Licenses](#appendix) ### Active Protection ![GitHub App Gating Demo](https://mintcdn.com/safedep/bmKYGdrg5odg4UQV/images/github-app-gating-demo.png?fit=max\&auto=format\&n=bmKYGdrg5odg4UQV\&q=85\&s=ab0f4bbe069f04213fae7256184a52a4) When any report fails, the GitHub App **Check** fails and blocks the branch from merging. The check fails if any *Verified Malicious Package*, *Vulnerability*, or *Risky License* is found. ### Cloud Policy When the installation is linked to a SafeDep Cloud tenant on the Team or Enterprise plan, the check reads the [cloud policy](/governance/cloud/policy/overview) of the tenant. The policy decides the lowest vulnerability severity that fails the check, and its block and trust entries apply to the packages of the pull request. Verified malware always fails the check. With no cloud policy, the SafeDep default policy applies: the check fails on `CRITICAL` and `HIGH` vulnerabilities, as above. A failing check shows a policy block in the comment and in the check run output. The block names the policy revision and the rule or setting that failed each finding. See [Fail Pull Request Checks](/governance/cloud/policy/pull-request-checks). ## Appendix ### Vulnerabilities * Checks for `CRITICAL` or `HIGH` severity vulnerabilities. * Uses [OSV](https://osv.dev) as the vulnerability database. ### Risky Licenses * The app currently classifies the following licenses as **Risky**: * `GPL-2.0` * `GPL-2.0-only` * `GPL-2.0-or-later` * `GPL-3.0` * `GPL-3.0-only` * `GPL-3.0-or-later` * `AGPL-3.0` * `AGPL-3.0-only` * `AGPL-3.0-or-later` ### Supported Lockfiles Supported lockfiles and ecosystems: 1. **NPM** * `package-lock.json` * `pnpm-lock.yaml` * `yarn.lock` 2. **GoLang** * `go.mod` 3. **PyPI** * `requirements.txt` * `uv.lock` * `poetry.lock` * `Pipfile.lock` 4. **RubyGems** * `Gemfile.lock` 5. **Cargo (Rust)** * `Cargo.lock` 6. **Packagist (PHP)** * `composer.lock` 7. **Maven (Java)** * `pom.xml` * `gradle.lockfile` > [card] [GitHub Code Scanning](/governance/integrations/github-code-scanning) > > Surface Vet findings in GitHub code scanning via SARIF. > [card] [Platform Integrations](/governance/integrations/overview) > > Wire Vet into other CI/CD platforms. > [card] [Vet Quickstart](/governance/vet/quickstart) > > Scan a repository from the CLI. > [card] [Fail Pull Request Checks](/governance/cloud/policy/pull-request-checks) > > Set the policy that the app enforces. # GitHub Code Scanning Source: https://docs.safedep.io/governance/integrations/github-code-scanning Integrate Vet with GitHub Actions and Code Scanning for automated security alerts. GitHub supports [uploading SARIF](https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning) reports for repository and organization-wide visibility of security events. `vet` exports policy violation reports as SARIF for upload to GitHub Code Scanning. ## Quick Setup with GitHub Action `vet` has a dedicated GitHub Action, which is the recommended approach for most teams. ### Basic Configuration Create `.github/workflows/vet.yml` in your repository: ```yaml theme={null} name: OSS Security Scan on: push: branches: [ main ] pull_request: branches: [ main ] permissions: contents: read security-events: write pull-requests: write jobs: vet-scan: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Run vet id: vet uses: safedep/vet-action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload SARIF if: steps.vet.outputs.report != '' uses: github/codeql-action/upload-sarif@v3 with: sarif_file: ${{ steps.vet.outputs.report }} category: vet ``` > [!NOTE] > > SARIF reports work when you enable GitHub Code Scanning in your repository. [Learn more](https://docs.github.com/en/code-security/code-scanning/enabling-code-scanning) ### Advanced Configuration To use a custom policy: ```yaml theme={null} - name: Run vet with custom policy id: vet uses: safedep/vet-action@v1 with: policy: '.github/vet/policy.yml' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` ## Manual SARIF Generation To generate a SARIF report using the `vet` CLI: ```bash theme={null} vet scan -D /path/to/project --report-sarif /path/to/report.sarif ``` > [!NOTE] > > By default the SARIF report includes vulnerabilities and malware findings. To also report policy violations, pass a policy with `--policy` or `--policy-suite` during the scan. ## Viewing Results Once uploaded, policy violations appear in the GitHub Security tab, giving a centralized view across repositories. ![GitHub Code Scanning Alerts](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet-github-code-scanning-alerts.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=c678fdb39373894c1c45958eda1b2a71) ## Pull Request Integration The GitHub Action adds a comment to pull requests when security issues are found: ![vet GitHub Action PR comment](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet-github-action-pr.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=c3bf76f16bde89090aa2dca06ccd5c6b) ## Best Practices > [accordion] Pin third-party actions to commit SHAs > > For production workflows, pin third-party GitHub Actions to a full commit SHA rather than a mutable tag. This protects against tag-moving attacks, where a compromised upstream action could inject malicious code. > > ```yaml theme={null} > # Instead of: > uses: actions/checkout@v4 > > # Pin to a specific commit SHA: > uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 > ``` > > The [actions/checkout](https://github.com/actions/checkout/releases) and [github/codeql-action](https://github.com/github/codeql-action/releases) release pages list the commit SHA for each release. `safedep/vet-action` uses [semantic versioning tags](https://github.com/safedep/vet-action/releases) maintained directly by SafeDep. ## Troubleshooting > [accordion] SARIF Upload Fails > > Ensure the `security-events: write` permission is set in your workflow file and that Code Scanning is enabled for your repository. > [accordion] No Violations Reported > > Check that your policy configuration is correct and that violations actually exist. Use `--report-json` locally to debug. > [card] [vet-action Repository](https://github.com/safedep/vet-action) > > View the complete documentation and examples > [card] [Full Example Workflow](https://github.com/safedep/vet-action/blob/main/example/vet-ci.yml) > > See a complete GitHub Actions workflow example # GitLab Dependency Scanning Source: https://docs.safedep.io/governance/integrations/gitlab Native GitLab integration for dependency security scanning with Vet. `vet` integrates with GitLab Dependency Scanning to detect malicious and vulnerable dependencies on every push and merge request. [GitLab Dependency Scanning with vet](https://www.youtube.com/embed/3FwcVVR9-1c?si=EyqimClJRLCFftnB) ## Prerequisites > [card] GitLab Account > > Active GitLab account with access to your project > [card] Ultimate Plan > > GitLab Group with Ultimate Plan for security scanning features > [!NOTE] > > Security scanning features are only available to GitLab Ultimate plans. Free users can still use the **Vet CI component** to find vulnerabilities and check policy violations. See the [demo video](https://www.youtube.com/watch?v=QJfSRc4p-z4) for free usage. ## Quick Setup ### 1. Enable CI on Your Project Create a `.gitlab-ci.yml` file in the root of your project: ```bash theme={null} touch .gitlab-ci.yml ``` ### 2. Add Vet as a CI Component Add the following to your `.gitlab-ci.yml` file: ```yaml theme={null} include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 ``` Commit and push to trigger your first scan. ## Viewing Results Once configured, the `vet` job appears in your pipeline with a security tab: ![GitLab Pipeline with vet](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/gitlab/pipeline.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=fa44b795114f4263cbdec2500d5de0a0) View vulnerabilities and malware findings in the security tab: ![GitLab Security Vulnerabilities](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/gitlab/vuls.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=9168f068ce6fd2fc25212b2e2f3f64a9) Access detailed reports at **Project > Secure > Vulnerability Report**: ![GitLab Vulnerability Dashboard](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/gitlab/dashboard.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=42fa6fbd0b567280744bcda8fd4c501e) ## Configuration Options ### Cloud Sync Integration Enable [SafeDep Cloud](/governance/cloud/quickstart) synchronization: ```yaml theme={null} include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 inputs: cloud: true cloud-key: $SAFEDEP_CLOUD_API_KEY cloud-tenant: $SAFEDEP_CLOUD_TENANT_DOMAIN ``` > [!WARNING] > > Store `SAFEDEP_CLOUD_API_KEY` and `SAFEDEP_CLOUD_TENANT_DOMAIN` as GitLab CI/CD variables for security. ### Policy Configuration Use custom policies for advanced filtering: ```yaml theme={null} include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 inputs: policy: '.gitlab/vet/policy.yml' ``` The CI job fails if any policy violations are found. Check the logs to identify which policies were violated. ### Version Control Specify which version of `vet` to use: ```yaml theme={null} include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 inputs: version: v1.9.0 ``` > [!NOTE] > > These are two independent versions: the component tag (`@v1.5.1`) pins the GitLab CI component, and the `version` input pins the `vet` binary the component downloads and runs. ### Trusted Registries Configure trusted registry URLs for package verification: ```yaml theme={null} include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 inputs: trusted-registries: - https://registry.npmjs.org - https://pypi.org ``` ### Artifact Access Control who can access scan artifacts: ```yaml theme={null} include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 inputs: artifact-access: 'developer' # Options: all, developer, none ``` > [!WARNING] > > Only use `all` if you are comfortable exposing security scan results publicly. ## Advanced Examples ### Multi-Stage Pipeline ```yaml theme={null} stages: - security - build - deploy include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 inputs: stage: security policy: '.gitlab/security-policy.yml' cloud: true cloud-key: $SAFEDEP_CLOUD_API_KEY cloud-tenant: $SAFEDEP_CLOUD_TENANT_DOMAIN build: stage: build script: - echo "Building application..." needs: ["vet"] ``` ### Conditional Scanning ```yaml theme={null} include: - component: gitlab.com/safedep/ci-components/vet/scan@v1.5.1 rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == "main" ``` ## Troubleshooting > [accordion] Security Tab Not Visible > > Ensure your GitLab plan includes security scanning features. Ultimate plan is required for the security dashboard. > [accordion] CI Component Not Found > > Verify you're using the correct component path and version. Check the [GitLab Component Catalog](https://gitlab.com/explore/catalog/safedep/ci-components/vet) for the latest version. > [accordion] Policy Violations Failing Build > > This is expected behavior when violations are found. Review the job logs to see which policies were violated, then fix the issues or adjust your policy configuration. > [card] [GitLab Component](https://gitlab.com/explore/catalog/safedep/ci-components/vet) > > View complete configuration options and examples > [card] [Report Issues](https://gitlab.com/safedep/ci-components/vet/-/issues) > > Report bugs or request improvements # Platform Integrations Source: https://docs.safedep.io/governance/integrations/overview Integrate Vet into your CI/CD and developer platforms for automated supply-chain scanning. Run SafeDep where your code already lives. Vet plugs into common CI/CD and developer platforms to scan dependencies automatically on every change. > [card] [GitHub App](/governance/integrations/github) > > Install the SafeDep GitHub App to scan pull requests. > [card] [GitHub Code Scanning](/governance/integrations/github-code-scanning) > > Run Vet in GitHub Actions and surface findings in code scanning. > [card] [GitLab](/governance/integrations/gitlab) > > Scan dependencies in GitLab CI. > [card] [Bitbucket Cloud App](/governance/integrations/bitbucket-app) > > Install the SafeDep app for Bitbucket Cloud to scan pull requests. > [card] [Bitbucket Pipes](/governance/integrations/bitbucket) > > Scan with Bitbucket Pipes. > [card] [DefectDojo](/governance/integrations/defectdojo) > > Send findings to DefectDojo for tracking. > [card] [Terraform](/governance/terraform-audit) > > Audit Terraform providers for supply-chain risk. # Visibility & Governance Source: https://docs.safedep.io/governance/overview Scan repositories, SBOMs, and CI/CD for supply-chain risk, and govern policy and visibility across your org. See the open-source risk in everything you depend on, then govern it across your organization. Scan repositories and pipelines, generate bills of materials, and manage policy and fleet-wide visibility from SafeDep Cloud. > [card] [Scan repositories](/governance/vet/overview) > > **Vet** finds malicious, vulnerable, and risky dependencies in code, lockfiles, and SBOMs. > [card] [Generate a BOM](/governance/xbom/overview) > > **xBom** inventories dependencies plus AI, SaaS, and crypto usage. > [card] [Integrate with CI/CD](/governance/integrations/overview) > > Wire SafeDep into GitHub, GitLab, Bitbucket, and more. > [card] [Govern org-wide](/governance/cloud/overview) > > **SafeDep Cloud** centralizes policy, endpoints, and visibility. > [card] [Set one policy for the tenant](/governance/cloud/policy/overview) > > **Cloud Policy** blocks and trusts packages, sets the cooldown, and decides what fails a pull request check. # Shadow AI in Code Source: https://docs.safedep.io/governance/shadow-ai-detection Detect AI and LLM SDK usage in your codebase using static code analysis and generate an SBOM with AI component evidence Shadow AI is the unauthorized use of AI services and SDKs within a codebase. Developers may integrate OpenAI, Anthropic, LangChain, or other AI services without security review, creating blind spots in your software supply chain. This guide walks you through detecting Shadow AI using `vet`'s static code analysis, querying the results, and generating a CycloneDX SBOM enriched with AI component evidence. ## Prerequisites * `vet` [installed](/governance/vet/quickstart) * Access to the source code you want to analyze ## Workflow **1. Scan source code** Analyze your source code and build a code analysis database. Use `--app` to specify your application directories and `--import-dir` for vendored or third-party dependencies. ```bash theme={null} vet code scan --db code.db \ --app ./src \ --import-dir ./vendor ``` This parses source files, builds call graphs, and matches function calls against embedded signature patterns. Results are stored in a SQLite database. > [!TIP] > > Use `--exclude` to skip test files or generated code: > > ```bash theme={null} > vet code scan --db code.db \ > --app ./src \ > --exclude ".*test.*" --exclude ".*__pycache__.*" > ``` **2. Query for AI components** Inspect what AI and LLM SDKs were detected using the `--tag ai` filter: ```bash theme={null} vet code query --db code.db --tag ai ``` This lists all signature matches tagged as AI, showing the file path, line number, and matched call pattern. You can also combine tags for a broader view: ```bash theme={null} vet code query --db code.db --tag ai --tag ml ``` To see more results or filter by language: ```bash theme={null} vet code query --db code.db --tag ai --language python --limit 200 ``` **3. Generate SBOM with AI evidence** Run `vet scan` with the code analysis database to produce a CycloneDX SBOM enriched with AI component evidence: ```bash theme={null} vet scan -D ./src --code code.db --report-cdx sbom.json ``` The generated SBOM includes AI components as evidence-backed entries, making Shadow AI usage visible to downstream security and compliance tooling. ## Understanding the Output ### Package-level AI usage When an AI SDK is both declared as a dependency and used in code, it appears with `source-code-analysis` evidence: ```json theme={null} { "bom-ref": "pkg:pypi/openai@1.0.0", "evidence": { "identity": [ { "methods": [{ "technique": "source-code-analysis", "confidence": 1.0 }] } ], "occurrences": [ { "location": "src/ai.py", "line": 42, "additionalContext": "openai.OpenAI" } ] }, "properties": [ { "name": "ai", "value": "true" } ] } ``` ### Application-level AI usage AI capabilities detected in first-party code (e.g., direct standard library HTTP calls to AI endpoints) appear as standalone xBOM components: ```json theme={null} { "bom-ref": "xbom:anthropic.ai.claude", "type": "library", "name": "Anthropic Claude", "publisher": "Anthropic", "evidence": { "occurrences": [ { "location": "src/chatbot.py", "line": 15, "additionalContext": "anthropic.Anthropic" } ] } } ``` The `ai` property tag lets you filter AI components from the SBOM programmatically. ## What Gets Detected `vet` detects AI and LLM usage across **Go**, **Python**, and **JavaScript/TypeScript**: | Service | Examples | | - | - | | **OpenAI** | OpenAI client SDK | | **Anthropic** | Claude, Bedrock, VertexAI | | **LangChain** | LangChain framework | | **CrewAI** | CrewAI agents | | **Azure AI** | Azure AI services | > [!NOTE] > > Detection signatures are community-maintained and embedded into `vet` at build time. Run `vet code validate` to verify all signatures are well-formed. > [card] [xBOM Concepts](/governance/xbom/overview) > > Learn about extended Bill of Materials and signature-based detection > [card] [Code Analysis](/governance/vet/code-analysis) > > Deeper dive into Vet's static code analysis capabilities > [card] [CycloneDX SBOM](/governance/cyclonedx-sbom) > > Generate and work with CycloneDX SBOMs > [card] [Policy as Code](/reference/policy-as-code) > > Enforce policies against detected components in CI/CD # Terraform Supply Chain Audit Source: https://docs.safedep.io/governance/terraform-audit Audit Terraform provider inventory for supply chain risks using SafeDep Cloud > [!NOTE] > > To follow this guide you need a SafeDep Cloud API Key and Tenant Identifier. See [Cloud Quickstart](/governance/cloud/quickstart) on how to onboard to SafeDep Cloud and get an API key. This guide covers how to discover [Terraform providers](https://developer.hashicorp.com/terraform/language/providers) used in a Terraform project, synchronize the inventory (BOM) with SafeDep Cloud, and query for unofficial providers that may pose supply chain risks. ## Prerequisites * `vet` installed (see [quickstart](/governance/vet/quickstart) for installation options) * SafeDep Cloud account with API key and tenant identifier * Terraform project with initialized providers (`.terraform.lock.hcl` must exist) ## Scan and Discover Terraform Providers Run `vet` on your Terraform project to discover providers. The project must be initialized so that `.terraform.lock.hcl` is present in the project directory. `--report-sync` uploads the provider inventory to SafeDep Cloud, so set your credentials first: ```bash theme={null} export SAFEDEP_API_KEY=your-api-key export SAFEDEP_TENANT_ID=your-tenant-domain ``` Then run the scan: ```bash theme={null} vet scan -D /path/to/terraform-code \ --report-sync \ --report-sync-project gh/test/infra1 \ --report-sync-project-version main ``` ### What This Command Does **1. Provider Discovery** Scans Terraform configuration files and lock files to identify all providers **2. Metadata Collection** Gathers information about provider versions, sources, and tiers (official, partner, community) **3. Cloud Synchronization** Uploads the provider inventory to SafeDep Cloud for centralized analysis **4. Project Tracking** Associates findings with specific projects and versions for tracking over time ## Query Provider Inventory Use SafeDep Cloud SQL queries to analyze your Terraform provider inventory. See [SafeDep Cloud Quickstart](/governance/cloud/quickstart) for more details on the query interface. ### Find Unofficial Terraform Providers Query for providers that are not officially maintained by HashiCorp: Providers are surfaced as packages in your synced inventory, joined to the global Terraform provider registry. Anchor the query on an indexed column (here `projects.origin_source`) and join out to `terraform_providers`: ```bash theme={null} safedep query exec --sql " SELECT projects.name, packages.name, terraform_providers.tier FROM projects JOIN project_versions ON project_versions.project_id = projects.id JOIN boms ON boms.pv_id = project_versions.id JOIN packages ON packages.bom_id = boms.id JOIN terraform_providers ON terraform_providers.provider_name = packages.name WHERE projects.origin_source = 'SOURCE_GITHUB' AND terraform_providers.tier != 'official' ORDER BY packages.name" ``` ### Example Response ``` projects.name packages.name terraform_providers.tier gh/test/infra1 registry.terraform.io/digitalocean/do community gh/test/infra1 registry.terraform.io/hetznercloud/hcloud community ``` ## Advanced Queries Break providers down by tier across your GitHub projects: ```bash theme={null} safedep query exec --sql " SELECT terraform_providers.tier, COUNT(DISTINCT packages.name) AS provider_count FROM projects JOIN project_versions ON project_versions.project_id = projects.id JOIN boms ON boms.pv_id = project_versions.id JOIN packages ON packages.bom_id = boms.id JOIN terraform_providers ON terraform_providers.provider_name = packages.name WHERE projects.origin_source = 'SOURCE_GITHUB' GROUP BY terraform_providers.tier ORDER BY provider_count DESC" ``` For the full query language, schema, join model, and more worked examples, see the [SafeDep Cloud SQL guide](/reference/sql-query). ## CI/CD Integration ### GitHub Actions Integrate Terraform provider auditing into your CI/CD pipeline: ```yaml theme={null} name: Terraform Security Audit on: push: paths: - '**/*.tf' - '.terraform.lock.hcl' pull_request: paths: - '**/*.tf' - '.terraform.lock.hcl' jobs: terraform-audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Terraform uses: hashicorp/setup-terraform@v3 - name: Terraform Init run: terraform init - name: Audit Terraform Providers run: | vet scan -D . \ --report-sync \ --report-sync-project ${{ github.repository }} \ --report-sync-project-version ${{ github.ref_name }} env: SAFEDEP_API_KEY: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} SAFEDEP_TENANT_ID: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} - name: Check for Unofficial Providers run: | safedep query exec -o json --sql " SELECT packages.name, terraform_providers.tier FROM projects JOIN project_versions ON project_versions.project_id = projects.id JOIN boms ON boms.pv_id = project_versions.id JOIN packages ON packages.bom_id = boms.id JOIN terraform_providers ON terraform_providers.provider_name = packages.name WHERE projects.name = '${{ github.repository }}' AND terraform_providers.tier != 'official' " > unofficial-providers.json if [ "$(jq '.count' unofficial-providers.json)" -gt 0 ]; then echo "⚠️ Unofficial providers detected:" jq -r '.rows[] | .["packages.name"]' unofficial-providers.json echo "Please review these providers for security compliance." fi env: SAFEDEP_API_KEY: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} SAFEDEP_TENANT_ID: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} ``` ### GitLab CI ```yaml theme={null} stages: - init - audit terraform-init: stage: init image: hashicorp/terraform:latest script: - terraform init artifacts: paths: - .terraform.lock.hcl expire_in: 1 hour terraform-audit: stage: audit image: ghcr.io/safedep/vet:latest script: - vet scan -D . --report-sync --report-sync-project $CI_PROJECT_PATH --report-sync-project-version $CI_COMMIT_REF_NAME dependencies: - terraform-init variables: SAFEDEP_API_KEY: $SAFEDEP_CLOUD_API_KEY SAFEDEP_TENANT_ID: $SAFEDEP_CLOUD_TENANT_DOMAIN ``` ## Policy Enforcement Terraform provider tier (official, partner, community) lives in SafeDep Cloud's query layer, not in Vet's local `--filter-suite` engine, which evaluates package-level signals (vulnerabilities, licenses, OpenSSF Scorecard) and has no notion of provider tiers. To enforce provider policies, query the synced inventory and fail the build on disallowed providers. The **Check for Unofficial Providers** step in the GitHub Actions example above demonstrates this pattern: it queries `terraform_providers.tier` and exits non-zero when any non-official provider is present. Adapt that query to encode your approved-provider rules. ## Schema Exploration List all queryable columns for Terraform providers: ```bash theme={null} safedep query schema show terraform_providers ``` Available fields include: * `terraform_providers.tier` - Provider tier (official, partner, community) * `terraform_providers.source` - Provider source URL * `terraform_providers.namespace` - Provider namespace * `packages.name` - Full provider name * `packages.version` - Provider version ## Troubleshooting > [accordion] No Providers Found > > If no providers are detected: > > * Ensure `.terraform.lock.hcl` exists (run `terraform init`) > * Verify Terraform configuration files are present > * Check that Vet supports your Terraform version > [accordion] Sync Issues > > If synchronization to SafeDep Cloud fails: > > * Verify API key and tenant ID are correct > * Check network connectivity to SafeDep Cloud > * Ensure project name doesn't contain special characters > [card] [Terraform Provider Registry](https://registry.terraform.io/) > > Browse official and community Terraform providers > [card] [SafeDep Cloud Queries](/governance/cloud/quickstart#query-your-data) > > Learn more about querying your infrastructure inventory > [card] [Supply Chain Security](https://about.gitlab.com/blog/2022/06/01/terraform-as-part-of-software-supply-chain-part1-modules-and-providers/) > > Learn about Terraform in the software supply chain > [card] [Vet CLI Documentation](https://github.com/safedep/vet) > > Complete Vet CLI documentation and examples # Generate an AI BOM Source: https://docs.safedep.io/governance/vet/ai-bom Build an AI Bill of Materials from source code with vet's xBOM engine: AI SDK detections in CycloneDX with file and line evidence. `vet` finds the AI libraries, SDKs, and agent frameworks your application actually calls. It scans source code, matches call sites against signatures for known AI SDKs, and writes each match into its [CycloneDX](/concepts/sbom) output as an extended Bill of Materials (xBOM). The AI components, each marked with an `ai` property and file and line evidence, are your AI BOM. Because the inventory comes from call sites, it shows what the code calls, not just what the manifests declare. Coverage tracks the AI ecosystem in current use: * **Model providers:** OpenAI, Anthropic, Google Gemini, xAI Grok, Mistral, Cohere, Groq, Ollama, AWS Bedrock, Hugging Face, and more * **Frameworks and agent SDKs:** LangChain, LangGraph, LlamaIndex, CrewAI, Vercel AI SDK, OpenAI Agents SDK, Claude Agent SDK, Pydantic AI, Spring AI, Semantic Kernel, and the Model Context Protocol (MCP) SDKs * **Languages:** Python, JavaScript, TypeScript, Java, and Go. Each SDK is covered in the languages it supports. Browse the [full signature set](https://github.com/safedep/vet/tree/main/signatures). AI is one xBOM category: the same scan also detects cryptographic, cloud, network, filesystem, and process usage (see the [vet xBOM documentation](https://github.com/safedep/vet/blob/main/docs/xbom.md)). ## Prerequisites * `vet` [installed](/governance/vet/quickstart) * Access to the source code you want to analyze ## Generate the AI BOM **1. Scan the source code** The first pass parses your source files, matches them against the embedded signatures, and stores the results in a local SQLite database. Point `--app` at your own code: ```bash theme={null} vet code scan --db code.db --app ./src ``` Skip test and generated code with `--exclude` (a regular expression), and restrict languages with `--lang` when you want a faster scan: ```bash theme={null} vet code scan --db code.db \ --app ./src \ --lang python \ --exclude ".*test.*" --exclude ".*__pycache__.*" ``` **2. Write the CycloneDX BOM** The second pass runs a normal `vet` scan, enriches it with the recorded detections, and writes the BOM: ```bash theme={null} vet scan -D ./src --code code.db --report-cdx xbom.json ``` `xbom.json` is a standard CycloneDX document that carries the code-analysis detections alongside the declared packages. Every AI component in it has the `ai` property, so downstream tooling can filter on it. **3. Inspect detections directly (optional)** You can review what `vet` found without generating a BOM. Query the database for matches tagged `ai`: ```bash theme={null} vet code query --db code.db --tag ai ``` Narrow the results by language, vendor, or file path: ```bash theme={null} vet code query --db code.db --tag ai --language python --limit 200 vet code query --db code.db --vendor OpenAI vet code query --db code.db --file src/agents/ ``` ## Read the AI BOM AI SDK calls detected in your code appear as standalone components with an `xbom:` bom-ref. The signature's vendor becomes the publisher, the `ai` property marks the component, and each occurrence records where the call sits in your source. This component records an Anthropic client constructed on line 3 of `src/app.py`: ```json theme={null} { "bom-ref": "xbom:anthropic.client", "type": "library", "name": "Anthropic API - AI client", "publisher": "Anthropic", "evidence": { "occurrences": [ { "location": "src/app.py", "line": 3, "additionalContext": "anthropic//Anthropic" } ] }, "properties": [ { "name": "ai", "value": "true" } ] } ``` `additionalContext` shows the matched call in the analyzer's namespace notation, with `//` separating the module path from the symbol. Detection follows calls, so an SDK that is imported but never called produces no component. If you scan vendored dependency source through `--import-dir`, `vet` attempts to attach those detections to the corresponding declared package instead of a standalone component. More AI SDKs and libraries are added to `vet` xBOM coverage over time. ### Filter the AI components The `ai` property makes the AI BOM easy to extract from the full document. With `jq`: ```bash theme={null} jq '.components[] | select(.properties[]? | .name == "ai" and .value == "true") | .name' xbom.json ``` > [!NOTE] > > Providers reached through the OpenAI-compatible mode of the `openai` SDK (DeepSeek and Moonshot document this as their official path) appear as OpenAI usage, because the code calls the `openai` SDK. ## Run it in CI Generate the BOM on each build and keep it as an artifact: ```yaml theme={null} - name: Build code analysis database run: vet code scan --app ./src --db code.db - name: Generate xBOM with AI components run: vet scan -D ./src --code code.db --report-cdx xbom.json ``` > [card] [CycloneDX SBOM](/governance/cyclonedx-sbom) > > Generate a standard CycloneDX SBOM with vet. > [card] [What is an SBOM?](/concepts/sbom) > > How CycloneDX BOMs and xBOMs relate. > [card] [Code Analysis](/governance/vet/code-analysis) > > The static analysis engine behind the xBOM. # Code Analysis Source: https://docs.safedep.io/governance/vet/code-analysis Analyze code and dependency usage patterns with Vet's code analysis features > [!WARNING] > > **EXPERIMENTAL**: This feature is experimental and may introduce breaking changes. `vet` uses the [code](https://github.com/safedep/code/) analysis framework built on [tree-sitter](https://tree-sitter.github.io/tree-sitter/) parsers. The framework supports multiple languages and source repositories (local and remote), and writes findings to a SQLite database that `vet scan` uses to enrich manifest analysis. ## Build a Code Analysis Database Build a SQLite database from your source code. The database is a prerequisite for code analysis features in `vet scan`. ```bash theme={null} vet code scan --app /path/to/app \ --db /tmp/code.db \ --lang python ``` This command analyzes application code recursively in the specified directory and creates a SQLite database with the findings. Omit `--lang` to scan all supported languages. ### Supported Languages The code analysis framework supports these languages through tree-sitter parsers: * Python * JavaScript/TypeScript * Java * Go * And more... ## Scan with Dependency Usage Analysis Pass the database to `vet scan` via the `--code` flag. Dependency usage analysis is enabled by default when a code database is provided. ```bash theme={null} vet scan -D /path/to/code --code /tmp/code.db ``` With a code database, `vet scan` adds: 1. **Manifest Analysis**: scans package manifests in the specified directory 2. **Usage Enrichment**: enriches packages with dependency usage data from the database 3. **Evidence-Based Results**: shows a scan summary with usage evidence and `used-in-code` tags for packages confirmed as used in code ![vet scan with code analysis database](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet/vet-scan-codedb.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=de08db8fb5f57aea1cbd96a74f9488d6) ## Practical Example Full workflow for a Python project: **1. Analyze Code** Build the code analysis database for your Python project: ```bash theme={null} vet code scan --app ./src \ --db ./analysis/code.db \ --lang python ``` **2. Enhanced Scan** Run `vet scan` with the code database: ```bash theme={null} vet scan -D . \ --code ./analysis/code.db \ --report-json results.json ``` **3. Review Results** Check the scan results for: * Dependencies actually used in code vs. declared * Unused dependencies that could be removed * Usage patterns and import analysis ## Advanced Usage ### Multi-language Projects For projects with multiple languages, omit the `--lang` flag: ```bash theme={null} vet code scan --app ./src --db ./analysis/polyglot.db ``` ### Custom Database Locations Organize databases by project or environment: ```bash theme={null} # Development environment vet code scan --app ./src --db ./analysis/dev-code.db # Production analysis vet code scan --app ./dist --db ./analysis/prod-code.db ``` ### Integration with CI/CD ```yaml theme={null} # GitHub Actions example - name: Build Code Analysis DB run: vet code scan --app ./src --db ./code-analysis.db - name: Enhanced Security Scan run: vet scan -D . --code ./code-analysis.db --report-sarif security.sarif ``` ## Limitations > [accordion] Experimental Status > > This feature is experimental and may have breaking changes. Test before using in production. > [accordion] Performance Impact > > Code analysis adds processing time to scans. Weigh the accuracy benefit against the speed cost for your use case. > [accordion] Storage Requirements > > Code analysis databases can grow large for extensive codebases. Monitor disk usage and remove old databases periodically. > [card] [Code Framework](https://github.com/safedep/code/) > > Learn more about the underlying code analysis framework > [card] [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) > > Understand the parsing technology behind code analysis > [card] [Dependency Usage Guide](/governance/vet/dependency-usage) > > See how to identify dependency usage in your code > [card] [Vet GitHub Repository](https://github.com/safedep/vet) > > Access the main Vet documentation and examples # Dependency Inventory Source: https://docs.safedep.io/governance/vet/dependency-inventory Generate accurate dependency inventories using package managers and SBOM tools Package managers such as Maven, Gradle, and npm have the most accurate view of library dependencies. They resolve exact versions and can generate an SBOM for `vet` to scan with higher fidelity. This guide uses the [CycloneDX Gradle plugin](https://github.com/CycloneDX/cyclonedx-gradle-plugin) to generate an SBOM and scan it with `vet`. ## Gradle Integration The CycloneDX Gradle plugin generates SBOMs that `vet` can analyze for security issues. ### Plugin Configuration Add the CycloneDX plugin to your `build.gradle` file: ```groovy theme={null} plugins { id 'org.cyclonedx.bom' version '1.10.0' } cyclonedxBom { includeConfigs = ["runtimeClasspath"] skipConfigs = ["compileClasspath", "testCompileClasspath"] skipProjects = [rootProject.name, "yourTestSubProject"] projectType = "application" schemaVersion = "1.6" destination = file("build/reports") outputName = "bom" outputFormat = "json" includeBomSerialNumber = false includeLicenseText = false includeMetadataResolution = true componentVersion = "2.0.0" componentName = "my-component" } ``` ### Configuration Options > [accordion] Dependency Scopes > > **includeConfigs**: Which dependency configurations to include > > ```groovy theme={null} > includeConfigs = [ > "runtimeClasspath", // Runtime dependencies > "implementationClasspath", // Implementation dependencies > "compileClasspath" // Compile-time dependencies > ] > ``` > [accordion] Project Filtering > > **skipConfigs** and **skipProjects**: Exclude unnecessary components > > ```groovy theme={null} > skipConfigs = ["testCompileClasspath", "testRuntimeClasspath"] > skipProjects = ["test-utils", "benchmarks"] > ``` > [accordion] Output Customization > > **destination** and **outputName**: Control where SBOMs are generated > > ```groovy theme={null} > destination = file("security/sboms") > outputName = "${project.name}-${project.version}-sbom" > outputFormat = "json" // or "xml" > ``` ### SBOM Generation Generate SBOM artifacts with a clean build: ```bash theme={null} gradle clean build cyclonedxBom ``` ![Sample Gradle build output](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/sample-gradle-build.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=4f9b886da54a454f0d01562cf44d7001) After a successful build, SBOM artifacts are stored in the `build/reports` directory. ## Multi-Project Configuration For multi-module projects, configure the plugin in each module or use a shared configuration in the root `build.gradle`: ```groovy theme={null} subprojects { apply plugin: 'org.cyclonedx.bom' cyclonedxBom { includeConfigs = ["runtimeClasspath"] projectType = "library" destination = file("${rootProject.buildDir}/reports/sboms") outputName = "${project.name}-bom" } } ``` ## Maven Integration For Maven projects, use the CycloneDX Maven plugin: ```xml theme={null} org.cyclonedx cyclonedx-maven-plugin 2.8.0 application 1.6 false true bom json package makeAggregateBom ``` Generate the SBOM: ```bash theme={null} mvn clean package cyclonedx:makeAggregateBom ``` ## Scanning SBOMs with Vet Once you have generated SBOM files, scan them with `vet`: ### CycloneDX Format ```bash theme={null} vet scan --lockfiles build/reports/bom.json \ --lockfile-as bom-cyclonedx \ --report-markdown=report.md ``` ![vet CycloneDX scan demonstration](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet-cyclonedx-scan-demo.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=d98d0b36164ea031e07940e8745f8282) ## npm/Node.js Integration For Node.js projects, use the CycloneDX npm plugin: ```bash theme={null} # Install globally npm install -g @cyclonedx/cyclonedx-npm # Generate SBOM cyclonedx-npm --output-file sbom.json # Scan with vet vet scan --lockfiles sbom.json --lockfile-as bom-cyclonedx ``` ## Python Integration For Python projects, use cyclonedx-python: ```bash theme={null} # Install pip install cyclonedx-bom # Generate SBOM (subcommand depends on project type: environment, requirements, poetry, pipenv) cyclonedx-py environment -o sbom.json # Scan with vet vet scan --lockfiles sbom.json --lockfile-as bom-cyclonedx ``` ## CI/CD Integration > [tab] GitHub Actions > > ```yaml theme={null} > name: Dependency Inventory Scan > on: [push, pull_request] > > jobs: > inventory-scan: > runs-on: ubuntu-latest > steps: > - uses: actions/checkout@v4 > > - name: Set up JDK > uses: actions/setup-java@v4 > with: > java-version: '17' > distribution: 'temurin' > > - name: Generate SBOM > run: ./gradlew cyclonedxBom > > - name: Scan SBOM with vet > run: | > docker run --rm -v "$PWD:/app" ghcr.io/safedep/vet:latest \ > scan --lockfiles /app/build/reports/bom.json \ > --lockfile-as bom-cyclonedx > > - name: Upload SBOM > uses: actions/upload-artifact@v4 > with: > name: sbom > path: build/reports/bom.json > ``` > [tab] GitLab CI > > ```yaml theme={null} > stages: > - build > - security > > generate-sbom: > stage: build > script: > - ./gradlew clean build cyclonedxBom > artifacts: > paths: > - build/reports/bom.json > expire_in: 1 hour > > security-scan: > stage: security > image: ghcr.io/safedep/vet:latest > script: > - vet scan --lockfiles build/reports/bom.json --lockfile-as bom-cyclonedx --report-json security-report.json > dependencies: > - generate-sbom > artifacts: > reports: > security: security-report.json > ``` ## Configuration Notes > [accordion] Environment-Specific SBOMs > > Control which dependencies appear in the SBOM by setting `includeConfigs` and `skipConfigs` in your `build.gradle` (shown above). For example, list only `runtimeClasspath` for a production SBOM, or add `testRuntimeClasspath` to include test dependencies. > [accordion] Storage and Versioning > > Store SBOMs alongside releases for compliance and audit: > > ```bash theme={null} > # Tag SBOMs with version information > cp build/reports/bom.json "release-artifacts/sbom-v${VERSION}.json" > ``` > [card] [CycloneDX Gradle Plugin](https://github.com/CycloneDX/cyclonedx-gradle-plugin) > > Complete documentation for the Gradle plugin > [card] [CycloneDX Maven Plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) > > Maven plugin documentation and examples > [card] [SBOM Generation Guide](/governance/cyclonedx-sbom) > > Learn more about generating SBOMs with Vet > [card] [Package Manager Support](https://github.com/safedep/vet#supported-package-managers) > > See all supported package managers in Vet # Dependency Usage Source: https://docs.safedep.io/governance/vet/dependency-usage Identify which dependencies are actually used in your code using static code analysis `vet` can identify which dependencies your code actually uses via static code analysis. When triaging vulnerabilities, this lets you focus on packages that are imported and deprioritize those that are only declared. > [!WARNING] > > **EXPERIMENTAL**: This feature is experimental and may introduce breaking changes. This page covers the dependency-usage workflow. For the underlying [Code Analysis](/governance/vet/code-analysis) feature, including supported languages and options, see that page. ## Demo [Dependency Usage Identification Demo](https://www.youtube.com/embed/yFUuMMAsnfI?si=hqL3SIIMjlN_kNpr) ## Quick Start ### Step 1: Create Code Analysis Database Build a code analysis database for your source code: ```bash theme={null} vet code scan --app src --db /tmp/dump/vet-test.db ``` This analyzes code in the `src` directory, extracts import statements and usage patterns, and stores the results in a SQLite database. ### Step 2: Scan with Usage Enrichment Run a Vet scan enriched with the dependency usage database: ```bash theme={null} vet scan --code /tmp/dump/vet-test.db ``` Results now include: * **Usage Evidence**: which dependencies are actually imported and used * **Used-in-Code Tags**: markers on packages confirmed as used in code * **Prioritized Results**: packages with real usage are highlighted ## Advanced Usage Patterns ### Language-Specific Analysis To target a specific language: ```bash theme={null} # Python projects vet code scan --app src --db python-analysis.db --lang python # JavaScript/TypeScript projects vet code scan --app src --db js-analysis.db --lang javascript # Multi-language projects vet code scan --app src --db full-analysis.db # Auto-detect all languages ``` ## Understanding the Results ### Usage Evidence Types The code analysis records several types of evidence: > [tab] Import Statements > > ```python theme={null} > # Python example > import requests > from flask import Flask > ``` > > These direct imports are tracked as usage evidence. > [tab] Function Calls > > ```javascript theme={null} > // JavaScript example > const axios = require('axios'); > axios.get('https://api.example.com'); > ``` > > Actual usage of imported modules is recorded. > [tab] Module References > > ```java theme={null} > // Java example > import org.apache.commons.lang3.StringUtils; > String result = StringUtils.capitalize(input); > ``` > > References to specific classes and methods are tracked. ### Tags and Annotations Dependencies found in your source code are marked with the `used-in-code` tag, so you can prioritize them over packages that are only declared in a manifest. ## Scope Separation > [accordion] Environment Separation > > Create separate databases for different scopes: > > ```bash theme={null} > # Production code only > vet code scan --app src/main --db prod-analysis.db > > # Include test code > vet code scan --app src --db full-analysis.db > ``` > [card] [Code Analysis Guide](/governance/vet/code-analysis) > > Learn more about Vet's code analysis capabilities > [card] [Policy as Code](/reference/policy-as-code) > > Create policies that leverage usage information > [card] [Vet Repository](https://github.com/safedep/vet) > > Access complete documentation and examples > [card] [Tree-sitter Parsers](https://tree-sitter.github.io/tree-sitter/) > > Learn about the parsing technology behind code analysis # Deploy vet with MDM Source: https://docs.safedep.io/governance/vet/mdm/overview Install, update, and remove vet across macOS and Linux fleets, then add optional visibility tasks through your MDM. Use your MDM to install, update, and remove `vet` across managed macOS and Linux endpoints. After `vet` is in place, you can add a separate MDM task to collect endpoint inventory and sync it to SafeDep Cloud. This guide works with any MDM that can deploy a package or run shell commands, such as Jamf, Intune, JumpCloud, Mosyle, or Kandji. Use this guide for two jobs: 1. Make `vet` available on each managed endpoint. 2. Run optional endpoint inventory on a schedule. > [!NOTE] > > Installing `vet` does not require a SafeDep account. SafeDep Cloud credentials are required only when you want endpoint inventory in SafeDep Cloud. Inventory sync from an MDM fleet needs the Enterprise plan. See [pricing](https://safedep.io/pricing). ## Before you start You need: * An MDM policy that can run a shell command, or deploy a package. * Administrator access on the target endpoints. * A small test device group for the first deployment. * A selected install method: Homebrew, npm, or a pre-built binary. Use the same install method for installation, updates, and removal. Do not mix package managers on the same endpoint. If you plan to run scheduled inventory as root, install `vet` in a system path or make sure the MDM job can resolve `vet` from `PATH`. The pre-built binary is the most predictable option for this case. ## Install vet Choose the method that matches the software already managed on your endpoints. > [tab] Pre-built binary > > Use this for the most predictable MDM deployment. > > Download the archive for each operating system and architecture from [vet releases](https://github.com/safedep/vet/releases). Verify it with the published `checksums.txt` file, then add the extracted `vet` binary to your MDM package. > > Install the binary in a system path: > > > [tab] macOS > > > > ```sh theme={null} > > install -d -o root -g wheel -m 0755 /usr/local/bin > > install -o root -g wheel -m 0755 vet /usr/local/bin/vet > > ``` > > > [tab] Linux > > > > ```sh theme={null} > > install -d -o root -g root -m 0755 /usr/local/bin > > install -o root -g root -m 0755 vet /usr/local/bin/vet > > ``` > [tab] Homebrew (macOS and Linux) > > Use this when Homebrew is already managed on the endpoint. Run the command in the user context that owns the Homebrew installation. Do not run Homebrew as root. > > ```sh theme={null} > brew install safedep/tap/vet > ``` > [tab] npm > > Use this when Node.js and npm are already managed on the endpoint. > > ```sh theme={null} > npm install -g @safedep/vet > ``` ## Verify the install Assign the install policy to your test group first. After the policy runs, verify the installation: ```sh theme={null} command -v vet vet version ``` The first command must return the managed `vet` path. The second command must return the installed version. ## Update vet Update `vet` through the same MDM policy and install method: > [tab] Pre-built binary > > Download and verify the required release, then replace the managed `vet` binary in your MDM package. Re-run the install policy to replace `/usr/local/bin/vet` on macOS and Linux. > [tab] Homebrew (macOS and Linux) > > ```sh theme={null} > brew upgrade safedep/tap/vet > ``` > [tab] npm > > ```sh theme={null} > npm install -g @safedep/vet@latest > ``` Run `vet version` after the update and confirm that it reports the expected version. ## Uninstall vet Disable any MDM tasks that run `vet` before you remove the CLI. Then use the uninstall command that matches the install method. > [tab] Pre-built binary > > ```sh theme={null} > rm -f /usr/local/bin/vet > ``` > [tab] Homebrew (macOS and Linux) > > ```sh theme={null} > brew uninstall safedep/tap/vet > ``` > [tab] npm > > ```sh theme={null} > npm uninstall -g @safedep/vet > ``` Run `command -v vet` after removal. It must not return a path. ## Run endpoint inventory with your MDM Installing `vet` makes the CLI available, but it does not schedule scans. Deploy endpoint inventory as a separate MDM task. This keeps installation, credentials, and schedules independent. The current fleet script is [`vet_endpoint_scan.sh`](https://github.com/safedep/vet/blob/main/scripts/mdm/vet_endpoint_scan.sh). It supports macOS and Linux. The script runs `vet endpoint scan` and collects AI tools, coding agents, MCP servers, and agent skills. **1. Deploy the script** Download the script from the `vet` repository and deploy it to a managed path on each endpoint. Make the file executable. ```sh theme={null} chmod 0755 /path/to/vet_endpoint_scan.sh ``` The script expects `vet` to already be installed on the endpoint. **2. Choose local-only or cloud sync** Run the script with no credentials for local-only inventory: ```sh theme={null} /path/to/vet_endpoint_scan.sh ``` For SafeDep Cloud sync, create an API key and get your Tenant ID from [SafeDep Cloud settings](https://app.safedep.io/settings/api-keys). Store both values in your MDM secret store, then pass them as environment variables: ```sh theme={null} SAFEDEP_API_KEY="" \ SAFEDEP_TENANT_ID="" \ /path/to/vet_endpoint_scan.sh ``` Cloud sync starts only when both variables are set. If neither variable is set, the script runs local-only. Do not set only one variable. **3. Choose the execution context** Run the script as root to scan every local human account on the machine. Use this mode for shared devices or when you want endpoint-wide coverage. Run the script as the logged-in user to scan only that user. Use this mode when you want the user's full `PATH`, especially for CLI tool discovery on macOS. **4. Add optional scan flags** Pass extra flags at the end when you want to narrow the inventory or reduce output. The script forwards them to `vet endpoint scan`. ```sh theme={null} /path/to/vet_endpoint_scan.sh --silent --kind ai-tool ``` **5. Assign a schedule** Assign the inventory policy to your test group first. Then choose the schedule that matches how often you want the inventory refreshed. Keep this policy separate from the install policy. The script continues to the next user if one user scan fails and reports the final result in the MDM job output. **6. Verify the result** Review the MDM job output and confirm that the script found `vet` and scanned the expected users. If Cloud sync is enabled, open [SafeDep Cloud](https://app.safedep.io), select **Endpoints**, open the endpoint, and select the **Inventory** tab. Confirm that the endpoint and its discovered items appear. To remove this inventory task, disable the MDM policy and remove the managed script. This does not uninstall `vet`. > [card] [vet installation options](https://github.com/safedep/vet#installation) > > Source of truth for supported installation methods. > [card] [vet MDM scripts](https://github.com/safedep/vet/blob/main/scripts/mdm/README.md) > > Source of truth for current macOS and Linux fleet scripts. > [card] [Endpoints inventory](/governance/cloud/endpoint-hub/inventory) > > Configure inventory sync and review discovered items. # Vet Source: https://docs.safedep.io/governance/vet/overview Vet is a free, open-source SCA scanner that finds malicious, vulnerable, and risky open-source dependencies in code and CI/CD. [Vet](https://github.com/safedep/vet) is a free, open-source software composition analysis (SCA) scanner. It checks your open-source dependencies for malicious packages, known vulnerabilities, license issues, and weak project health, then lets you enforce policy on what it finds. Run it locally, in CI/CD, or against a whole repository. ## What Vet does > [card] Automated analysis > > Replace manual dependency reviews with policy-driven analysis. > [card] Policy as code > > Define and version security policy with [CEL](/concepts/cel). > [card] CI/CD integration > > Run in any CI tool or your local workflow. > [card] Trusted data > > Built on OSV, OpenSSF Scorecard, deps.dev, and SafeDep malware intelligence. ## Get started > [card] [Vet Quickstart](/governance/vet/quickstart) > > Scan your first project in minutes. > [card] [Dependency Inventory](/governance/vet/dependency-inventory) > > Generate an accurate dependency inventory. > [card] [Code Analysis](/governance/vet/code-analysis) > > See how dependencies are actually used. > [card] [Dependency Usage](/governance/vet/dependency-usage) > > Prioritize findings by which dependencies your code actually uses. > [card] [MDM Deployment](/governance/vet/mdm/overview) > > Install and manage vet across endpoint fleets. > [card] [Filtering & Policy](/reference/filtering) > > Query results and enforce policy with CEL. ![vet scanning a project](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet/vet-demo.gif?s=c58d126fdc88065b973d9d947b801e54) # Vet Quickstart Source: https://docs.safedep.io/governance/vet/quickstart Get started with Vet in under 5 minutes > [!NOTE] > > For SafeDep Cloud, refer to [Cloud Quickstart](/governance/cloud/quickstart) Use [SafeDep Vet](https://github.com/safedep/vet) to detect security risks and apply policy-based controls that block vulnerable or malicious open source dependencies. ## Installation > [accordion] Homebrew (macOS/Linux) > > ```bash theme={null} > brew tap safedep/tap > brew install safedep/tap/vet > ``` > [accordion] Container Image > > ```bash theme={null} > docker run --rm -it ghcr.io/safedep/vet:latest version > ``` > [accordion] Pre-built Binary > > Download a pre-built binary suitable for your OS at [GitHub Releases](https://github.com/safedep/vet/releases) For additional installation options, see [Vet's README](https://github.com/safedep/vet). ## Running Your First Scan Scan a source code repository, auto-discovering well-known manifest files: ```bash theme={null} vet scan -D /path/to/dir ``` ![vet scanning a directory](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet/vet-scan-directory.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=898ff1a8606eb9d1c309cb7b5c20a8c6) ### Other scanning options > [accordion] Scan a single file > > ```bash theme={null} > vet scan -M package-lock.json > ``` > [accordion] Scan a PURL > > ```bash theme={null} > vet scan --purl pkg:npm/express@4.18.2 > ``` > [accordion] Scan a Java JAR file > > ```bash theme={null} > vet scan -M /path/to/my-app.jar > ``` > [accordion] Scan an OCI image > > ```bash theme={null} > vet scan --image ghcr.io/safedep/vet:latest > ``` For more scanning options, see [Vet's README](https://github.com/safedep/vet). ## Policy as Code `vet` supports a [CEL](https://cel.dev/)-based policy language for identifying risks. Scan and fail on critical or high vulnerabilities: ```bash theme={null} vet scan -D /path/to/dir \ --filter '(vulns.critical.size() > 0) || (vulns.high.size() > 0)' \ --filter-fail ``` ### Advanced Policy Configuration Combine multiple CEL queries into a policy suite ([example](https://github.com/safedep/vet/blob/main/samples/filter-suites/fs-generic.yml)) and audit your application: ```bash theme={null} vet scan -D /path/to/dir \ --filter-suite /path/to/policy.yml \ --filter-fail ``` ## Setup CI/CD Guardrails `vet` includes a native [GitHub Action](https://github.com/safedep/vet-action) for policy-driven guardrails against risky OSS components. ![vet guardrails in GitHub](https://mintcdn.com/safedep/A0tSXvZ_XcagO9QB/images/vet-guardrails.png?fit=max\&auto=format\&n=A0tSXvZ_XcagO9QB\&q=85\&s=150f43463641243a1819a6e9b7d028c6) > [card] [GitHub Integration](/governance/integrations/github-code-scanning) > > Setup Vet with GitHub Actions and Code Scanning > [card] [GitLab Integration](/governance/integrations/gitlab) > > Integrate Vet with GitLab CI/CD pipelines > [card] [Policy Configuration](/reference/policy-as-code) > > Learn advanced policy configuration with CEL > [card] [Cloud Platform](/governance/cloud/quickstart) > > Scale across your organization with SafeDep Cloud ## What's Next? * See the [Vet GitHub Repository](https://github.com/safedep/vet) for the latest documentation on usage and advanced features. * For `vet`'s complete commands, sub-commands, flags, and usage documentation, see the [Vet CLI Reference Manual](https://safedep.github.io/vet). # xBom Source: https://docs.safedep.io/governance/xbom/overview xBom generates a Bill of Materials enriched with AI and SaaS usage by analyzing your source code, not just manifests. Modern applications reach far beyond declared dependencies: AI SDKs, ML models, and third-party SaaS APIs. Traditional BOM tools only read manifest files like `requirements.txt` or `pom.xml`. [xBom](https://github.com/safedep/xbom) analyzes your source code to find what your application actually uses, for a more accurate [SBOM](/concepts/sbom). ## What xBom does > [card] Beyond manifests > > Finds real evidence of AI SDKs, cloud APIs, and crypto in your code, not just declared packages. > [card] Extensible signatures > > Community-driven signatures detect components; add your own for proprietary tools. > [card] CycloneDX output > > Produces standard CycloneDX BOMs for compliance and tooling. > [card] Multi-ecosystem > > Supports Java and Python today, with JavaScript in progress. ## Get started > [card] [xBom Quickstart](/governance/xbom/quickstart) > > Generate your first xBOM. > [card] [CycloneDX SBOM](/governance/cyclonedx-sbom) > > Generate a standard SBOM with Vet. > [card] [What is an SBOM?](/concepts/sbom) > > SBOM versus xBOM, explained. > [card] [Contribute signatures](https://github.com/safedep/xbom/blob/main/CONTRIBUTING.md#contributing-signatures) > > Add detections for new components. # xBom Quickstart Source: https://docs.safedep.io/governance/xbom/quickstart Get started with SafeDep xBom, an open source Bill of Materials generator enriched with AI and SaaS usage detected from source code. > [card] [xBom Repository](https://github.com/safedep/xbom) > > View the xBom source code and contribute on GitHub **xBom** generates a Bill of Materials (BOM) enriched with AI components, SaaS integrations, and more. It uses static code analysis to find these in your code, not just your declared dependencies. ## Installation Install xBom using one of the following methods: **macOS & Linux (Homebrew):** ```bash theme={null} # Installation on macOS & Linux brew install safedep/tap/xbom ``` **Pre-built binary:** Download a **[pre-built binary](https://github.com/safedep/xbom/releases)** for your operating system from the GitHub releases page. ## Generating Your First BOM To generate a BOM for your source code, use the `generate` command: ```bash theme={null} # Generate BOM for your source code xbom generate --dir /path/to/your/code --bom /path/to/output/bom.cdx.json ``` Replace `/path/to/your/code` with your project directory and `/path/to/output/bom.cdx.json` with your desired output path. The output is an SBOM in **[CycloneDX v1.6 JSON format](https://cyclonedx.org/docs/1.6/json/)**, including any AI components and other supported elements detected in the codebase. ## Supported Languages Currently, `xbom` supports the following programming languages: | Language | Status | | - | - | | Python | | | Java | | | JavaScript | | We are continuously working to expand language support. ## Supported BOM Types xBom specializes in identifying a variety of components beyond traditional libraries. ### AI Components xBom detects usage of AI SDKs and services, including: * LangChain * Anthropic * CrewAI * OpenAI ### Cloud Services xBom also identifies integrations with major cloud platforms: * Google Cloud Platform (GCP) * Microsoft Azure > [!NOTE] > > To request support for a new AI framework or cloud service, please > [create an issue](https://github.com/safedep/xbom/issues/new) on > our GitHub repository ## HTML report The primary output is a CycloneDX JSON file. xBom also prints a link to an interactive HTML report so you can browse the detected components in a browser. ![xbom-demo](https://raw.githubusercontent.com/safedep/xbom/main/docs/assets/xbom-demo.gif) ### Limitations **Current focus (AI BOM generation):** `xbom` is currently focused on AI BOM generation. It uses static code analysis to identify AI products, SaaS APIs, and similar non-library components in your codebase. **For full dependency SBOMs:** To generate an SBOM covering open-source library dependencies from manifest files, use [Vet](https://github.com/safedep/vet) alongside xBom. `vet` specializes in dependency analysis and vulnerability management, and the two tools together cover more of the software supply chain. ### Telemetry **Purpose:** `xbom` collects anonymous usage telemetry to show which integrations and use cases are common, guiding what to build next. It collects no personally identifiable information or sensitive data. **How to disable:** Set the `XBOM_DISABLE_TELEMETRY` environment variable to `true`: ```bash theme={null} export XBOM_DISABLE_TELEMETRY=true ``` > [card] [xBom](/governance/xbom/overview) > > What xBom is and how it works. > [card] [What is an SBOM?](/concepts/sbom) > > SBOM versus xBOM, explained. > [card] [CycloneDX SBOM](/governance/cyclonedx-sbom) > > Generate a standard SBOM with Vet. > [card] [xBom on GitHub](https://github.com/safedep/xbom) > > Source and signature contributions. # What is SafeDep? Source: https://docs.safedep.io/introduction SafeDep protects developers and AI coding agents against malicious open source components: block them before they run, govern the rest. SafeDep protects developers and AI coding agents against malicious open source components. You can inspect the code you write. You cannot inspect everything you depend on: packages, IDE extensions, Agent Skills, MCP servers, and GitHub repositories. Every one of them can carry a supply chain attack, and campaigns like Shai-Hulud, Miasma, and S1ngularity spread exactly this way. SafeDep closes this blindspot. It blocks malicious components before their code runs, and it gives you visibility and policy over everything else you depend on. Its core tools ([Vet](https://github.com/safedep/vet), [PMG](https://github.com/safedep/pmg), [xBom](https://github.com/safedep/xbom), and [Gryph](/ai-security/gryph-overview)) are free, open source, and usable without a SafeDep account. [SafeDep Cloud](/governance/cloud/overview) is the control plane, data lake, and intelligence layer that runs these tools across a team or an organization. New here? [Choose your path](/get-started/choose-your-path): start free with one tool, add Cloud when your team is ready. ## Where to start > [card] [Block malicious packages](/package-security/overview) > > Stop malicious and vulnerable packages at install time and in CI/CD, with PMG and Vet. > [card] [Secure AI coding agents](/ai-security/overview) > > Discover, audit, and control what AI agents access and run, with Gryph and the MCP server. > [card] [Scan & govern dependencies](/governance/overview) > > Scan repositories, SBOMs, and CI/CD for risk, and govern policy across your org with Vet and SafeDep Cloud. > [card] [How SafeDep works](/concepts/malicious-package) > > Understand how SafeDep detects malicious packages, plus the core terms used across these docs. # Package Security Source: https://docs.safedep.io/package-security/overview Block malicious open-source packages before they reach your code, on developer machines and in CI/CD. Stop malicious open-source components before they reach your code. SafeDep blocks known-bad packages wherever they enter: a developer's install, your CI/CD pipeline, or your artifact registry. The same risk arrives through more than packages: IDE extensions, Agent Skills, MCP servers, and GitHub repositories carry it too. When a component is not in the known-bad database yet, scan it on demand before you adopt it. > [card] [Block at install time](/package-security/pmg/overview) > > **PMG** guards `npm`, `pip`, and other package managers on the developer machine. No account or API key needed. > [card] [Deploy across managed devices](/package-security/pmg/mdm/overview) > > Install PMG on macOS, Linux, and Windows fleets through your MDM. > [card] [Block in your CI/CD pipeline](/governance/integrations/overview) > > Stop risky dependencies in pull requests and pipelines with the GitHub App, GitLab, and Bitbucket integrations. > [card] [Block in JFrog Xray](/threat-intel/integrations/jfrog-xray) > > Stop malicious packages in your JFrog artifact registry with SafeDep. > [card] [Scan a package on demand](/package-security/scan/overview) > > Run an on-demand malware analysis of any package, IDE extension, or GitHub repository before you use it. New to how SafeDep decides what is malicious? See [Malicious Package](/concepts/malicious-package). To check a package's risk from your own code, use the [Insights API](/reference/insights-api-typescript). > [!NOTE] > > For teams, [**SafeDep Cloud**](/governance/cloud/overview) adds centralized policy, endpoint inventory, and org-wide visibility on top of the open-source tools. # Apply the Cloud Policy in PMG Source: https://docs.safedep.io/package-security/pmg/cloud-policy Turn on cloud.policy so that PMG applies the block entries, trust entries and dependency cooldown of your SafeDep Cloud tenant. With the `cloud.policy` setting on, PMG applies the [cloud policy](/governance/cloud/policy/overview) of your tenant: its block entries, its trust entries and its dependency cooldown. Your security admin changes the policy in SafeDep Cloud, and PMG gets the change with no new config on each machine. > [!NOTE] > > The cloud policy needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). Without `cloud.policy`, PMG works as before and blocks malicious packages with no account. ## Turn on the cloud policy on one machine ```bash theme={null} pmg config set cloud.enabled true pmg cloud login pmg config set cloud.policy true pmg cloud sync ``` * `pmg cloud login` stores the tenant ID and an API key of the tenant. PMG can also read them from the `SAFEDEP_TENANT_ID` and `SAFEDEP_API_KEY` environment variables. * `cloud.policy` applies only when `cloud.enabled` is `true`. * `pmg cloud sync` fetches the policy at once. * `pmg config set` adds `cloud.policy` to a config file that an older PMG wrote. If the command prints `key not found`, the file has no `cloud` section. Run `pmg config edit` and add this section to the file: ```yaml theme={null} cloud: enabled: true policy: true ``` Save the file and run `pmg cloud login` and `pmg cloud sync`. You can also run `pmg setup install` and then the `pmg config set` commands again. `pmg setup install` adds the missing keys of the PMG template to your config file. It also installs the PMG PATH shims, and on macOS and Linux the shell aliases. Then check the state: ```bash theme={null} pmg setup doctor ``` The cloud policy check names the tenant, the revision that PMG applied and the age of the cache. It warns when no cache exists yet, when the cache is more than 7 days old, when PMG rejected a policy, and for each field that PMG does not apply. ## Turn on the cloud policy with MDM On an endpoint with a managed config file, users cannot change the PMG config. Set both keys in the managed config file: ```yaml theme={null} cloud: enabled: true policy: true ``` To turn off all cloud content on a managed endpoint, set `cloud.policy: false` in the managed config file. Under `global_lockdown: true`, the cloud policy does not change a key that the managed config file sets. So keep each key that the cloud policy must manage out of that file. See [Deploy PMG with MDM](/package-security/pmg/mdm/overview#manage-settings-from-the-cloud-policy). ## What PMG fetches PMG fetches the resolved policy of the endpoint. It holds the package rules that apply to the endpoint and the dependency cooldown. PMG sends the labels `reported/os` and `reported/arch` with each fetch, so a policy override can select endpoints by operating system or CPU architecture. PMG fetches the policy in the background after each command, also after a command that PMG blocked. It fetches at most once every 5 minutes, also when `cloud.auto_sync.enabled` is `false`. `pmg cloud sync` fetches at once. The persistent proxy applies a new policy with no restart. PMG keeps the policy in the `cloud-policy/` folder of its config folder. Under `sudo`, PMG reads the cache of the user who ran `sudo` first. On a short-lived CI runner, run `pmg cloud sync` before the first install. A new runner has no cache, so it applies only the PMG config until the first fetch. ## Offline and failed fetches PMG never drops the cloud policy because it is offline. It keeps the last policy that it applied until a newer one arrives. | State | When | What PMG does | | - | - | - | | Applied | A fetch succeeded in the last 7 days | Applies the policy | | Stale | No fetch succeeded for more than 7 days | Applies the last policy. `pmg setup doctor` warns. | | Rejected | A new policy fails its check, for example it is for another machine | Keeps the previous policy. `pmg setup doctor` warns. | | None | No cache yet | Applies only the PMG config | A fetch that fails keeps the cache. When you log out, PMG keeps the last policy. PMG drops a trust entry at its expiry, also with no network. ## Which settings the cloud policy changes | PMG setting | With the cloud policy | | - | - | | `dependency_cooldown.enabled`, `dependency_cooldown.days` | When the policy sets the cooldown, its value wins over the config file and the `PMG_*` environment variables. PMG refuses `--skip-dependency-cooldown`. PMG rounds the value up to whole days. Exception: under `global_lockdown`, a managed config file that sets one of these keys keeps its value. | | `dependency_cooldown.skip` | Still applies. | | `blocked_packages` | Still applies, together with the block entries of the policy. | | `trusted_packages`, the `PMG_INSECURE_INSTALLATION` environment variable | Still apply, but a block entry of the policy wins over them. Under `global_lockdown`, PMG ignores `PMG_INSECURE_INSTALLATION`. | | Malicious Package Exclusions of SafeDep Cloud | PMG ignores them. Use [trust entries](/governance/cloud/policy/trust-a-package) instead. | | Every other setting, such as the sandbox and the proxy | Not changed. The cloud policy does not manage them. | A trust entry of the policy never skips the malware analysis and never allows verified malware. See [Package Rules](/concepts/package-rules). ## What a block looks like A block entry of the cloud policy stops the install with a message that names the rule and the revision. This example comes from the PMG tests: ```text theme={null} pmg: blocked pkg:npm/evil@1.2.4 by the policy of your tenant rule r_9c1 · policy revision 48 · default policy revision 12 · IR-2291 credential stealer To ask for an exception, send the rule id and the reason to your security admin. They can run: safedep policy rule show r_9c1 ``` With `cloud.enabled` on, PMG syncs each decision of the cloud policy to your tenant. Your security admin can list them with `safedep policy decision list`. See [Explain a Decision](/governance/cloud/policy/explain-a-decision). ## Known gaps PMG keeps the policy cache in the folder of the user, so a user can change the cache on a laptop. For each gap of this release, see [Cloud Policy Limits](/reference/cloud-policy-limits#known-gaps). ## Next steps > [card] [Cloud Policy](/governance/cloud/policy/overview) > > What the cloud policy controls and who can change it. > [card] [Hold Back Newly Published Versions](/package-security/pmg/dependency-cooldown) > > The dependency cooldown of PMG. > [card] [Deploy PMG with MDM](/package-security/pmg/mdm/overview) > > Ship the managed config file to a fleet. > [card] [PMG configuration](https://github.com/safedep/pmg/blob/main/docs/config.md#cloud-policy) > > The config reference in the PMG repository. # Hold Back Newly Published Package Versions Source: https://docs.safedep.io/package-security/pmg/dependency-cooldown Set how many days PMG waits before it installs a newly published package version, and exempt the packages you trust. An attacker who takes over a maintainer account publishes a malicious version. The registry often removes the version within days. The PMG dependency cooldown hides each version that is younger than a set number of days, so the package manager installs an older version. The cooldown is on by default with a window of 2 days. It applies to npm, PyPI, Go, and Cargo packages. > [!NOTE] > > The [cloud policy](/package-security/pmg/cloud-policy) of a SafeDep Cloud tenant can set the cooldown. When it does, the cloud value wins over `dependency_cooldown.enabled` and `dependency_cooldown.days` in the config file, over the `PMG_*` environment variables, and over `--skip-dependency-cooldown`, which PMG then refuses. One exception: under `global_lockdown: true`, a managed config file that sets one of these keys keeps its value. The skip list still applies. To exempt one package from the cloud cooldown, your security admin creates a [trust entry](/governance/cloud/policy/trust-a-package) with the scope `cooldown`. ## Set the window ```bash theme={null} pmg config set dependency_cooldown.days 7 ``` To turn the cooldown off, set `dependency_cooldown.enabled` to `false`. ## Read the result For npm, PyPI, and Cargo, PMG removes each version inside the window from the version list that the registry sends. When the version range allows an older version, the package manager installs it and PMG shows no message. PMG blocks the install in these cases: * Every version of the package is inside the window. * You asked for an exact version, such as `pmg npm install pkg@1.2.3`, and that version is inside the window. The report starts with `Dependency cooldown` and names each blocked package. When a dependency asks for an exact version inside the window, the package manager fails, and PMG lists the held-back versions after the error. Add `--verbose` to see the held-back versions on every install. For npm and PyPI, the cooldown does not apply when the package manager downloads a locked version directly, such as `npm ci` with a lockfile. For Go and Cargo, PMG also checks each download against the window, so a version from `go.mod` or `Cargo.lock` is checked too. PMG does not change the version list for Go. The `go` command picks the version, and PMG blocks the download when that version is inside the window. ## Exempt a package For a package that you must install as soon as it is published, such as your own SDK, add it to the skip list. Open the config file with `pmg config edit` and add an entry: ```yaml theme={null} dependency_cooldown: enabled: true days: 7 skip: - purl: pkg:npm/my-internal-sdk reason: "First-party SDK, tested on release" - purl: pkg:npm/another-internal-pkg@1.2.3 reason: "One build we must test now" ``` A package URL (PURL) without a version exempts all versions. A PURL with a version exempts only that version. PMG still checks an exempt package for malware. ## Skip the cooldown for one install ```bash theme={null} pmg --skip-dependency-cooldown npm install express ``` ## With SafeDep Cloud The cooldown is free in PMG. With SafeDep Cloud, you see every cooldown hold on the endpoints and CI runners of your team. This query lists them: ```sql theme={null} SELECT endpoints.identifier, package_guard_events.package_name, package_guard_events.package_version, package_guard_events.timestamp FROM package_guard_events JOIN endpoints ON endpoints.id = package_guard_events.invocation_id WHERE package_guard_events.package_action = 'PMG_PACKAGE_ACTION_COOLDOWN_BLOCKED' ORDER BY package_guard_events.timestamp DESC ``` A package that the cooldown holds back on many endpoints can be one of your own packages. To exempt it, see [Exempt a package](#exempt-a-package). > [!NOTE] > > This section needs the SafeDep Cloud Team or Enterprise plan, with PMG [connected to your tenant](/governance/cloud/endpoint-hub/package-guard). See [pricing](https://safedep.io/pricing). ## Next steps For pip version requirements and the `trusted_packages` list, see the [dependency cooldown documentation](https://github.com/safedep/pmg/blob/main/docs/dependency-cooldown.md) in the PMG repository. > [card] [Alert on PMG blocks](/governance/cloud/alerts) > > With SafeDep Cloud, send malicious and cooldown blocks to Slack or a webhook. > [card] [Use PMG with a Private Registry or Mirror](/package-security/pmg/private-registries) > > Check packages from an internal registry. # PMG in GitHub Actions Source: https://docs.safedep.io/package-security/pmg/github-actions Block malicious packages in GitHub Actions CI with one PMG action step, a job summary, and kernel enforcement. [PMG](https://github.com/safedep/pmg) runs as a persistent proxy in CI/CD. The `safedep/pmg` action starts it once per job. The proxy intercepts installs from every [supported package manager](https://github.com/safedep/pmg#supported-package-managers) and blocks each package flagged as malicious. At the end of the job, the action stops the proxy, writes a job summary, and fails the job when PMG blocked a package. > [!NOTE] > > In CI, PMG is non-interactive: flagged packages are always blocked, never prompted. For local development use the wrapped commands (`pmg npm install`) covered in the [PMG quickstart](/package-security/pmg/quickstart). ## Use the SafeDep PMG action Add one `safedep/pmg` step right after `actions/checkout`. The job needs no other PMG step. ```yaml theme={null} - uses: actions/checkout@v6 - uses: safedep/pmg@v0.34.0 with: api-key: ${{ secrets.SAFEDEP_API_KEY }} tenant-id: ${{ secrets.SAFEDEP_TENANT_ID }} - run: npm ci # intercepted automatically ``` Put the action before the language setup steps, so the proxy sees the traffic of every later step. Use one `safedep/pmg` step per job. A second step fails, and the proxy of the first step keeps running. By default, the action runs the proxy in server mode. On a GitHub hosted runner, it also turns on [kernel enforcement](#enforce-in-the-kernel). Set `timeout-minutes` on the job. A proxy that stops serving holds the job until the timeout. PMG blocks malicious packages using SafeDep's free community intelligence with or without credentials. Add the optional `api-key` and `tenant-id` to connect the run to [SafeDep Cloud](/governance/cloud/overview), so block events sync to [Endpoint Hub](/governance/cloud/endpoint-hub/overview) before the runner is destroyed. > [!NOTE] > > Use `safedep/pmg@v0.34.0` or a later release tag. The post step, the job summary, and the `fail-on-violation`, `auto-stop` and `baseline` inputs need v0.34.0 and a runner that runs Node 24 actions. A self-hosted runner needs runner version 2.327.1 or later. The `v1` tag points at an older action without these inputs. GitHub warns about an unknown input and runs the job without it. ### Upgrade from v0.33.0 or earlier Earlier releases needed a `pmg proxy stop --fail-on-violation` step at the end of the job. From v0.34.0, the post step of the action does this work. Remove the stop step. Server mode is the default, so the job no longer needs `server-mode: true`. A job that keeps its own stop step must set `auto-stop: false`. Otherwise the post step finds no proxy and fails the job, because a stop step could hide a block. ## What happens at the end of the job The action has a post step. GitHub runs it at the end of the job, also when an earlier step fails and when the job is cancelled. The post step: 1. Stops the proxy. With `api-key`, the proxy sends its last events to SafeDep Cloud. 2. Proposes a network profile from the hosts that the job reached. See [Allow Only Known Hosts in GitHub Actions](/package-security/pmg/github-actions-network-policy). 3. Writes the job summary. The summary shows the verdict, the number of blocked packages, each denied connection, and each destination host. The run also gets an annotation when PMG blocked a package, and one for each denial. 4. Fails the job when PMG blocked a package or the network policy denied a connection. The `fail-on-violation`, `auto-stop`, and `baseline` inputs change the post step. See [Inputs](#inputs). > [!WARNING] > > On a public repository, anyone can read the job summary. It lists the hosts that the job reached. Set `baseline: false` to leave them out. A denied connection still shows in the summary, with its host. ## Example workflow A full workflow that installs dependencies through PMG on every pull request: ```yaml install-dependencies.yml expandable theme={null} name: Install Dependencies on: pull_request: branches: [main] permissions: contents: read jobs: install-deps: runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v6 # Start PMG. The post step stops it and fails the job on a block. - uses: safedep/pmg@v0.34.0 with: api-key: ${{ secrets.SAFEDEP_API_KEY }} tenant-id: ${{ secrets.SAFEDEP_TENANT_ID }} # Your usual language setup and install - uses: actions/setup-node@v6 with: node-version: "24" - run: npm ci ``` ## See blocks from every pipeline With the `api-key` and `tenant-id` inputs, the blocks from every job go to one tenant. To review them across all repositories, see [Review Package Blocks Across CI Pipelines](/governance/cloud/endpoint-hub/ci-package-blocks). > [!NOTE] > > This needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ## Enforce in the kernel [PMG Kernel Enforcement for GitHub Actions](https://www.youtube.com/embed/V3kwD04L6N4) Proxy variables are a request that a process can ignore. A step that runs `env -i`, uses `sudo`, or calls an HTTP client of its own bypasses the proxy. Kernel enforcement makes the Linux kernel route every process on the runner through PMG. The `enforce` input is `auto` by default. The action enforces when the job runs on a GitHub hosted runner, on the runner host, with passwordless `sudo`. GitHub hosted Ubuntu runners meet these conditions. In a job container, on a self-hosted runner, or without `sudo`, the action runs the proxy without enforcement and says so in the log. Set `enforce: true` to fail the job where the runner cannot enforce. Set `enforce: false` to turn enforcement off. ```yaml theme={null} - uses: safedep/pmg@v0.34.0 with: enforce: true enforce-namespaces: redirect api-key: ${{ secrets.SAFEDEP_API_KEY }} tenant-id: ${{ secrets.SAFEDEP_TENANT_ID }} - run: npm ci ``` `enforce-namespaces: redirect` also routes the containers that steps start, such as `docker run` and `docker build`. See [Protect Docker builds and containers](#protect-docker-builds-and-containers). The action installs the PMG CA into the system trust store, starts the proxy as root, and exports the trust variables. The post step stops the root proxy. A step that runs `pmg` as root uses the `PMG_BIN` and `PMG_PROXY_STATE` variables that the action exports: ```yaml theme={null} - run: sudo "$PMG_BIN" proxy status --state "$PMG_PROXY_STATE" ``` The runner is not exempt. Its connections to GitHub go through the proxy, which passes them through with the real certificate. If the proxy stops serving but keeps running, the runner cannot report. GitHub then cancels the job after its `timeout-minutes`, and the post step does not run. The GitHub default is 360 minutes, so set a shorter timeout on every job. The `enforce-*` inputs set the policy without a config file. See [Inputs](#inputs). With `enforce: auto`, an `enforce-*` input fails the job where the action cannot enforce, so a runner change does not turn enforcement off without notice. For the policy keys and what enforcement does not cover, see [Kernel Enforcement on Linux](/package-security/pmg/kernel-enforcement). To refuse every host that the job does not need, add a network policy. See [Allow Only Known Hosts in GitHub Actions](/package-security/pmg/github-actions-network-policy). ### Protect Docker builds and containers With `enforce-namespaces: redirect`, PMG also checks the packages that a container installs. This includes the `RUN` steps of `docker build`, `docker run`, and Docker actions. PMG reads the registry traffic with its own CA. A container that does not trust this CA fails the TLS handshake. The action exports the path of a CA bundle as `PMG_CA_BUNDLE`. The bundle holds the PMG CA and the public root CAs, so the other hosts still work. Give this file to each container that installs packages. For a build, pass the bundle as a build secret. The secret is not stored in the image. ```yaml docker-build.yml expandable theme={null} name: Build Docker Image on: pull_request: branches: [main] permissions: contents: read jobs: build: runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v6 - uses: safedep/pmg@v0.34.0 with: enforce: true enforce-namespaces: redirect - uses: docker/setup-buildx-action@v4 - uses: docker/build-push-action@v7 with: context: . push: false tags: app:ci secret-files: pmg-ca=${{ env.PMG_CA_BUNDLE }} ``` Without `docker/build-push-action`, pass the same secret to the Docker CLI: ```bash theme={null} docker build --secret id=pmg-ca,src=$PMG_CA_BUNDLE -t app:ci . ``` In the Dockerfile, mount the secret in each `RUN` step that installs packages: ```dockerfile Dockerfile theme={null} FROM node:24-slim WORKDIR /app COPY package.json package-lock.json ./ # The bundle is present only when the build gets the pmg-ca secret. # A build without the secret, such as a local build, uses the CAs of the image. RUN --mount=type=secret,id=pmg-ca,target=/run/secrets/pmg-ca.pem,mode=0444 \ if [ -f /run/secrets/pmg-ca.pem ]; then export NODE_EXTRA_CA_CERTS=/run/secrets/pmg-ca.pem; fi; \ npm ci COPY . . CMD ["node", "index.js"] ``` `mode=0444` is required. BuildKit mounts a secret that only root can read, and the install can run as a different user. Set the variable that your package manager reads: | Package manager | Variable | | - | - | | npm, pnpm | `NODE_EXTRA_CA_CERTS` | | pip | `PIP_CERT` | | uv, Go | `SSL_CERT_FILE` | | Cargo | `CARGO_HTTP_CAINFO` | To give the bundle to a container at runtime, mount it in the container: > [tab] docker run > > ```bash theme={null} > docker run -v "$PWD":/app -w /app \ > -v "$PMG_CA_BUNDLE":/pmg-ca.pem:ro -e NODE_EXTRA_CA_CERTS=/pmg-ca.pem \ > node:24 npm ci > ``` > [tab] Docker action > > A Docker action can read files in the workspace, at `/github/workspace`. Copy the bundle there in a step before the action: > > ```yaml theme={null} > - run: cp "$PMG_CA_BUNDLE" pmg-ca.pem > - uses: some/docker-action@v1 > env: > NODE_EXTRA_CA_CERTS: /github/workspace/pmg-ca.pem > ``` ## Job containers and Docker actions > [!NOTE] > > You need this setup only when the job runs in a job container. Kernel enforcement does not work in a job container. On a job without a job container, use `enforce-namespaces: redirect` instead. It sends Docker actions, `docker://` steps, `docker run`, and `docker build` through PMG. See [Protect Docker builds and containers](#protect-docker-builds-and-containers). In a job with a job container (`jobs..container`), the action and the proxy run inside that container, and `run:` steps reach the proxy at `127.0.0.1`. A Docker action or a `docker://` step runs in a different container on the job network, where `127.0.0.1` is its own loopback, so its connection to the proxy fails. Set `expose-to-job-network` to bind the proxy to the job container's address on the job network: ```yaml theme={null} jobs: build: runs-on: ubuntu-latest timeout-minutes: 30 container: image: node:24 options: --init steps: - uses: actions/checkout@v6 - uses: safedep/pmg@v0.34.0 with: expose-to-job-network: true - run: npm ci - uses: docker://node:24 with: args: npm ci ``` Every container on the job network can then reach the proxy, including service containers. The runner mounts `/github/home` in the job container and in Docker actions, so the exported CA path is valid in both. The action fails when the job has no job container, and it warns when `HOME`, `XDG_CONFIG_HOME`, or `PMG_CONFIG_DIR` moves the CA outside `/github/home`. The action needs a POSIX shell and common tools in the image, such as busybox, plus `curl` or `wget`. It does not need `bash` or Node in the image. Alpine images such as `node:24-alpine` work as they are. An Alpine job container on arm64 does not work, because the runner has no Node build for it. ## Self-hosted runners `enforce: auto` does not enforce on a self-hosted runner. Kernel enforcement adds the PMG CA to the trust store of the host, and the CA stays after the job. A host that more than one repository shares then trusts the PMG CA for every job. Set `enforce: true` on an ephemeral runner, or on a host that only trusted jobs use. > [!WARNING] > > Deploy PMG one way on a runner host. Either use the `safedep/pmg` action in each workflow, or install PMG for the whole system and run the proxy as a service on the host. PMG does not support both on one host. To run the proxy as a service on the host, see [Kernel Enforcement on Linux](/package-security/pmg/kernel-enforcement). On that host, remove the `safedep/pmg` step from the workflows. One host proxy serves all jobs, so the jobs get no post step, no job summary, and no verdict for each job. The host proxy routes only the processes on the host. A job container, a Docker action, or a `docker run` step goes around it unless the proxy redirects containers and each container trusts the PMG CA. See [Kernel Enforcement on Linux](/package-security/pmg/kernel-enforcement). ## Action inputs and outputs ### Inputs An input that maps to a `PMG_*` variable or to a config key has no effect when you leave it empty. PMG then uses the value from `config-file`, or its own default. | Input | Default | Effect | | - | - | - | | `version` | `latest` | The PMG release to install, for example `v0.34.0`, or `latest`. | | `cache` | `false` | Set `true` to keep the PMG binary in the runner tool cache. The action checks the cached file against the release checksum on each run. | | `api-key` | Empty | The SafeDep Cloud API key. Set it with `tenant-id`, from a secret. With both inputs, the proxy sends its events to SafeDep Cloud. The action fails when you set only one of them. | | `tenant-id` | Empty | The SafeDep Cloud tenant ID. Set it with `api-key`. | | `endpoint-id` | `gha//` | The name of the runner in SafeDep Cloud. Applies only with `api-key` and `tenant-id`. | | `server-mode` | Empty (server mode) | Set `false` to use the PMG shims instead of the proxy. With shims, the job has no job summary and no kernel enforcement. `sandbox: true` also selects shims. | | `fail-on-violation` | `true` | Fail the job at its end when PMG blocked a package or the network policy denied a connection. Set `false` to report a block without a failed job. When PMG cannot stop the proxy, for example after a crash, the job fails with every setting. | | `auto-stop` | `true` | Stop the proxy in the post step. Set `false` when a step of the job stops the proxy. | | `baseline` | `true` | Show the proposed network profile and the list of destination hosts in the job summary. Set `false` to leave them out. | | `enforce` | `auto` | Kernel enforcement: `auto`, `true`, or `false`. See [Enforce in the kernel](#enforce-in-the-kernel). | | `enforce-ports` | Empty | With enforcement, more destination ports that the kernel routes through the proxy. | | `enforce-exempt-users` | Empty | With enforcement, users that the kernel never routes. | | `enforce-exempt-executables` | Empty | With enforcement, programs that connect directly, as absolute paths or globs. | | `enforce-skip-destinations` | Empty | With enforcement, CIDR prefixes that the kernel never routes. | | `enforce-namespaces` | `ignore` | With enforcement, what happens to the containers that steps start: `ignore`, `redirect`, or `auto`. `redirect` fails the job when the runner cannot redirect them. `auto` redirects them where the runner can. See [Protect Docker builds and containers](#protect-docker-builds-and-containers). | | `network-profile` | Empty | The network profile that the proxy applies, as a path in the repository or a built-in name. Turns on server mode, and fails with `server-mode: false`. See [Allow Only Known Hosts in GitHub Actions](/package-security/pmg/github-actions-network-policy). | | `network-mode` | `audit` | With `network-profile`, what the proxy does with a denied destination: `audit` or `enforce`. | | `expose-to-job-network` | `false` | In a job with a job container, bind the proxy to the address of the job container on the job network. The action fails when the job has no job container. Ignored with `enforce: true`. See [Job containers and Docker actions](#job-containers-and-docker-actions). | | `paranoid` | `false` | Set `true` to block suspicious packages as well as malicious ones. Sets `PMG_PARANOID`. | | `cooldown-enabled` | `true` | Set `false` to allow package versions that were published recently. Sets `PMG_DEPENDENCY_COOLDOWN_ENABLED`. | | `cooldown-days` | `2` | The number of days that a new package version stays blocked. Sets `PMG_DEPENDENCY_COOLDOWN_DAYS`. | | `sandbox` | `false` | Set `true` to run package managers in an OS sandbox. Applies only with shims, so it turns off server mode unless `server-mode` is `true`. The action also relaxes the AppArmor limit on user namespaces on the runner. Sets `PMG_SANDBOX_ENABLED`. | | `sandbox-driver` | `landlock` | The sandbox backend: `landlock` or `bubblewrap`. With `bubblewrap`, the action installs it with `apt-get`. Sets `PMG_SANDBOX_DRIVER`. | | `verbosity` | `normal` | The PMG output level: `silent`, `normal`, or `verbose`. Sets `PMG_VERBOSITY`. | | `disable-telemetry` | `false` | Set `true` to stop anonymous PMG telemetry. Sets `PMG_DISABLE_TELEMETRY`. | | `skip-event-logging` | `false` | Set `true` to stop writing audit events to the local event log. This also removes the proposed network profile from the job summary. Sets `PMG_SKIP_EVENT_LOGGING`. | | `config-file` | Empty | The path of a PMG `config.yml` in the repository. The action copies it to the PMG config directory before PMG starts. An input that you set overrides the same key in the file. | The `enforce-*` inputs take a list, separated by commas or new lines. Each list adds to the same list in the config. The `proxy-mode` input is removed. The value `false` fails the job. Any other value gives a warning. ### Outputs | Output | Value | | - | - | | `version` | The PMG release that the action installed, for example `v0.34.0`. | | `bin-dir` | The directory that holds the `pmg` binary on the runner. | To read an output, give the step an `id`: ```yaml theme={null} - uses: safedep/pmg@v0.34.0 id: pmg - run: echo "PMG ${{ steps.pmg.outputs.version }} is in ${{ steps.pmg.outputs.bin-dir }}" ``` ### Supported runners The action supports Linux runners on x86\_64 and arm64. On a macOS or Windows runner, the action fails. ## Use raw commands To wire the proxy up directly without the action: ```yaml theme={null} - run: pmg proxy start --daemon - run: pmg proxy env >> "$GITHUB_ENV" - run: npm ci - run: pmg proxy stop --fail-on-violation if: always() ``` > [!WARNING] > > `pmg proxy env >> "$GITHUB_ENV"` sets `HTTP_PROXY`, `HTTPS_PROXY`, and the CA variables for every later step. `pmg proxy stop` does not remove the variables. A step after the stop step that uses the network connects to the stopped proxy and fails, for example `actions/upload-artifact` with `ECONNRESET`. Put the stop step last in the job. The action does not have this problem, because its post step empties the proxy variables after the stop. For the proxy lifecycle, certificate trust, bind address, and cloud event sync, see the [persistent proxy server docs](https://github.com/safedep/pmg/blob/main/docs/persistent-proxy.md). > [card] [Allow Only Known Hosts in GitHub Actions](/package-security/pmg/github-actions-network-policy) > > Refuse every host that the job does not need. > [card] [Kernel Enforcement on Linux](/package-security/pmg/kernel-enforcement) > > Route every process and container on the runner through PMG. > [card] [PMG](/package-security/pmg/overview) > > How PMG blocks malicious packages at install time. > [card] [Malicious Package](/concepts/malicious-package) > > How SafeDep detects malicious packages. # Allow Only Known Hosts in GitHub Actions Source: https://docs.safedep.io/package-security/pmg/github-actions-network-policy Build a network policy from the PMG job summary, commit it, and make PMG refuse every other destination in GitHub Actions. A compromised package can send your CI secrets to a host that the attacker controls. A network policy lists the hosts that a job can reach. The PMG proxy refuses every other destination, and the job fails. [PMG Network Policy for GitHub Actions](https://www.youtube.com/embed/F6FKH_gi5EY) > [!NOTE] > > This page uses `safedep/pmg@v0.34.0` or later. Earlier releases have no job summary and need the stop and proposal steps that their documentation shows. Use the policy with [kernel enforcement](/package-security/pmg/github-actions#enforce-in-the-kernel). Without it, a process can ignore the proxy variables and connect directly. ## Build the policy from a run The proxy records every destination that a job reaches. At the end of the job, the post step of the action proposes a profile from these destinations and shows it in the job summary. **1. Run the job with the action** ```yaml theme={null} - uses: safedep/pmg@v0.34.0 with: enforce: true - run: npm ci ``` The job summary proposes a profile for `.pmg/network.yml`. To propose it for another path, set `network-profile` to a path that does not exist yet. The proposal comes from the event log, so do not set `skip-event-logging: true` or `baseline: false`. **2. Review the proposal** The proposal has one allow rule for each host that the job reached. It inherits the built-in `github-actions` profile, which allows the hosts of the runner and refuses every host that no rule allows. One run does not reach every host that the job needs. Remove each host that the job does not need. **3. Commit the profile** Save the proposal as `.pmg/network.yml`, commit it, and set `network-profile` on the action: ```yaml theme={null} - uses: safedep/pmg@v0.34.0 with: enforce: true network-profile: .pmg/network.yml ``` `network-mode` is `audit` by default. Each later run lists the destinations that the profile does not allow, in the summary and as a warning on the run. The summary shows the rules to add. **4. Protect the profile** The profile controls what the job can reach, so give it the same review as the workflow file. Add a `CODEOWNERS` line: ```text theme={null} .pmg/network.yml @your-org/security ``` A committed profile looks like this: ```yaml .pmg/network.yml theme={null} name: network inherits: github-actions network: deny_ip_literals: true allow_outbound: - registry.npmjs.org:443 deny_outbound: - "*:*" ``` `deny_ip_literals` refuses a connection to an IP address that is not explicitly allowed. Without it, an allow list of names does not stop a package that sends data to an IP address. ## Enforce the policy Set `network-mode: enforce`: ```yaml theme={null} - uses: safedep/pmg@v0.34.0 with: enforce: true network-profile: .pmg/network.yml network-mode: enforce - run: npm ci ``` The proxy refuses each destination that the profile does not allow. The post step fails the job, and the job summary names the destination, the rule, and the program. The two inputs control different things: | Input | What it controls | | - | - | | `enforce: true` | Which connections reach the proxy. The Linux kernel sends every process on the runner through the proxy, so a step cannot go around it. | | `network-mode: enforce` | What the proxy does with a destination that the profile does not allow. `enforce` refuses the connection. `audit`, the default, lets it through and records it. | Use both. Without `enforce: true`, a process that ignores the proxy variables connects directly, and the profile never sees the connection. To add a host later, run the job with `network-mode: audit` and add the rule that the summary shows. Under `enforce`, the proxy refuses a new destination, so the proposal gets no rule for it. ## Hosts of the runner Make your profile inherit `github-actions`. This built-in profile allows the hosts of the runner, its agents, GitHub releases, the GitHub container registry, and the cache and artifact storage. To see the hosts, run: ```bash theme={null} pmg sandbox profile show github-actions ``` Do not inherit another built-in profile, such as `npm-restrictive`. It does not allow the hosts of the runner, so the proxy refuses the connections of the runner to GitHub. The runner, `actions/cache`, and `actions/upload-artifact` store data in Azure storage. `github-actions` allows only the storage accounts that the [GitHub Meta API](https://api.github.com/meta) lists, not every Azure storage account. When GitHub adds a storage account, a job under `network-mode: enforce` fails, and the job summary names a denied `productionresultssa.blob.core.windows.net` host. Add that host to `network.allow_outbound` in your profile. You do not need a new PMG release. An action that downloads from another host also needs a rule in your profile. ## Next steps For the steps without `enforce` and the steps with `config-file`, see [Build the profile from a run](https://github.com/safedep/pmg/blob/main/docs/github-action.md#build-the-profile-from-a-run) in the PMG action documentation. For all inputs of the action, see [Inputs](/package-security/pmg/github-actions#inputs). > [card] [PMG in GitHub Actions](/package-security/pmg/github-actions) > > Set up the PMG action and kernel enforcement. > [card] [Limit the Hosts a Package Install Can Reach](/package-security/pmg/network-policy) > > Apply a network policy on a developer machine. # Kernel Enforcement on Linux Source: https://docs.safedep.io/package-security/pmg/kernel-enforcement Make the Linux kernel route every package install through PMG, on VMs, build hosts, self-hosted CI runners, and the containers they start. PMG's persistent proxy serves every package manager on a host through proxy environment variables. A variable is a request. A process can drop it with `env -i` or `sudo`, and an install script with its own HTTP client never reads it. Kernel enforcement closes that gap on Linux. The kernel sends every TCP connection to ports 80 and 443 from every eligible process to the PMG proxy. A process cannot opt out. This page covers a Linux host you operate: a VM, a shared build machine, or a self-hosted CI runner for GitHub Actions, GitLab, CircleCI, Jenkins, or any other CI system. It also covers the containers that host starts. For GitHub hosted runners, the `safedep/pmg` action does these steps for you. See [PMG in GitHub Actions](/package-security/pmg/github-actions#enforce-in-the-kernel). > [!NOTE] > > Kernel enforcement and the container redirect are in PMG v0.31.0 and later. Kernel enforcement is Linux only. On macOS and Windows, `pmg proxy start --enforce` fails with an error that names the platform. ## Requirements * Linux 5.15 or later with kernel BTF (`CONFIG_DEBUG_INFO_BTF`) and cgroup v2. * Root. Attaching the kernel programs needs `CAP_BPF`, `CAP_NET_ADMIN`, and `CAP_PERFMON`. * The PMG CA in the system trust store. Install it with `sudo pmg setup cert install --system`. The daemon refuses to start without it. * For containers: nf\_tables and conntrack. Every Docker host has them. Run `pmg setup doctor` to check whether a host can enforce. The `Kernel enforcement` line names what is missing. ## Enforce on a Linux host Every `pmg proxy` command runs with `sudo` and an explicit `--state` path, because `sudo` resets `HOME`. **1. Install the PMG CA into the system trust store** ```bash theme={null} sudo pmg setup cert install --system ``` As root, this writes the keypair to `/etc/safedep/pmg/` with a root-owned key and installs the certificate into the system store. **2. Start the daemon with enforcement** ```bash theme={null} sudo pmg proxy start --daemon --enforce --state /run/pmg/proxy-state.json ``` The daemon attaches to the cgroup v2 root, so it covers every process on the host. It attaches before it reports ready. Add `--enforce-namespaces redirect` to cover containers too. See [Containers](#containers). **3. Export the trust variables** ```bash theme={null} sudo pmg proxy env --state /run/pmg/proxy-state.json ``` Under enforcement this prints no proxy variables. It prints the variables that point tools at the system trust store: `NODE_USE_SYSTEM_CA=1`, `UV_NATIVE_TLS=1`, `REQUESTS_CA_BUNDLE`, and `PMG_CA_BUNDLE`. Put them in the environment of the processes that install packages. On a CI runner, that is the runner's environment file. **4. Check the status** ```bash theme={null} sudo pmg proxy status --state /run/pmg/proxy-state.json ``` The output names the config file the daemon read, the enforced ports, the exempt executables, and the namespace mode. **5. Stop the daemon** ```bash theme={null} sudo pmg proxy stop --state /run/pmg/proxy-state.json --fail-on-violation ``` The kernel detaches the programs when the daemon exits, after a stop and after a crash. Nothing is left to clean up. Until the daemon runs again, connections go out directly. > [!WARNING] > > A root daemon reads the managed config, `/etc/safedep/pmg/config.yml`, when it exists, and root's own per-user file otherwise. It never reads the file of the user who ran `sudo`. Set the policy with `sudo pmg config edit --system`. ### Run the daemon as a service On a host that stays up, such as a self-hosted runner, a `systemd` unit starts the daemon at boot and restarts it on failure. The PMG repository ships an [example unit](https://github.com/safedep/pmg/blob/main/examples/systemd/pmg-proxy.service). It runs the daemon as root, keeps the state file under `/run/pmg`, and starts before the runner service, so the runner's own connections are enforced too. 1. Install the PMG CA as root: `sudo pmg setup cert install --system`. 2. Put the policy in `/etc/safedep/pmg/config.yml`, with `proxy.server.listen_port` fixed and `proxy.server.enforce.enabled: true`. 3. Install and start the unit: `sudo cp pmg-proxy.service /etc/systemd/system/ && sudo systemctl enable --now pmg-proxy`. 4. Give the runner the trust variables from `pmg proxy env` through its environment file, such as the `.env` file of a GitHub Actions runner. A job cannot stop a root daemon, so the daemon serves every job until an operator stops it. `pmg proxy status` shows that it still enforces. ### CI runners On a GitHub Actions runner host, the service replaces the `safedep/pmg` action. PMG does not support both on one host. Remove the `safedep/pmg` step from the workflows that run on that host. See [PMG in GitHub Actions](/package-security/pmg/github-actions#self-hosted-runners). Do not exempt the runner. Its traffic to the CI service goes through the proxy, which passes it through with the real certificate. The user that runs the jobs can write the runner's folder, so an exemption would let a job put any program there under an exempt name and reach a registry directly. Set a job timeout on every enforced job. If the daemon stops serving but keeps running, the runner cannot report, and the job hangs until the CI system cancels it. A self-hosted runner is then offline until the daemon restarts. `Restart=on-failure` does not restart a hung daemon. ## Set the policy Every process is eligible unless the policy says otherwise. Only the daemon's own process is exempt. The `pmg` binary is not, so `PMG_INSECURE_INSTALLATION=true pmg npm install` cannot bypass the daemon. ```yaml theme={null} proxy: server: listen_port: 7777 enforce: enabled: true ports: [80, 443] exempt_users: [] eligible_users: [] exempt_executables: - /opt/observability/bin/agent skip_destinations: [10.20.0.0/16] deny_udp: true namespaces: mode: ignore ``` | Key | What it does | | - | - | | `ports` | Destination ports the kernel routes. The ports of your [custom registries](https://github.com/safedep/pmg/blob/main/docs/proxy-mode.md#custom-registries) are always added. | | `exempt_executables` | Absolute paths or globs of programs that connect directly. The daemon also exempts a matching file that appears later. | | `exempt_users` | Users the kernel never routes. | | `eligible_users` | Limits enforcement to these users. Empty means every user. | | `skip_destinations` | CIDR prefixes the kernel never routes, in addition to loopback, link-local, and the Azure host address `168.63.129.16`. | | `deny_udp` | Refuses UDP to the enforced ports, so a QUIC client falls back to TCP. On by default. | | `namespaces.mode` | What happens to containers: `ignore`, `redirect`, or `auto`. See [Containers](#containers). | > [!WARNING] > > Never exempt an interpreter such as `node`, `python3`, or `sh`, an HTTP client such as `curl` or `wget`, or a CI runner. An install script can run any of them. An exemption covers a file, so a user who can write its folder can add a matching file. > > `eligible_users` is safe only when no eligible user can become another one. `sudo curl` runs as root, and root is then not eligible. Leave it empty on a host whose users have `sudo`. Every key has a flag on `pmg proxy start` and a `PMG_*` variable, for example `--enforce-exempt-executable` and `PMG_PROXY_SERVER_ENFORCE_EXEMPT_EXECUTABLES`. A list flag adds to the list in the file. See the [policy table](https://github.com/safedep/pmg/blob/main/docs/persistent-proxy.md#policy-from-the-command-line) in the PMG repository. ## Containers A container has its own network namespace, so the kernel programs do not see its connections. Its traffic enters the host through a bridge, and PMG can redirect it there. Set `namespaces.mode` or the `--enforce-namespaces` flag: * `redirect` turns the redirect on. The start fails when the host cannot redirect. * `auto` turns it on where the host can, and runs as `ignore` elsewhere. `pmg proxy status` shows the reason. * `ignore` is the default. Containers are not enforced. The redirect covers `docker run`, `RUN` steps in `docker build` with the default builder and with a `docker-container` builder, and containers that a CI job starts. The daemon adds `169.254.200.1` to `lo`, listens on it, and loads one nftables table named `pmg`. A rule on each ingress interface, `docker0` and `br-*` by default, sends TCP to the enforced ports to that listener. The kernel deletes the table when the daemon exits. > [!WARNING] > > A host firewall with a default deny on input, such as ufw or firewalld, drops the redirected connection, and the container hangs. The daemon warns at start and names the rule to add. For ufw: > > ```bash theme={null} > sudo ufw allow in on docker0 to 169.254.200.1 > ``` ### Trust inside a container The redirect is transparent. Trust is not. The proxy terminates a connection to a registry host with the PMG CA, and a container that does not trust the CA fails the TLS handshake. The daemon log names the fix. Every other host keeps its real certificate. Pass the file that `PMG_CA_BUNDLE` names into the container. It holds the PMG CA and the public roots. `NODE_EXTRA_CA_CERTS` adds to the container's own trust. A tool that replaces its bundle, through `SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE`, `PIP_CERT`, or `CURL_CA_BUNDLE`, needs this full bundle. > [tab] docker run > > ```bash theme={null} > docker run -v "$PMG_CA_BUNDLE":/pmg-ca.pem:ro -e NODE_EXTRA_CA_CERTS=/pmg-ca.pem node:22 npm ci > ``` > [tab] docker build > > Pass the bundle as a secret, so it never enters the image. `mode=0444` is required, because BuildKit mounts a secret readable by root only. > > ```bash theme={null} > docker build --secret id=pmg-ca,src=$PMG_CA_BUNDLE -t app . > ``` > > ```dockerfile theme={null} > RUN --mount=type=secret,id=pmg-ca,target=/run/pmg-ca.pem,mode=0444 \ > NODE_EXTRA_CA_CERTS=/run/pmg-ca.pem npm ci > ``` ## Verify Run these on a Linux machine with Docker before you turn enforcement on for real jobs. Start the daemon with the container redirect on, then run each command from another terminal. ```bash theme={null} sudo pmg proxy start --daemon --enforce --enforce-namespaces redirect --state /run/pmg/proxy-state.json ``` 1. A host process is enforced. Without proxy variables, `curl` still reaches the registry through the proxy. ```bash theme={null} env -i /usr/bin/curl -sSv -o /dev/null https://registry.npmjs.org/ 2>&1 | grep issuer # issuer: O=SafeDep PMG; CN=SafeDep PMG Proxy CA ``` 2. A container that connects to a host that is not a registry passes through. It needs nothing. ```bash theme={null} docker run --rm curlimages/curl -sS https://ifconfig.co ``` 3. A container that connects to a registry without the PMG CA fails closed. ```bash theme={null} docker run --rm curlimages/curl -sS https://registry.npmjs.org/-/ping # curl: (60) SSL certificate problem ``` 4. With the bundle mounted, the registry works through the proxy, and a known malicious test package is blocked. ```bash theme={null} eval "$(sudo pmg proxy env --state /run/pmg/proxy-state.json)" docker run --rm -v "$PMG_CA_BUNDLE":/pmg-ca.pem:ro -e CURL_CA_BUNDLE=/pmg-ca.pem \ curlimages/curl -sS -o /dev/null -w '%{http_code}\n' \ https://registry.npmjs.org/safedep-test-pkg/-/safedep-test-pkg-0.1.3.tgz # 403 ``` `sudo nft list table inet pmg` shows the redirect rules while the daemon runs. ## Coverage and limits What the kernel routes: | Traffic | Covered | | - | - | | TCP to an enforced port from a host process | Yes. The kernel redirects it to the proxy. | | TCP from a container on `docker0` or `br-*` | Yes, with `namespaces.mode: redirect` or `auto`. | | A container with `--network host` | Yes. It is in the host namespace and takes the host path. | | A CI job that runs inside a container | Yes, when the daemon runs on the host and the redirect is on. A job container on a GitHub hosted runner has no host daemon. See [PMG in GitHub Actions](/package-security/pmg/github-actions#job-containers-and-docker-actions). | | UDP to an enforced port | Refused with `deny_udp`. QUIC clients fall back to TCP. | | IPv6 from a container to an enforced port | Refused. The listener has an IPv4 address, and the client falls back to IPv4. | | A process with an exempt executable or an exempt user | No. It connects directly. | Known limits: * The proxy decides by host name. A redirected TLS connection without SNI, or with Encrypted ClientHello, and a plain HTTP request without a `Host` header are dropped. A registry that clients reach by IP needs a name, or a `skip_destinations` entry so the kernel never redirects it. * A client that pins certificates fails closed on registry hosts. * Node 20 cannot read the system trust store and is not supported under enforcement. Node 22 and later work with `NODE_USE_SYSTEM_CA=1`. * An exemption covers a file, not the code that runs in it. Any process can start an exempt program with `LD_PRELOAD` and run its own code in it. Keep the exempt list short. * `sudo` bypasses `eligible_users`, as described in [Set the policy](#set-the-policy). * One daemon enforces one cgroup. A second `pmg proxy start --enforce` on the same cgroup fails. * The daemon runs as root for its whole life. > [card] [PMG in GitHub Actions](/package-security/pmg/github-actions) > > The action uses kernel enforcement by default on GitHub hosted runners. > [card] [PMG System Install](/package-security/pmg/system-install) > > Protect every user on a shared Linux host or in a Docker image with PATH shims. > [card] [Limit the Hosts a Package Install Can Reach](/package-security/pmg/network-policy) > > Allow only the hosts that installs need. > [card] [Persistent proxy reference](https://github.com/safedep/pmg/blob/main/docs/persistent-proxy.md) > > How the kernel programs and the container redirect work, with every policy key. > [card] [PMG](/package-security/pmg/overview) > > How PMG blocks malicious packages at install time. # PMG in Kubernetes Source: https://docs.safedep.io/package-security/pmg/kubernetes Block package installs inside Kubernetes workloads and report PMG events with a stable workload identity. Use PMG in a Kubernetes workload that installs packages at run time. Common examples include development workspaces, build Pods, and CI jobs. PMG protects only the containers that include it. It does not protect other Pods in the cluster. It also does not scan packages that are already in an image. > [!NOTE] > > Use the [Docker image guide](/package-security/pmg/system-install#docker-images) to protect package installs during an image build. This guide adds Kubernetes workload identity and cloud reporting to a PMG-enabled image. ## Requirements * PMG v0.28.0 or later * A Linux container image * A workload that runs a supported package manager * A writable home directory for the container user, or writable `PMG_CONFIG_DIR` and `PMG_CACHE_DIR` paths You need a SafeDep Cloud API key and tenant ID only when you want to send events to [Package Guard](/governance/cloud/endpoint-hub/package-guard). PMG blocks malicious packages without these credentials. ## Build a PMG-enabled image Install PMG in each image that runs package manager commands. ```dockerfile theme={null} FROM ghcr.io/safedep/pmg:v0.28.0 AS pmg FROM node:22-bookworm COPY --from=pmg /usr/local/bin/pmg /usr/local/bin/pmg RUN pmg setup install --system ENV PATH="/usr/local/lib/pmg/bin:$PATH" RUN mkdir -p /app && chown node:node /app WORKDIR /app USER node COPY --chown=node:node package*.json ./ RUN npm ci COPY --chown=node:node . . CMD ["node", "index.js"] ``` > [!NOTE] > > This example shows the minimum PMG version that supports Kubernetes identity. Check the [PMG releases](https://github.com/safedep/pmg/releases) for the current stable version. Replace `v0.28.0` before you build the image. The `PATH` value routes package manager commands through PMG. Keep the PMG shim directory before the real package manager directory. The `npm ci` command in this example runs during the image build. PMG protects it as a Docker build command. PMG uses Kubernetes identity only for commands that run after Kubernetes starts the container. > [!WARNING] > > Do not set `PMG_CLOUD_ENDPOINT_ID` in an image that runs on Kubernetes. This value overrides the automatic Kubernetes workload identity. ## Add the workload identity PMG can group all replicas of one workload under one endpoint. It can also attach the Pod name and Pod UID to each install session. **1. Create the Cloud Secret** Skip this step if you do not use SafeDep Cloud. Also omit `PMG_CLOUD_ENABLED`, `SAFEDEP_API_KEY`, and `SAFEDEP_TENANT_ID` from the workload. Create a local file named `safedep-cloud.env`. ```text theme={null} SAFEDEP_API_KEY= SAFEDEP_TENANT_ID= ``` Create the Kubernetes Secret in the target namespace. ```bash theme={null} kubectl create secret generic safedep-cloud \ --from-env-file=safedep-cloud.env ``` Delete the local file after Kubernetes creates the Secret. Do not commit the file to source control. **2. Add PMG to the workload** Add the PMG settings and Kubernetes fields to the container that runs package installs. ```yaml theme={null} apiVersion: apps/v1 kind: Deployment metadata: name: checkout spec: replicas: 2 selector: matchLabels: app: checkout template: metadata: labels: app: checkout spec: containers: - name: checkout image: registry.example.com/checkout:1.0.0 env: - name: PMG_CLOUD_ENABLED value: "true" - name: SAFEDEP_API_KEY valueFrom: secretKeyRef: name: safedep-cloud key: SAFEDEP_API_KEY - name: SAFEDEP_TENANT_ID valueFrom: secretKeyRef: name: safedep-cloud key: SAFEDEP_TENANT_ID - name: KUBE_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: KUBE_POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: KUBE_POD_UID valueFrom: fieldRef: fieldPath: metadata.uid - name: KUBE_WORKLOAD_NAME value: checkout - name: KUBE_WORKLOAD_KIND value: Deployment ``` Set `KUBE_WORKLOAD_NAME` to the workload name. Set `KUBE_WORKLOAD_KIND` to `Deployment`, `StatefulSet`, `DaemonSet`, `Job`, `CronJob`, `ReplicaSet`, or `Pod`. Kubernetes does not expose the owning workload through a Downward API field. The workload manifest must set these two values. **3. Set the cluster name when needed** Set a cluster name when one SafeDep tenant receives events from more than one cluster. ```yaml theme={null} - name: KUBE_CLUSTER_NAME value: prod-eu ``` Use the same value for all workloads in one cluster. **4. Deploy the workload** Save the manifest as `checkout.yaml` and apply it. ```bash theme={null} kubectl apply -f checkout.yaml kubectl rollout status deployment/checkout ``` PMG does not call the Kubernetes API. The container does not need extra RBAC permissions. ## How PMG names the endpoint PMG uses one of these endpoint IDs. * `k8s:/` * `k8s://` All replicas of the `checkout` Deployment use the same endpoint ID. Each install session still includes its Pod name and Pod UID. PMG can derive common workload names from generated Pod names. Set `KUBE_WORKLOAD_NAME` so the identity stays stable for every workload type. Do not set `cloud.endpoint_id` or `PMG_CLOUD_ENDPOINT_ID`. A configured endpoint ID has higher priority than the Kubernetes identity. See the [PMG configuration reference](https://github.com/safedep/pmg/blob/main/docs/config.md#endpoint-identity) for the full priority order. ## Sync short-lived workloads PMG starts automatic cloud sync after package manager commands. This mode works for long-running Pods. A Job can stop before the automatic sync process finishes. Run a final sync before a short-lived container exits. Disable automatic sync in the short-lived container. ```yaml theme={null} - name: PMG_CLOUD_AUTO_SYNC_ENABLED value: "false" ``` Run the package manager and the final sync in the same container command. ```yaml theme={null} command: ["/bin/sh", "-c"] args: - | npm ci install_status=$? pmg cloud sync --timeout 60s sync_status=$? if [ "$install_status" -ne 0 ]; then exit "$install_status" fi exit "$sync_status" ``` This command runs the sync when `npm ci` fails. It also keeps the package manager exit status when PMG blocks a package. > [!NOTE] > > An abrupt Pod deletion can remove events that PMG has not synced. Use an explicit final sync for Jobs and other short-lived workloads. ## Verify the deployment Check the PMG version and system setup. ```bash theme={null} kubectl exec deployment/checkout -- pmg version kubectl exec deployment/checkout -- pmg setup doctor ``` Check that the package manager resolves through the PMG shim. ```bash theme={null} kubectl exec deployment/checkout -- sh -c 'command -v npm' ``` The command must print `/usr/local/lib/pmg/bin/npm`. Test the block with the benign SafeDep test package. The command must fail because PMG marks this package as malicious for testing. ```bash theme={null} kubectl exec deployment/checkout -- sh -c \ 'cd /tmp && npm install --no-cache --prefer-online safedep-test-pkg@0.1.3' ``` Sync the test event now. ```bash theme={null} kubectl exec deployment/checkout -- pmg cloud sync --timeout 60s ``` Open [SafeDep Cloud](https://app.safedep.io). Select **Endpoint Hub**, and then select the Kubernetes workload endpoint. The endpoint name must match `k8s:/checkout` or `k8s://checkout`. ## Troubleshooting > [accordion] The package manager does not use the PMG shim > > Check the `PATH` inside the container. > > ```bash theme={null} > kubectl exec deployment/checkout -- sh -c 'printf "%s\n" "$PATH"' > ``` > > Keep `/usr/local/lib/pmg/bin` before the package manager directory. Call `pmg npm` or `pmg pip` directly when a version manager changes `PATH`. > [accordion] The endpoint does not use a Kubernetes name > > Remove `PMG_CLOUD_ENDPOINT_ID` from the image and workload. Also remove `cloud.endpoint_id` from the PMG config. > > Set `KUBE_NAMESPACE` and `KUBE_WORKLOAD_NAME` in the container environment. > [accordion] Each Pod appears as a different endpoint > > Set one `KUBE_WORKLOAD_NAME` value for all replicas. Do not use the Pod name as the workload name. > [accordion] PMG cannot write its runtime data > > Make the container user's home directory writable. You can also set `PMG_CONFIG_DIR` and `PMG_CACHE_DIR` to writable paths. > > Do not let an init process create these directories as another user. > [accordion] A Job does not send its final events > > Run `pmg cloud sync --timeout 60s` before the container exits. Confirm that the container has the Cloud Secret and network access during the sync. > [card] [Docker and shared VMs](/package-security/pmg/system-install) > > Install PMG in an image or on a shared Linux host. > [card] [Package Guard](/governance/cloud/endpoint-hub/package-guard) > > View package install events in SafeDep Cloud. > [card] [PMG configuration](https://github.com/safedep/pmg/blob/main/docs/config.md) > > Review all PMG configuration keys and endpoint identity rules. > [card] [PMG overview](/package-security/pmg/overview) > > Learn how PMG blocks malicious packages. # Intune Source: https://docs.safedep.io/package-security/pmg/mdm/intune Deploy PMG to macOS, Linux, or Windows devices with Intune scripts, or package a Windows Win32 app. Intune script policies accept one script with no script parameters. Windows supports PowerShell policies and [Win32 app packages](#windows-win32-app). Generate a [standalone installer](https://github.com/safedep/pmg/tree/main/scripts/mdm/standalone) for your platform with your SafeDep Cloud credentials embedded, then upload that file. > [!NOTE] > > A [SafeDep subscription](https://safedep.io/pricing) is required to sync PMG events with SafeDep Cloud. For Cloud sync, you need a SafeDep Cloud API key and Tenant ID from [app.safedep.io/settings/api-keys](https://app.safedep.io/settings/api-keys). Installs sync to [Package Guard](/governance/cloud/endpoint-hub/package-guard). PMG blocking works without Cloud. For a local-only deployment, use the [prebuilt standalone scripts](https://github.com/safedep/pmg/tree/main/scripts/mdm/standalone) or omit credentials and `--embed-cloud-credentials` when generating them. ## Install 1. Clone the `main` branch of [pmg](https://github.com/safedep/pmg) and generate the installer from `scripts/mdm/`: > [tab] macOS > > ```sh theme={null} > SAFEDEP_API_KEY=... SAFEDEP_TENANT_ID=... \ > ./generate_standalone_macos.sh \ > --embed-cloud-credentials \ > --output-dir /path/to/pmg-intune > ``` > > Optionally add `--config /path/to/config.yml` for managed config. Set `cloud.enabled: true` in that file. > [tab] Linux > > ```sh theme={null} > SAFEDEP_API_KEY=... SAFEDEP_TENANT_ID=... \ > ./generate_standalone_linux.sh \ > --embed-cloud-credentials \ > --output-dir /path/to/pmg-intune > ``` > > Optionally add `--config /path/to/config.yml` for managed config. Set `cloud.enabled: true` in that file. > [tab] Windows > > Add this setting to your deployment's `config.yml`: > > ```yaml theme={null} > cloud: > enabled: true > ``` > > Keep your other policy settings in this file. The installer replaces the managed config with it. > > Generate the installer with both `--config` and `--embed-cloud-credentials`. Run the generator in Bash on macOS or Linux, or Git Bash on Windows: > > ```sh theme={null} > SAFEDEP_API_KEY=... SAFEDEP_TENANT_ID=... \ > ./generate_standalone_windows.sh \ > --config /path/to/config.yml \ > --embed-cloud-credentials \ > --output-dir /path/to/pmg-intune > ``` > > Credentials alone do not enable Cloud sync. The Windows installer always creates a managed config, which `pmg config set cloud.enabled true` cannot change. > > If you generate the installer in Git Bash, restrict its ACL from an elevated PowerShell terminal in the output directory: > > ```powershell theme={null} > icacls .\pmg_setup_install_windows_standalone.ps1 /inheritance:r ` > /grant:r "BUILTIN\Administrators:F" "NT AUTHORITY\SYSTEM:F" > ``` > [!WARNING] > > Base64 is not encryption. Anyone who can read the uploaded installer in Intune can recover the credentials. Use a scoped, revocable API key. Do not commit the generated artifacts. 2. Upload the generated installer through Intune, using the procedure for your platform: > [tab] macOS > > Follow [Microsoft's procedure for macOS shell scripts](https://learn.microsoft.com/en-us/intune/device-management/tools/run-shell-scripts-macos). Upload `pmg_setup_install_macos_standalone.sh`. Set **Run script as signed-in user** to **No**. > [tab] Linux > > In the Intune admin center: > > * Go to **Devices > Manage devices > Scripts and remediations > Platform scripts**. > * Select the **Linux** tab and add `pmg_setup_install_linux_standalone.sh`. > * Set the execution context to **Root**. > > See [Microsoft's procedure for Linux shell scripts](https://learn.microsoft.com/en-us/intune/intune-service/configuration/custom-settings-linux). > [tab] Windows > > Follow [Microsoft's PowerShell script procedure](https://learn.microsoft.com/en-us/intune/device-management/tools/run-powershell-scripts-windows). Upload `pmg_setup_install_windows_standalone.ps1`. > > * Set **Run this script using the logged on credentials** to **No** (SYSTEM). > * Set **Run script in 64-bit PowerShell host** to **Yes**. > * Sign the generated script if your policy requires it. Otherwise, set **Enforce script signature check** to **No**. > > Windows requires PMG v0.29.0 or later. The installer downloads the latest stable release by default. To pin a version, optionally add `$env:PMG_VERSION = 'v0.29.0'` at the start of the generated script before uploading. 3. Assign the policy to a device group. On macOS and Linux, use a recurring install frequency if new users can be added later. On Windows, only logged-on users receive credentials and sync during a run. Windows platform scripts do not run on a recurring schedule after success. Update the script or policy to rerun the installer when credentials are needed for later sign-ins. A direct standalone upload in Intune cannot pass `--cloud-sync-only` to the script. Run the normal installer again when you need to sync or configure later users. Keep macOS and Linux shell scripts below 1 MB. Windows PowerShell scripts must be below 200 KB, including embedded config and credentials. ## Uninstall Upload the matching uninstaller from the same output directory (`pmg_uninstall_macos_standalone.sh`, `pmg_uninstall_linux_standalone.sh`, or `pmg_uninstall_windows_standalone.ps1`), with the same platform settings as install. Do not assign the install and uninstall policies at the same time. ## Windows Win32 app Use a Win32 app to bundle a release binary, including for devices without GitHub access. 1. Put `lib_windows.ps1`, `pmg_setup_install_windows.ps1`, and `pmg_uninstall_windows.ps1` from [`scripts/mdm/windows`](https://github.com/safedep/pmg/tree/main/scripts/mdm/windows) in one source folder. 2. Add `pmg.exe` from the Windows x86-64 release zip of [v0.29.0 or later](https://github.com/safedep/pmg/releases/latest). A bundled binary must be owned by Administrators or SYSTEM. For Cloud sync, add `config.yml` with `cloud.enabled: true` and your other policy settings. 3. Package the folder with Microsoft's Content Prep Tool and [add the Win32 app](https://learn.microsoft.com/en-us/intune/app-management/deployment/add-win32). 4. Set the install command: ```powershell theme={null} powershell.exe -NoProfile -ExecutionPolicy Bypass -File pmg_setup_install_windows.ps1 ``` 5. Set the uninstall command: ```powershell theme={null} powershell.exe -NoProfile -ExecutionPolicy Bypass -File pmg_uninstall_windows.ps1 ``` 6. Set **Install behavior** to **System**. Add a file-exists detection rule for `%ProgramFiles%\safedep\pmg\pmg.exe`, with **Associated with a 32-bit app on 64-bit clients** set to **No**. 7. Assign the app to the Windows device group. A Win32 app does not set the Cloud environment variables. Have users run `pmg cloud login` in their own sessions, or package the credential-bearing standalone installer generated above and use its filename in the install command. Keep `cloud.enabled: true` in the managed config. ## Manage settings from the cloud policy With the [cloud policy](/package-security/pmg/cloud-policy), your security admin changes the package rules and the dependency cooldown of PMG in SafeDep Cloud, with no new MDM package. To use it on the fleet, change the managed `config.yml` that you ship with the scripts: 1. Set `cloud.enabled: true` and `cloud.policy: true`. 2. Keep `dependency_cooldown.enabled` and `dependency_cooldown.days` out of the file. Under `global_lockdown: true`, PMG keeps the value of each key that the managed file sets, and the cloud policy cannot change it. PMG reports the field as locked, and `safedep endpoint policy show` shows the exception. ```yaml config.yml theme={null} global_lockdown: true cloud: enabled: true policy: true # No dependency_cooldown keys: the cloud policy sets the cooldown. ``` Users cannot change the managed config. To turn off all cloud content on the fleet, ship `cloud.policy: false`. The cloud policy needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). > [card] [Other MDMs](/package-security/pmg/mdm/overview) > > Jamf, JumpCloud, and the script layout. > [card] [MDM scripts README](https://github.com/safedep/pmg/blob/main/scripts/mdm/README.md) > > Source of truth in the PMG repo. # Jamf Source: https://docs.safedep.io/package-security/pmg/mdm/jamf Deploy PMG to macOS devices with a Jamf script payload or package. Deploy PMG with a Jamf policy that runs the [multi-file MDM scripts](https://github.com/safedep/pmg/tree/main/scripts/mdm/macos) as root. Ship `lib_macos.sh` with the install or uninstall script. Jamf manages Apple devices only. For a Linux or Windows fleet, use [JumpCloud](/package-security/pmg/mdm/jumpcloud) or [Intune](/package-security/pmg/mdm/intune) instead. > [!NOTE] > > A [SafeDep subscription](https://safedep.io/pricing) is required to sync PMG events with SafeDep Cloud. You need a SafeDep Cloud API key and Tenant ID from [app.safedep.io/settings/api-keys](https://app.safedep.io/settings/api-keys). Installs sync to [Package Guard](/governance/cloud/endpoint-hub/package-guard). ## Install 1. Download `lib_macos.sh` and `pmg_setup_install_macos.sh` from [`scripts/mdm/macos/`](https://github.com/safedep/pmg/tree/main/scripts/mdm/macos). You can optionally add a sibling `config.yml` for a machine-wide config. If you do, set `cloud.enabled: true` in it. A global config prevents the installer from changing that flag. 2. Upload the folder as a script payload, or as a package that drops the files together at a fixed path. 3. Create a policy that runs as root and invokes the installer. Pass the Cloud credentials as Jamf script parameters `$4` and `$5`: ```sh theme={null} #!/bin/sh cd "$(dirname "$0")" SAFEDEP_API_KEY="$4" SAFEDEP_TENANT_ID="$5" ./pmg_setup_install_macos.sh ``` Renumber `$4` and `$5` if your parameter slots differ. 4. Assign the policy to a computer group and run it. ## Uninstall Create a second policy with `lib_macos.sh` and `pmg_uninstall_macos.sh`: ```sh theme={null} #!/bin/sh cd "$(dirname "$0")" ./pmg_uninstall_macos.sh ``` Assign it to the same computer group. Do not run the install and uninstall policies on the same devices at the same time. ## Run cloud sync only Create a separate policy to repeat cloud sync without installing or configuring PMG again. Reuse the install script and parameters, and add `--cloud-sync-only`: ```sh theme={null} #!/bin/sh cd "$(dirname "$0")" SAFEDEP_API_KEY="$4" SAFEDEP_TENANT_ID="$5" ./pmg_setup_install_macos.sh --cloud-sync-only ``` Assign this policy to the same computer group with a recurring trigger. Use it only for users who already have PMG and cloud sync enabled. Run the normal install policy to configure new users. ## Manage settings from the cloud policy With the [cloud policy](/package-security/pmg/cloud-policy), your security admin changes the package rules and the dependency cooldown of PMG in SafeDep Cloud, with no new MDM package. To use it on the fleet, change the managed `config.yml` that you ship with the scripts: 1. Set `cloud.enabled: true` and `cloud.policy: true`. 2. Keep `dependency_cooldown.enabled` and `dependency_cooldown.days` out of the file. Under `global_lockdown: true`, PMG keeps the value of each key that the managed file sets, and the cloud policy cannot change it. PMG reports the field as locked, and `safedep endpoint policy show` shows the exception. ```yaml config.yml theme={null} global_lockdown: true cloud: enabled: true policy: true # No dependency_cooldown keys: the cloud policy sets the cooldown. ``` Users cannot change the managed config. To turn off all cloud content on the fleet, ship `cloud.policy: false`. The cloud policy needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). > [card] [Other MDMs](/package-security/pmg/mdm/overview) > > JumpCloud, Intune, and the script layout. > [card] [MDM scripts README](https://github.com/safedep/pmg/blob/main/scripts/mdm/README.md) > > Source of truth in the PMG repo. # JumpCloud Source: https://docs.safedep.io/package-security/pmg/mdm/jumpcloud Deploy PMG to macOS, Linux, or Windows devices with JumpCloud Commands. Deploy PMG with a JumpCloud Command that runs as `root` on macOS or Linux, or as `SYSTEM` on Windows. Use the [multi-file MDM scripts](https://github.com/safedep/pmg/tree/main/scripts/mdm) and ship the shared lib with the install or uninstall script for your platform. > [!NOTE] > > A [SafeDep subscription](https://safedep.io/pricing) is required to sync PMG events with SafeDep Cloud. For optional Cloud sync, you need a SafeDep Cloud API key and Tenant ID from [app.safedep.io/settings/api-keys](https://app.safedep.io/settings/api-keys). Installs sync to [Package Guard](/governance/cloud/endpoint-hub/package-guard). ## Install **1. Create a Command** In the JumpCloud Admin Console, create a Command and set **Run As** to `root` for macOS or Linux. Windows Commands run as `SYSTEM`. **2. Attach the scripts** > [tab] macOS > > Upload `lib_macos.sh` and `pmg_setup_install_macos.sh` from [`scripts/mdm/macos/`](https://github.com/safedep/pmg/tree/main/scripts/mdm/macos). Set **File Destination** to `/tmp/pmg-mdm/`. > > Optionally upload a `config.yml` to the same directory for managed config. Set `cloud.enabled: true` in it for Cloud sync. > [tab] Linux > > Upload `lib_linux.sh` and `pmg_setup_install_linux.sh` from [`scripts/mdm/linux/`](https://github.com/safedep/pmg/tree/main/scripts/mdm/linux). Set **File Destination** to `/tmp/pmg-mdm/`. > > Optionally upload a `config.yml` to the same directory for managed config. Set `cloud.enabled: true` in it for Cloud sync. > [tab] Windows > > Upload `lib_windows.ps1` and `pmg_setup_install_windows.ps1` from [`scripts/mdm/windows/`](https://github.com/safedep/pmg/tree/main/scripts/mdm/windows). Set **File Destination** to `C:\Windows\Temp\pmg-mdm\`. > > For the Cloud-enabled Command below, also upload `config.yml` with `cloud.enabled: true` to the same directory. Keep your other policy settings in this file because it replaces the managed config. Credentials alone do not enable sync. > > Optionally include `pmg.exe` from the release zip of [v0.29.0 or later](https://github.com/safedep/pmg/releases/latest) to avoid a download. The bundled binary must be owned by Administrators or SYSTEM. **3. Set the timeout** Set **Timeout After** to at least 900 seconds so a slow download is not killed mid-run. **4. Add Cloud variables** Define the Command Variables `safedep_api_key` and `safedep_tenant_id`. Mark the API key as a Secret variable. For local-only blocking, omit both variables and their assignments from the Command body. **5. Set the Command body** > [tab] macOS > > ```sh theme={null} > #!/bin/sh > set -eu > cd /tmp/pmg-mdm > chmod +x pmg_setup_install_macos.sh > SAFEDEP_API_KEY={{safedep_api_key}} SAFEDEP_TENANT_ID={{safedep_tenant_id}} ./pmg_setup_install_macos.sh > cd / && rm -rf /tmp/pmg-mdm > ``` > [tab] Linux > > ```sh theme={null} > #!/bin/sh > set -eu > cd /tmp/pmg-mdm > chmod +x pmg_setup_install_linux.sh > SAFEDEP_API_KEY={{safedep_api_key}} SAFEDEP_TENANT_ID={{safedep_tenant_id}} ./pmg_setup_install_linux.sh > cd / && rm -rf /tmp/pmg-mdm > ``` > [tab] Windows > > ```powershell theme={null} > $env:SAFEDEP_API_KEY = '{{safedep_api_key}}' > $env:SAFEDEP_TENANT_ID = '{{safedep_tenant_id}}' > & C:\Windows\Temp\pmg-mdm\pmg_setup_install_windows.ps1 > ``` > > Windows requires PMG v0.29.0 or later. The installer downloads the latest stable release by default. To pin a version, optionally set `$env:PMG_VERSION = 'v0.29.0'` before running it. **6. Assign and run** Assign the Command to a device group and run it. ## Uninstall **1. Create a second Command** Use `root` on macOS or Linux, or `SYSTEM` on Windows. > [tab] macOS > > Upload `lib_macos.sh` and `pmg_uninstall_macos.sh` from [`scripts/mdm/macos/`](https://github.com/safedep/pmg/tree/main/scripts/mdm/macos), with **File Destination** `/tmp/pmg-mdm/`. > [tab] Linux > > Upload `lib_linux.sh` and `pmg_uninstall_linux.sh` from [`scripts/mdm/linux/`](https://github.com/safedep/pmg/tree/main/scripts/mdm/linux), with **File Destination** `/tmp/pmg-mdm/`. > [tab] Windows > > Upload `lib_windows.ps1` and `pmg_uninstall_windows.ps1` from [`scripts/mdm/windows/`](https://github.com/safedep/pmg/tree/main/scripts/mdm/windows), with **File Destination** `C:\Windows\Temp\pmg-mdm\`. **2. Set the Command body** > [tab] macOS > > ```sh theme={null} > #!/bin/sh > set -eu > cd /tmp/pmg-mdm > chmod +x pmg_uninstall_macos.sh > ./pmg_uninstall_macos.sh > cd / && rm -rf /tmp/pmg-mdm > ``` > [tab] Linux > > ```sh theme={null} > #!/bin/sh > set -eu > cd /tmp/pmg-mdm > chmod +x pmg_uninstall_linux.sh > ./pmg_uninstall_linux.sh > cd / && rm -rf /tmp/pmg-mdm > ``` > [tab] Windows > > ```powershell theme={null} > & C:\Windows\Temp\pmg-mdm\pmg_uninstall_windows.ps1 > ``` **3. Assign and run** Assign the Command to the same device group and run it. Do not run the install and uninstall Commands on the same devices at the same time. ## Run cloud sync only Create another Command to repeat cloud sync without installing or configuring PMG again. Set it up the same way as the install Command, with the same shared library and script and `root` on macOS/Linux or `SYSTEM` on Windows. Use this Command body: > [tab] macOS > > ```sh theme={null} > #!/bin/sh > set -eu > cd /tmp/pmg-mdm > chmod +x pmg_setup_install_macos.sh > SAFEDEP_API_KEY={{safedep_api_key}} SAFEDEP_TENANT_ID={{safedep_tenant_id}} ./pmg_setup_install_macos.sh --cloud-sync-only > cd / && rm -rf /tmp/pmg-mdm > ``` > [tab] Linux > > ```sh theme={null} > #!/bin/sh > set -eu > cd /tmp/pmg-mdm > chmod +x pmg_setup_install_linux.sh > SAFEDEP_API_KEY={{safedep_api_key}} SAFEDEP_TENANT_ID={{safedep_tenant_id}} ./pmg_setup_install_linux.sh --cloud-sync-only > cd / && rm -rf /tmp/pmg-mdm > ``` > [tab] Windows > > ```powershell theme={null} > $env:SAFEDEP_API_KEY = '{{safedep_api_key}}' > $env:SAFEDEP_TENANT_ID = '{{safedep_tenant_id}}' > & C:\Windows\Temp\pmg-mdm\pmg_setup_install_windows.ps1 --cloud-sync-only > ``` > > Only logged-on users are synced. This mode does not save credentials in Credential Manager. Rerun the normal installer to store them after users sign in. Assign it to the same device group on a recurring schedule. Use it only for users who already have PMG and cloud sync enabled. Run the normal install Command to configure new users. ## Manage settings from the cloud policy With the [cloud policy](/package-security/pmg/cloud-policy), your security admin changes the package rules and the dependency cooldown of PMG in SafeDep Cloud, with no new MDM package. To use it on the fleet, change the managed `config.yml` that you ship with the scripts: 1. Set `cloud.enabled: true` and `cloud.policy: true`. 2. Keep `dependency_cooldown.enabled` and `dependency_cooldown.days` out of the file. Under `global_lockdown: true`, PMG keeps the value of each key that the managed file sets, and the cloud policy cannot change it. PMG reports the field as locked, and `safedep endpoint policy show` shows the exception. ```yaml config.yml theme={null} global_lockdown: true cloud: enabled: true policy: true # No dependency_cooldown keys: the cloud policy sets the cooldown. ``` Users cannot change the managed config. To turn off all cloud content on the fleet, ship `cloud.policy: false`. The cloud policy needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). > [card] [Other MDMs](/package-security/pmg/mdm/overview) > > Jamf, Intune, and the script layout. > [card] [MDM scripts README](https://github.com/safedep/pmg/blob/main/scripts/mdm/README.md) > > Source of truth in the PMG repo. # Deploy PMG with MDM Source: https://docs.safedep.io/package-security/pmg/mdm/overview Install PMG on macOS, Linux, and Windows fleets through Jamf, JumpCloud, Intune, or another MDM. Install or remove PMG on macOS, Linux, and Windows fleets through your MDM. On macOS and Linux, the scripts install the binary machine-wide and configure each local user. On Windows, they run `pmg setup install --system` once to put administrator-owned shims first on the machine `PATH`. > [!NOTE] > > The [MDM scripts README](https://github.com/safedep/pmg/blob/main/scripts/mdm/README.md) in the PMG repo is the source of truth. Scripts and supported MDMs are updated there first. Run the scripts as root on macOS and Linux, or as SYSTEM or an administrator on Windows. For a single machine or golden image with no MDM agent, such as a shared VM, CI runner, or Docker image, use [system install](/package-security/pmg/system-install) instead. PMG blocks packages without Cloud credentials. MDM deploys can also sync data to [SafeDep Cloud](/governance/cloud/quickstart). With Cloud credentials configured, the install script attempts `pmg cloud sync` after setup. On Windows, this runs for logged-on users only. A successful sync adds the device to [Endpoint Hub](/governance/cloud/endpoint-hub/overview) without waiting for a package manager event. Cloud sync from an MDM fleet needs the SafeDep Cloud Enterprise plan. See [pricing](https://safedep.io/pricing). To use Cloud sync, you need an API key and Tenant ID from [app.safedep.io/settings/api-keys](https://app.safedep.io/settings/api-keys). To repeat the sync without installing or configuring PMG again, pass `--cloud-sync-only` to the install script. Use this option only for users who already have PMG and cloud sync enabled. Run the normal installer to configure new users. On Windows, run it after those users sign in to store their Cloud credentials. ## Supported MDMs Jamf, Mosyle, and Kandji use the [macOS scripts](https://github.com/safedep/pmg/tree/main/scripts/mdm/macos). [JumpCloud](/package-security/pmg/mdm/jumpcloud) and [Intune](/package-security/pmg/mdm/intune) also support Linux and Windows deployments. Use multi-file scripts when your MDM can ship sibling files, or standalone scripts when it accepts one script per policy. ## Scripts * **Multi-file** (Jamf, JumpCloud, Intune Win32 apps): deploy the shared lib for your platform alongside the install or uninstall script. The entry scripts source the shared lib at runtime and fail without it. * **Standalone** (Intune): use a prebuilt installer, or generate one with managed config and optional Cloud credentials embedded, then upload that one script. Do not assign an install policy and an uninstall policy to the same devices at the same time. For managed config, ship `config.yml` beside the scripts or embed it with the standalone generator's `--config` option. Keep your other policy settings in the file. The installer replaces the managed config with the bundled file. On Windows, Cloud credentials must be accompanied by a config with `cloud.enabled: true`. This applies to runtime and embedded credentials. The system install always creates a managed config, which `pmg config set cloud.enabled true` cannot change. On macOS and Linux, the installer enables sync automatically when credentials are supplied and no managed config exists. If you supply a managed config, set `cloud.enabled: true` in it. For Windows standalone scripts with runtime credentials, keep `--config` and omit `--embed-cloud-credentials` when generating the installer. See [Globally Managed Configuration](https://github.com/safedep/pmg/blob/main/docs/config.md#globally-managed-configuration). > [!NOTE] > > A successful MDM install status does not confirm Cloud sync. If a Windows endpoint does not appear in Endpoint Hub, check `pmg config get cloud.enabled` and run `pmg cloud sync` in a logged-on user's session with credentials configured. Cloud login and sync failures do not fail the normal installer. Windows deployment requires PMG v0.29.0 or later. See the [MDM scripts README](https://github.com/safedep/pmg/blob/main/scripts/mdm/README.md) for platform requirements and cleanup limitations. The MDM scripts do not install a persistent MITM CA (`pmg setup cert install`). On macOS this needs interactive Keychain authorization, so it cannot run through MDM: have each user run it in their own session when needed. On Linux, PMG's ephemeral CA is usually enough. Run `pmg setup cert install --system` as your normal user only if a tool needs a persistent CA in the system trust store. Windows package managers use the injected ephemeral CA, except Go, which needs a user-run `pmg setup cert install`. ## Manage settings from the cloud policy With the [cloud policy](/package-security/pmg/cloud-policy), your security admin changes the package rules and the dependency cooldown of PMG in SafeDep Cloud, with no new MDM package. To use it on the fleet, change the managed `config.yml` that you ship with the scripts: 1. Set `cloud.enabled: true` and `cloud.policy: true`. 2. Keep `dependency_cooldown.enabled` and `dependency_cooldown.days` out of the file. Under `global_lockdown: true`, PMG keeps the value of each key that the managed file sets, and the cloud policy cannot change it. PMG reports the field as locked, and `safedep endpoint policy show` shows the exception. ```yaml config.yml theme={null} global_lockdown: true cloud: enabled: true policy: true # No dependency_cooldown keys: the cloud policy sets the cooldown. ``` Users cannot change the managed config. To turn off all cloud content on the fleet, ship `cloud.policy: false`. The cloud policy needs the SafeDep Cloud Team or Enterprise plan. See [pricing](https://safedep.io/pricing). ## Next steps > [card] [Jamf](/package-security/pmg/mdm/jamf) > > Multi-file scripts for macOS. Pass Cloud credentials as script parameters. > [card] [JumpCloud](/package-security/pmg/mdm/jumpcloud) > > Multi-file scripts for macOS, Linux, or Windows. > [card] [Intune](/package-security/pmg/mdm/intune) > > Standalone scripts for all three platforms, or a Windows Win32 app. # Limit the Hosts a Package Install Can Reach Source: https://docs.safedep.io/package-security/pmg/network-policy Allow a sandboxed package install to reach only the hosts it needs, and refuse every other destination. A malicious install script sends stolen data to a host that the attacker controls. A network policy lists the hosts that an install can reach. The PMG proxy checks each connection against the policy. Each built-in sandbox profile has a network policy. For example, the npm profile allows `registry.npmjs.org`, `registry.yarnpkg.com`, `npm.pkg.github.com`, and `github.com` on port 443, and denies every other destination. The policy has two modes: * `audit` (default): PMG records each destination that the policy denies, and lets the connection through. * `enforce`: PMG refuses each destination that the policy denies. > [!NOTE] > > Network policy needs PMG v0.33.0 or later, and the [sandbox](/package-security/pmg/sandbox) turned on. ## Build a policy from a run **1. Run the install in audit mode** ```bash theme={null} pmg npm install ``` When the policy denies a destination, the report starts with `Network policy would deny` and names each destination. The report also shows the run ID and the command to propose a profile. **2. Propose a profile** ```bash theme={null} pmg sandbox profile propose --last --new my-npm ``` PMG writes the user profile `my-npm`. It inherits the npm profile, allows each host that the run reached, and denies every other destination. Run the command without `--new` to see the proposal first. **3. Review the profile** ```bash theme={null} pmg sandbox profile edit my-npm ``` Remove each host that the install does not need. PMG checks the profile when you close the editor. **4. Use the profile for npm** ```bash theme={null} pmg config set sandbox.policies.npm.profile my-npm ``` **5. Turn on enforce mode** ```bash theme={null} pmg config set sandbox.network_mode enforce ``` The mode applies to every package manager. The built-in profiles of the other package managers also deny every host that they do not list. ## Fix a refused destination In enforce mode, the package manager gets an HTTP 403 error for a denied destination. The PMG report names the destination and the rule: ```text theme={null} ⊘ Network policy denied registry.example.com:443 rule *:* Allow it with pmg sandbox allow net-connect=registry.example.com:443. ``` To allow the destination for one run, use `--sandbox-allow`: ```bash theme={null} pmg --sandbox-allow net-connect=registry.example.com:443 npm install ``` To keep the allowance for this repository, use `pmg sandbox allow`: ```bash theme={null} pmg sandbox allow net-connect=registry.example.com:443 ``` ## Refuse connections that skip the proxy The policy applies to the connections that go through the PMG proxy. A script that ignores the proxy variables can connect directly. To refuse direct connections, set `network_via_proxy_only: true` in the profile. Landlock and Seatbelt support this setting. Bubblewrap refuses a profile with this setting. On a Linux host or a CI runner, [kernel enforcement](/package-security/pmg/kernel-enforcement) routes every process through the proxy. ## With SafeDep Cloud The network policy is free in PMG. With SafeDep Cloud, you see the destinations that the policy refused on every endpoint. PMG records each destination that the policy refuses, or in audit mode would refuse. This query lists them: ```sql theme={null} SELECT endpoints.identifier, package_guard_events.hostname, package_guard_events.timestamp FROM package_guard_events JOIN endpoints ON endpoints.id = package_guard_events.invocation_id WHERE package_guard_events.event_type = 'PMG_EVENT_TYPE_NETWORK_POLICY_DECISION' ORDER BY package_guard_events.timestamp DESC ``` Use the result to find a host that the policy must allow, or a package that tried to reach an unknown host. > [!NOTE] > > This section needs the SafeDep Cloud Team or Enterprise plan, with PMG [connected to your tenant](/governance/cloud/endpoint-hub/package-guard). See [pricing](https://safedep.io/pricing). ## Next steps For the rule syntax, IP literal rules, and how the proxy matches a host, see [Network rules](https://github.com/safedep/pmg/blob/main/docs/sandbox.md#network-rules) in the PMG repository. > [card] [Allow Only Known Hosts in GitHub Actions](/package-security/pmg/github-actions-network-policy) > > Apply a network policy to a CI job. > [card] [Sandbox Your AI Coding Agent](/ai-security/sandbox-coding-agents) > > Limit the hosts that a coding agent can reach. # PMG Source: https://docs.safedep.io/package-security/pmg/overview PMG wraps your package managers and blocks malicious packages at install time, before any code runs. Free, open source, no account required. [PMG](https://github.com/safedep/pmg) (Package Manager Guard) blocks malicious packages at install time. It wraps the package managers you already use, so every `npm install` or `pip install` is checked against SafeDep's malware intelligence before any code runs. It is free, open source, and needs no account or API key. PMG runs on macOS, Linux, and Windows. Native Windows interception uses `.cmd` PATH shims in PowerShell and `cmd.exe`. Windows has no sandbox or background proxy daemon. See the [Windows setup guidance](/package-security/pmg/quickstart#windows). ## What PMG does * **Blocks before code runs:** catches malicious packages at install time, not after they are already in your environment. * **No workflow change:** wraps your existing package managers. You and your AI coding agents run the same commands. * **Deep dependency analysis:** resolves and checks the full transitive dependency tree, not just the package you asked for. * **No account needed:** uses SafeDep's free community API. Apache 2.0 licensed, no signup or API key. ## How it works PMG intercepts each install command, resolves the dependency tree, and checks every package against SafeDep's [malicious package intelligence](/concepts/malicious-package) before allowing the install to proceed. Known malicious packages are blocked outright. A [dependency cooldown](/package-security/pmg/dependency-cooldown), on by default, also skips package versions published inside a recent time window, when a freshly compromised release is most likely to slip through. It supports `npm`, `pnpm`, `yarn`, `bun`, `aube`, `npx`, `pnpx`, `aubx`, `aubr`, `pip`, `pipx`, `poetry`, `uv`, and `uvx`. Support for `go` and `cargo` is experimental. For dependency-resolution internals and CLI flags, see the [PMG repository](https://github.com/safedep/pmg). On macOS and Linux, PMG can also run each install in a [sandbox](/package-security/pmg/sandbox) that blocks credential reads, and apply a [network policy](/package-security/pmg/network-policy) that limits the hosts an install can reach. On a CI runner or a shared Linux host, PMG can also run as one persistent proxy that every package manager uses. With [kernel enforcement](/package-security/pmg/kernel-enforcement), the Linux kernel routes every process through that proxy, and a process cannot opt out. The containers that the host starts can be routed too. > [!NOTE] > > Connect PMG to [SafeDep Cloud](/governance/cloud/overview) and the installs it checks sync to [Endpoint Hub](/governance/cloud/endpoint-hub/overview) as Package Guard events, a timeline of package activity across your team's endpoints. Local blocking works the same with or without an account. ## Get started > [card] [PMG Quickstart](/package-security/pmg/quickstart) > > Install PMG and protect your package managers in minutes. > [card] [Stop Install Scripts from Reading Your Secrets](/package-security/pmg/sandbox) > > Run package installs in the PMG sandbox. > [card] [Limit the Hosts a Package Install Can Reach](/package-security/pmg/network-policy) > > Allow an install to reach only the hosts it needs. > [card] [Hold Back Newly Published Package Versions](/package-security/pmg/dependency-cooldown) > > Set the dependency cooldown window and exempt packages. > [card] [Use PMG with a Private Registry or Mirror](/package-security/pmg/private-registries) > > Check packages from an internal registry. > [card] [PMG in GitHub Actions](/package-security/pmg/github-actions) > > Block malicious packages in CI and limit the hosts a job can reach. > [card] [Sandbox Your AI Coding Agent](/ai-security/sandbox-coding-agents) > > Run Claude Code, Codex, or Pi in the PMG sandbox. > [card] [Deploy on Kubernetes](/package-security/pmg/kubernetes) > > Protect package installs in Kubernetes workloads and group events by workload. > [card] [Kernel Enforcement on Linux](/package-security/pmg/kernel-enforcement) > > Make the kernel route every process and container on a Linux host through PMG. > [card] [Deploy with MDM](/package-security/pmg/mdm/overview) > > Install PMG on macOS, Linux, and Windows fleets through your MDM. > [card] [Malicious Package](/concepts/malicious-package) > > How SafeDep detects malicious packages across registries. > [card] [PMG on GitHub](https://github.com/safedep/pmg) > > Source, full documentation, and CI usage. > [card] [Alert on PMG blocks](/governance/cloud/alerts) > > Stream malicious and cooldown blocks from SafeDep Cloud to Slack or any webhook. # Use PMG with a Private Registry or Mirror Source: https://docs.safedep.io/package-security/pmg/private-registries Make PMG check packages that come from an internal npm, PyPI, Go, or Cargo registry or mirror, such as Artifactory or Nexus. PMG checks packages from the public registries, such as `registry.npmjs.org` and `pypi.org`. When your package manager uses an internal mirror or a registry proxy, such as Artifactory, Nexus, or Athens, add the registry to the PMG config. PMG then checks each package that comes from it. PMG checks public packages. A private package that is not in the SafeDep malware database passes the check. ## Add the registry **1. Find the registry URL your package manager uses** ```bash theme={null} npm config get registry npm config get @myscope:registry pip config debug ``` Run `npm config get` for each scope that you use. For Go, use the `GOPROXY` URL. For Cargo, read the `[registries]` and `[source]` tables of `.cargo/config.toml`. **2. Add the registry to the PMG config** Open the config file with `pmg config edit` and add an entry under `proxy.registries`: ```yaml theme={null} proxy: registries: - name: npm-mirror ecosystem: npm endpoints: - url: https://packages.example.com/artifactory/api/npm/npm-virtual - name: pypi-mirror ecosystem: pypi endpoints: - url: https://packages.example.com/artifactory/api/pypi/python/simple ``` The `ecosystem` is `npm`, `pypi`, `go`, or `cargo`. For PyPI, use a URL that ends in `/simple`. If the registry serves files from a second host, add that URL as a second endpoint. **3. Check the config** ```bash theme={null} pmg setup doctor ``` The `Custom registries` row shows the number of endpoints. When an entry is not valid, the row fails, and PMG refuses to run installs until you fix it. **4. Install a package from the registry** ```bash theme={null} pmg npm install express ``` The report shows `PMG: N packages analyzed`. Do not put credentials in the PMG config. Keep them where your package manager reads them, such as `.npmrc` or the pip config. PMG does not store them. ## Next steps For how PMG matches a request, the requirements for each registry type, and troubleshooting, see [Custom Registries](https://github.com/safedep/pmg/blob/main/docs/proxy-mode.md#custom-registries) in the PMG repository. > [card] [Hold Back Newly Published Package Versions](/package-security/pmg/dependency-cooldown) > > Set the dependency cooldown window. > [card] [Limit the Hosts a Package Install Can Reach](/package-security/pmg/network-policy) > > Allow an install to reach only your registry. # PMG Quickstart Source: https://docs.safedep.io/package-security/pmg/quickstart Install and configure PMG (Package Manager Guard) to block malicious packages at install time. > [card] [PMG Repository](https://github.com/safedep/pmg) > > View the PMG source code and contribute on GitHub **Package Manager Guard (PMG)** wraps your package manager and blocks malicious packages at install time. > [!NOTE] > > PMG requires **no configuration** - just install and use it as you normally > would with your package managers. For what PMG is and how it works, see the [PMG overview](/package-security/pmg/overview). ## Installation ### Using Homebrew (macOS and Linux) ```bash theme={null} brew install safedep/tap/pmg ``` ### Using Go Install ```bash theme={null} go install github.com/safedep/pmg@latest ``` ### Download Binary Download the latest release from our [GitHub releases page](https://github.com/safedep/pmg/releases) and add it to your PATH. ### Windows Use Windows 10 or 11. Download `pmg_Windows_x86_64.zip` from a [v0.29.0 or later release](https://github.com/safedep/pmg/releases/latest), extract `pmg.exe`, and add its directory to your PATH. The release is x86-64 only. ARM64 runs it under emulation. 32-bit Windows is not supported. Windows support requires PMG v0.29.0 or later. For Node.js installed by its MSI, winget, or Chocolatey, use the [Windows system install](/package-security/pmg/system-install#windows-machines). These installers put Node on the machine PATH, ahead of every per-user shim. Until system install is complete, invoke `pmg npm` explicitly. ## Quick Setup ### Automated Setup (Recommended) Run PMG's automated setup: ```sh theme={null} pmg setup install ``` > [tab] macOS and Linux > > Setup creates package-manager PATH shims and the `~/.pmg.rc` alias layer for bash, zsh, and fish. Restart your terminal or source your shell's config file to activate it. > [tab] Windows > > Setup creates `.cmd` shims in `%LOCALAPPDATA%\safedep\pmg\bin` and prepends that directory to your user PATH. It does not create aliases or PowerShell profile functions. Open a new PowerShell or `cmd.exe` terminal. > > ```powershell theme={null} > Get-Command npm > pmg setup doctor > ``` > > `npm` should resolve under the shim directory. If the real manager appears first, follow the diagnostic and use [system install](/package-security/pmg/system-install#windows-machines) for machine-wide toolchains. Verify protection with the benign test package. PMG must block it: ```sh theme={null} npm install --no-cache --prefer-online safedep-test-pkg@0.1.3 ``` ### Manual Usage (Alternative) To invoke PMG explicitly: ```bash theme={null} pmg npm install pmg pnpm add pmg pip install ``` If PMG detects a malicious package, it blocks the install and displays a warning. ## Supported Package Managers PMG supports these tools from the [PMG README](https://github.com/safedep/pmg#supported-package-managers): | Package Manager | Status | Command | | - | - | - | | `npm` | Active | `pmg npm install ` | | `pnpm` | Active | `pmg pnpm add ` | | `yarn` | Active | `pmg yarn add ` | | `bun` | Active | `pmg bun add ` | | `aube` | Active | `pmg aube add ` | | `npx` | Active | `pmg npx ` | | `pnpx` | Active | `pmg pnpx ` | | `aubx` | Active | `pmg aubx ` | | `aubr` | Active | `pmg aubr