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
Copy file name to clipboardExpand all lines: docs/github-action.md
+40-2Lines changed: 40 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -311,8 +311,9 @@ jobs:
311
311
312
312
`changed_files` accepts:
313
313
314
-
- `auto`— diff against the PR base branch in CI (`GITHUB_BASE_REF`), else staged changes
315
-
- `pr`— diff against the PR base branch (`GITHUB_BASE_REF`)
314
+
- `auto`— the PR base diff when a pull request base can be found, else staged changes
315
+
- `pr`— the PR base diff, and nothing else
316
+
- `current-commit`— files in the `HEAD` commit
316
317
- a commit hash — files changed in that commit
317
318
- a comma-separated file list — e.g. `src/app.py,src/utils.js`
318
319
@@ -322,6 +323,43 @@ jobs:
322
323
> nothing rather than falling back to the whole repo. To scan an explicit file
323
324
> list regardless of git state, use the `scan_files` input instead.
324
325
326
+
### Checking that the scope took effect
327
+
328
+
Diff-only mode logs what it did. Look for these lines in the step output:
329
+
330
+
```text
331
+
INFO Resolved PR diff base to 'origin/main'
332
+
INFO Diff-only scan scoping requested (changed_files=auto): resolved 12 changed file(s)
333
+
INFO Diff-only scan scoping active: 12 scan target(s) from 12 changed file(s)
334
+
```
335
+
336
+
If the scope could not be applied, the run says why instead of quietly scanning
337
+
everything or nothing:
338
+
339
+
| Warning you will see | What to do |
340
+
|----------------------|------------|
341
+
| `none of the candidate PR bases (...) could be resolved ... The checkout is shallow` | Add `fetch-depth: 0` to `actions/checkout` |
342
+
| `no pull request base was found` | The trigger is not `pull_request`, so there is no base. Use `changed_files: 'current-commit'` or an explicit file list |
343
+
| `is not a git repository` | Run `actions/checkout` before the scan step |
344
+
| `git refused to read ... not the usual container ownership mismatch` | The checkout is damaged or incomplete. Re-run `actions/checkout`, or pass an explicit file list |
345
+
| `scan_all and a changed-files scope ... are both set, and they disagree` | Unset `scan_all` — it can come from a Socket dashboard config, not just your workflow |
346
+
| `resolved to zero files. The scanners will be SKIPPED` | The diff found nothing scannable. Combined with a warning above, it tells you the diff failed rather than the PR being empty |
347
+
348
+
You do not need `git config --global --add safe.directory` for this. The scan
349
+
runs as root inside a container over a workspace owned by the runner user, and
350
+
git normally refuses that with `detected dubious ownership`. When git refuses,
351
+
the scan trusts that one workspace directory so the diff can run, and logs that
352
+
it did — so no workflow change is needed. Setting `safe.directory` in a workflow
353
+
step would not have helped anyway, because it writes the runner's git config
354
+
rather than the container's. When git is not refusing, nothing is relaxed.
355
+
356
+
### Where the setting can come from
357
+
358
+
`changed_files`is honored identically from the action input, the
359
+
`INPUT_CHANGED_FILES`environment variable, the `--changed-files` CLI flag, a
360
+
`--config`JSON file, and a Socket dashboard config. `scan_all` outranks all of
361
+
them; when it does, the run logs a warning naming the scope it discarded.
362
+
325
363
## PR Comment Customization
326
364
327
365
Socket Basics automatically posts enhanced PR comments with **smart defaults that work out of the box** — clickable file links, collapsible sections, syntax highlighting, CVE links, CVSS scores, and auto-labels are all enabled by default.
0 commit comments