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.
Network policy needs PMG v0.33.0 or later, and the sandbox turned on.
Build a policy from a run
1
Run the install in audit mode
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
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
4
Use the profile for npm
5
Turn on enforce mode
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:--sandbox-allow:
pmg sandbox allow:
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, setnetwork_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 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:This section needs the SafeDep Cloud Team or Enterprise plan, with PMG connected to your tenant. See pricing.
Next steps
For the rule syntax, IP literal rules, and how the proxy matches a host, see Network rules in the PMG repository.Allow Only Known Hosts in GitHub Actions
Apply a network policy to a CI job.
Sandbox Your AI Coding Agent
Limit the hosts that a coding agent can reach.

