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 frominput.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.
How checks work
Formal addsinput.integrations.socket to the request stage of every HTTP request. That includes requests on the Formal Endpoint and requests a Connector receives.
- Request fields:
urlis 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.
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 likeaction 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:
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
Connect fails with "invalid Socket API token"
Connect fails with "invalid Socket API token"
Cause: Socket rejected the token.Fix: Check that you copied the whole token and that it has not been revoked.
Connect fails with "cannot query Socket's firewall"
Connect fails with "cannot query Socket's firewall"
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.Connect fails with "must belong to exactly one organization"
Connect fails with "must belong to exactly one organization"
Cause: The token is a personal token with access to several Socket organizations.Fix: Create an organization API token instead.
status_code is 401 or 403 in policy input
status_code is 401 or 403 in policy input
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