You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 90d2a40
Browse filesBrowse the repository at this point in the historyBrowse files
docs: List the API token scopes Socket Basics needs (#140)
* docs: List the API token scopes Socket Basics needs
The docs named the scopes `full-scans` and `socket-basics`, which are not
scope names; the API checks `full-scans:create` and `socket-basics:read`.
They also left out that Socket Tier 1 needs `full-scans:create`, and that a
missing scope never fails the run.
- Add an API token scopes section to the parameters reference: a
least-privilege scope table, then every Socket API call by step (dashboard
configuration, result upload, Socket Tier 1) with the scope it checks, when
it is called and how a denial shows up in the log
- Note that on an Enterprise organization a key without
`socket-basics:read` also loses organization discovery, so `SOCKET_ORG`
must be set for the upload
- Note which token variables each step reads, and that the Socket npm CLI
prefers its own variables over the one Tier 1 passes
- Correct the scope names in the README, the GitHub Action guide and the
Docker guide, and link them to the new section
* docs: Correct org discovery, the engine-download scope and the scope names
- The organization is discovered from the key without socket-basics:read
on non-Enterprise plans, where the settings call is never made. Four
places said discovery always needs the scope.
- POST coana-cli/artifacts checks full-scans:create or fixes:list in its
handler; it was listed as needing no scope.
- A denied settings call logs one warning, "Error loading Socket Basics
config: Insufficient permissions", not a separate line before it.
- full-scans and socket-basics are the scope groups, which also work.
socket-basics:read is the only scope in its group, so the API reports
it as socket-basics.
- The setup-guide paragraph no longer states which scopes that guide
lists, since the list is changing.
* chore(deps): Lock the Socket Python SDK at 3.6.3
socketdev 3.6.3 fixes settings.integration_events(), which Socket
Basics does not call. The lockfile moves so the image runs the current
SDK. The >=3.6.2 floor stays, because the bundled Socket Python CLI
pins 3.6.2 exactly and installs on the same system interpreter.
* chore(deps): Bundle Socket Python CLI 2.13.1 in the heavy image
The heavy and app-tests images move the bundled Socket Python CLI from
2.12.0 to 2.13.1. That release pins socketdev 3.6.3 exactly, so the
source-install floor moves to >=3.6.3 with it.
The changelog carries the upgrade notes that reach heavy-image users:
2.13.0 changed the CLI's exit codes and made --strict-blocking fail on
existing blocking alerts. Socket Basics does not run socketcli itself.
The bundled CLI also pins the Coana engine 15.15.2, while Socket Tier 1
still runs 15.15.0 through the npm CLI.
Configure scanning policies, notification channels, and rule sets for your entire organization in one place. Socket Basics loads these settings on every run when its API key has the `socket-basics` scope, and they take precedence over the matching workflow inputs, including fields you leave blank. See [Dashboard Settings and Workflow Inputs](docs/github-action.md#dashboard-settings-and-workflow-inputs) for the exceptions and for setting values per repository.
157
+
Configure scanning policies, notification channels, and rule sets for your entire organization in one place. Socket Basics loads these settings on every run when its API key has the `socket-basics:read` scope, and they take precedence over the matching workflow inputs, including fields you leave blank. See [Dashboard Settings and Workflow Inputs](docs/github-action.md#dashboard-settings-and-workflow-inputs) for the exceptions and for setting values per repository.
@@ -164,12 +164,16 @@ Create your `SOCKET_SECURITY_API_KEY` in the [Socket Dashboard](https://socket.d
164
164
165
165
| Scope | Required for |
166
166
|-------|--------------|
167
-
| `full-scans` | Submitting scan results to your organization |
168
-
| `socket-basics` | Loading scanner configuration from the Socket Dashboard |
167
+
| `full-scans:create` | Submitting scan results to your organization, and running Socket Tier 1 reachability |
168
+
| `socket-basics:read` | Loading scanner configuration from the Socket Dashboard (Enterprise organizations) |
169
169
170
-
If Socket Basics is configured from the Socket Dashboard, the `socket-basics` scope is required. If it is missing, you will see `Insufficient permissions` when Socket Basics loads dashboard configuration.
170
+
If Socket Basics is configured from the Socket Dashboard, `socket-basics:read` is required. If it is missing, the log shows `Error loading Socket Basics config: Insufficient permissions`, and the scan runs with the workflow inputs alone. On an Enterprise organization the organization is then not discovered from the key either, so results are not uploaded unless `SOCKET_ORG` is set.
171
171
172
-
If Socket Basics is configured with CLI arguments, environment variables, or a JSON config file, only `full-scans` permissions are required for result submission. Set `SOCKET_ORG` explicitly in your workflow when using this mode.
172
+
Each scope sits in a group named by its prefix, and granting the group also works: `full-scans`includes `full-scans:create`, and `socket-basics` contains only `socket-basics:read`.
173
+
174
+
If Socket Basics is configured with CLI arguments, environment variables, or a JSON config file, only `full-scans:create` is required. Set `SOCKET_ORG` explicitly in your workflow when using this mode.
175
+
176
+
A missing scope does not change the exit code. See [API token scopes](docs/parameters.md#api-token-scopes) for every Socket API call Socket Basics makes and the scope each one checks.
173
177
174
178
## 💻 Other Usage Methods
175
179
@@ -270,7 +274,7 @@ Add new connectors by:
270
274
271
275
**Socket API errors / results missing from the dashboard:**
272
276
- Ensure `SOCKET_SECURITY_API_KEY` and `SOCKET_ORG` are set correctly
273
-
- `No Socket organization configured` in the log means nothing was uploaded: set `SOCKET_ORG`, or use a key with the `socket-basics` scope so the organization can be discovered
277
+
- `No Socket organization configured` in the log means nothing was uploaded: set `SOCKET_ORG`. The organization is normally discovered from the key, but on an Enterprise organization that also needs the `socket-basics:read` scope
274
278
- `Need at least one file to be uploaded`means the facts file was written outside the scanned workspace; keep `--output` inside it (see [Save Results to File](docs/local-install-docker.md#save-results-to-file))
275
279
- Verify your Socket Enterprise subscription is active
276
280
- If you see `Insufficient permissions`, confirm your API token has the scopes required for your configuration mode (see [Required API Token Scopes](#required-api-token-scopes))
Copy file name to clipboardExpand all lines: docs/parameters.md
+114-5Lines changed: 114 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ GitHub Action input is delivered to the container as the environment variable
37
37
|`--console-tabular-enabled`|`console_tabular_enabled`|`INPUT_CONSOLE_TABULAR_ENABLED`|`console_tabular_enabled`| Print consolidated findings as tables. |
38
38
|`--console-json-enabled`|`console_json_enabled`|`INPUT_CONSOLE_JSON_ENABLED`|`console_json_enabled`| Print consolidated findings as JSON. |
39
39
|`--socket-org`|`socket_org`|`SOCKET_ORG` (also `SOCKET_ORG_SLUG`, `INPUT_SOCKET_ORG`) |`socket_org`| Socket organization slug. Not the same thing as `--repo`. |
40
-
| —<sup>2</sup> |`socket_security_api_key`|`SOCKET_SECURITY_API_KEY` (also `SOCKET_SECURITY_API_TOKEN`, `SOCKET_API_KEY`, `INPUT_SOCKET_SECURITY_API_KEY`) |`socket_api_key`<sup>3</sup> | Socket API key (`full-scans` scope to upload, `socket-basics` scope to load dashboard config). |
40
+
| —<sup>2</sup> |`socket_security_api_key`|`SOCKET_SECURITY_API_KEY` (also `SOCKET_SECURITY_API_TOKEN`, `SOCKET_API_KEY`, `INPUT_SOCKET_SECURITY_API_KEY`) |`socket_api_key`<sup>3</sup> | Socket API key (`full-scans:create` scope to upload, `socket-basics:read` scope to load dashboard config; see [API token scopes](#api-token-scopes)). |
41
41
|`--repo`| — |`GITHUB_REPOSITORY`|`repo`|`owner/repo` recorded on the scan and used to find the PR. Discovered from git when omitted. |
42
42
|`--branch`| — |`GITHUB_HEAD_REF`, `GITHUB_REF_NAME`|`branch`| Branch recorded on the scan. Discovered from git when omitted. |
43
43
|`--pull-request`| — |`GITHUB_PR_NUMBER` (also `INPUT_PR_NUMBER`) | — | PR number. The PR notifier reads the environment variable. |
The key needs the `full-scans` scope to upload results and the `socket-basics`
705
-
scope to load dashboard configuration. With the latter the organization is
706
-
discovered from the key; otherwise set `SOCKET_ORG` explicitly or the run logs
704
+
The key needs `full-scans:create` to upload results and `socket-basics:read`
705
+
to load dashboard configuration; see [API token scopes](#api-token-scopes).
706
+
When `SOCKET_ORG` is not set, the organization is discovered from the key. On
707
+
an Enterprise organization that discovery is lost if the key lacks
708
+
`socket-basics:read`, so set `SOCKET_ORG` explicitly or the run logs
707
709
`No Socket organization configured`and uploads nothing. `--repo` names the
708
710
repository, not the organization.
709
711
712
+
### API token scopes
713
+
714
+
Socket Basics authenticates with a single Socket organization API token. A
715
+
token missing a scope does **not** fail the run. Each Socket API call that is
716
+
denied logs an error or a warning and the scan continues, so check the log
717
+
rather than the exit code.
718
+
719
+
#### Scopes to grant
720
+
721
+
For a least-privilege token, grant these:
722
+
723
+
| Scope | Needed for |
724
+
|:---|:---|
725
+
| `full-scans:create` | Uploading results to the Socket dashboard. Socket Tier 1 also needs it to upload manifests and record the reachability scan |
726
+
| `socket-basics:read` | Loading scanner configuration from the Socket dashboard, on Enterprise organizations. Without it on an Enterprise organization, the organization is also not discovered from the key |
727
+
728
+
Scopes are grouped by their prefix, and granting a group grants every scope in
729
+
it. The `full-scans` group covers `full-scans:create`, `full-scans:list` and
730
+
`full-scans:delete`, so it works here but holds more than Socket Basics uses.
731
+
`socket-basics:read`is the only scope in the `socket-basics` group, so
732
+
selecting either one is the same token: the dashboard shows both checked, and
733
+
the API reports the scope as `socket-basics`.
734
+
735
+
The scopes each endpoint checks are listed in the
736
+
[API reference](https://docs.socket.dev/reference). A few calls check no scope
737
+
and work with any valid token for the organization: `GET organizations`and
738
+
`GET orgs/{org}/supported-files`.
739
+
740
+
Socket Basics does not use the `repo:*`, `full-scans:list`, `diff-scans:*`,
741
+
`packages:list`, `security-policy:read` or `triage:*` scopes. It never looks up
742
+
or creates the repository with a separate call. The repository name travels as
743
+
a parameter of the scan upload.
744
+
745
+
The [CI/CD token setup guide](https://docs.socket.dev/docs/create-socket-api-key-for-cicd)
746
+
lists scopes for several Socket tools. Socket Basics needs only the two above.
747
+
A token created for the Socket CLIs can upload results if it has
748
+
`full-scans:create`. Check that it also has `socket-basics:read` before relying
749
+
on dashboard configuration.
750
+
751
+
#### API calls by run type
752
+
753
+
**Dashboard configuration**, at startup on every run where the key is set and
754
+
no `--config` file is given:
755
+
756
+
| API call | Scope | Purpose |
757
+
|:---|:---|:---|
758
+
| `GET organizations` | none | Find the organization (the one named by `SOCKET_ORG`, or the first one the key belongs to) and its plan |
759
+
| `GET orgs/{org}/settings/socket-basics` | `socket-basics:read` | Load the dashboard configuration. **Only called when the plan is Enterprise** |
760
+
761
+
This step reads the key from `SOCKET_SECURITY_API_KEY`,
762
+
`SOCKET_SECURITY_API_TOKEN`or `INPUT_SOCKET_SECURITY_API_KEY` only. A key set
763
+
only as `SOCKET_API_KEY` or `INPUT_SOCKET_API_KEY` is used for uploads and
764
+
Tier 1 but skips this step.
765
+
766
+
If either call fails, the log shows one warning,
767
+
`Error loading Socket Basics config: ...`, and the run continues with the
768
+
environment and workflow inputs alone. When the settings call is denied for a
769
+
missing scope, that warning reads
770
+
`Error loading Socket Basics config: Insufficient permissions`, followed by the
771
+
request path. Nothing from this step is kept, including the discovered
772
+
organization, so on an Enterprise organization set `SOCKET_ORG` when the key
773
+
lacks `socket-basics:read`. On other plans the settings call is never made, and
774
+
the organization is discovered without that scope.
775
+
776
+
**Result upload**, after the scanners finish:
777
+
778
+
| API call | Scope | Purpose |
779
+
|:---|:---|:---|
780
+
| `POST orgs/{org}/full-scans` | `full-scans:create` | Upload `.socket.facts.json` as a full scan |
781
+
782
+
The upload is skipped, without calling the API, when the facts file has no
783
+
components, when no key or organization is configured, or when
784
+
`SKIP_SOCKET_SUBMISSION=1`. If the repository does not exist in Socket yet, the
785
+
upload creates it, and an organization API token needs no scope beyond
786
+
`full-scans:create`for that. A denied upload logs
787
+
`Failed to submit socket facts file`and does not change the exit code.
| `POST orgs/{org}/coana-cli/artifacts` | `full-scans:create` or `fixes:list` | Find the reachability engine download. Only called when the engine is not cached, which is every run in a fresh container (see [Network access for Tier 1](#network-access-for-tier-1)) |
798
+
| `POST orgs/{org}/upload-manifest-files` | `full-scans:create` | Upload the manifests for analysis |
799
+
| `POST tier1-reachability-scan/finalize` | `full-scans:create` | Mark the reachability scan done. A failure here only logs a warning |
800
+
801
+
The reachability engine (Coana) runs with the same token, and its calls check
802
+
`full-scans:create`. The `coana-cli/artifacts`, `upload-manifest-files` and
803
+
`tier1-reachability-scan/finalize`endpoints are not in the public API
804
+
reference. Options passed through
805
+
`socket_additional_params`can make further calls that this table does not
806
+
cover.
807
+
808
+
A Tier 1 failure logs `Error running connector socket_tier1` and does not
809
+
change the exit code. Tier 1 passes the key to the Socket npm CLI as
810
+
`SOCKET_SECURITY_API_KEY`, but that CLI prefers `SOCKET_CLI_API_TOKEN`,
811
+
`SOCKET_CLI_API_KEY`or `SOCKET_SECURITY_API_TOKEN` when one of them is set in
812
+
the environment. If you set more than one of these, give them the same token.
813
+
814
+
The heavy image's Python CLI (`socketcli`) is a separate tool that Socket
Enable Socket Tier 1 reachability analysis for dependency scanning.
712
821
@@ -1021,7 +1130,7 @@ Configuration is merged in the following order (later sources override earlier o
1021
1130
1022
1131
1. Default values
1023
1132
2. Environment variables, including GitHub Action inputs (the action passes each `with:` input as an `INPUT_*` variable)
1024
-
3. Socket Basics dashboard configuration (when the organization is on an Enterprise plan with Socket Basics enabled, the API key has the `socket-basics` scope, and no `--config` file is used)
1133
+
3. Socket Basics dashboard configuration (when the organization is on an Enterprise plan with Socket Basics enabled, the API key has the `socket-basics:read` scope, and no `--config` file is used)
0 commit comments