Skip to main content

Overview

Formal’s Socket integration lets check package downloads against Socket (supply chain security for open source packages). You connect your own Socket organization. Checks run on your Socket plan and quota. Policies read Socket’s verdict from input.integrations.socket. The Formal Endpoint and the evaluate these policies locally.

Connect Socket

1

Create a Socket organization API token

A Socket owner or admin creates an organization API token in Socket settings (organization API tokens). Give it the packages:list scope.
2

Connect the token in Formal

Go to Socket under Controls. Paste the token and click Connect Socket.Formal checks the token before it saves it. The token must belong to exactly one Socket organization. Formal then runs one Socket check on a public npm package to confirm the token can use Socket’s firewall.Verify: the page shows your Socket organization name, its ID, and when it was connected.
Formal never shows the token again. Each Formal organization connects one Socket organization. To change the token, click Disconnect and connect again.

How checks work

Formal adds input.integrations.socket to the request stage of every HTTP request. That includes requests on the Formal Endpoint and requests a Connector receives.
  • Request fields: url is always set. It is not determined via Socket’s API and does not make a network request.
  • Verdict fields: the rest are fetched only when a policy reads one of them. Formal then makes one Socket check for that request, however many fields the policy reads.
Always check input.http.package_registry or input.http.hostname (such as input.http.hostname == "registry.npmjs.org") before reading a Socket verdict. Otherwise Formal sends every HTTP request to Socket, and each check counts against your Socket organization’s quota.

Policy input

input.integrations.socket is available in the request stage of HTTP requests. The verdict fields (purl, status, action, reason and alerts) use Socket’s own names and values. They are set only when Socket answered with a 2xx status. A non-2xx answer, such as 429 when the Socket quota runs out, sets only status_code.

Alert object

Error object

Handle failed checks

A Socket check can fail, for example when Socket is down, your quota runs out or the token is revoked. Verdict fields like action are unset when it does. By default, a rule that matches on action doesn’t match a failed check, so Formal allows the download (fail open). To block downloads Socket couldn’t check instead (fail closed), add a rule that blocks when status is unset:
To act on one kind of failure, match status_code (for example == 429) or error.type. This rule only covers failed checks. Socket still answers not_scanned or not_identified for packages it has no verdict for, and status is set. To block those too, match input.integrations.socket.status != "scanned". See Block malicious package downloads for a complete setup.

Troubleshooting

Cause: Socket rejected the token.Fix: Check that you copied the whole token and that it has not been revoked.
Cause: The token is valid but lacks the packages:list scope. The error includes Socket’s status and response.Fix: Create a token with packages:list and connect again.
Cause: The token is a personal token with access to several Socket organizations.Fix: Create an organization API token instead.
Cause: The token was revoked, or its scope or plan changed after you connected it.Fix: Disconnect Socket and connect a new token.

Next Steps

Block malicious packages

Intercept package registries and block flagged packages

Network rules

Match package registry traffic on the Formal Endpoint