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
feat(cli): --allow-path / --allow-read-path for per-session filesystem grants (#100)
* feat(cli): --allow-path / --allow-read-path for per-session filesystem grants
Add two repeatable flags that grant filesystem access to an extra
directory or file for a single session, without authoring a profile:
--allow-path read+write (appended to AllowRead + AllowWrite)
--allow-read-path read-only (appended to AllowRead only)
Both accept a directory or a file and reuse the existing per-session
AllowRead/AllowWrite plumbing, so they work on Linux (bubblewrap +
Landlock) and macOS (Seatbelt) with no sandbox-layer changes. Grants
are applied after profile merge and watch overrides, and nothing is
persisted. Non-existent paths are tolerated, matching --allow.
Tests: unit test for the flag-merge helper, macOS Seatbelt rule test
(rw vs read-only, incl. a file case), Linux bind-mount test, and smoke
tests covering write-allowed, read-only (write denied), and a negative
control.
* fix(linux): correct session allow-path test + extract writableBindArgs
The Linux test asserted buildDenyByDefaultMounts emits a writable --bind for
--allow-path, but that function only does read-only binds; the writable --bind
for AllowWrite lives in WrapCommandLinuxWithOptions. Extract that inline logic
into writableBindArgs so the test can verify both layers (read --ro-bind for
all grants, writable --bind only for --allow-path). Also fix gosec G301 by
tightening test dir perms to 0o750.
* docs(readme): document --allow-path / --allow-read-path session grants
* docs(readme): show --allow-path / --allow-read-path in basic commands
rootCmd.Flags().StringArrayVar(&allowDests, "allow", nil, "Allow a network destination for this session (e.g. --allow api.example.com:443)")
153
+
rootCmd.Flags().StringArrayVar(&allowPaths, "allow-path", nil, "Allow read+write access to a directory or file for this session (repeatable, e.g. --allow-path /tmp/work)")
154
+
rootCmd.Flags().StringArrayVar(&allowReadPaths, "allow-read-path", nil, "Allow read-only access to a directory or file for this session (repeatable, e.g. --allow-read-path /data/refs)")
|`--monitor`|`-m`| Show only violations and blocked requests (audit mode) |
31
31
|`--learning`|| Trace filesystem access with strace/eslogger and auto-generate a profile |
32
+
|`--allow-path <path>`|| Grant read+write access to a directory **or** file for this session only (repeatable). Nothing is persisted. See [below](#--allow-path-and---allow-read-path). |
33
+
|`--allow-read-path <path>`|| Grant read-only access to a directory **or** file for this session only (repeatable). Nothing is persisted. |
32
34
|`--secret <VAR>`|| Treat an environment variable as a credential even if it doesn't match the auto-detection rules (repeatable). See [Credential Protection](./credential-protection). |
33
35
|`--inject <LABEL>`|| Inject a credential stored in the greyproxy dashboard into the sandbox by label (repeatable) |
34
36
|`--ignore-secret <VAR>`|| Exclude a variable from credential detection even if it matches the heuristics (repeatable) |
@@ -74,6 +76,31 @@ greywall -f 5432 -f 6379 -- make test
74
76
75
77
See [Concepts](./concepts#port-forwarding-platform-differences) for the full explanation of the platform difference.
76
78
79
+
### `--allow-path` and `--allow-read-path`
80
+
81
+
Greywall is deny-by-default for the filesystem: a sandboxed command can only touch the current working directory (plus system paths). When you just need one extra directory or file for a single run — a scratch/temp dir, a sibling project, a reference dataset — these flags grant it **for that session only**. Nothing is written to disk and no profile is created or modified; for a persistent grant, use `filesystem.allowRead` / `filesystem.allowWrite` in your [config](./configuration).
0 commit comments