Skip to content

Grant log paths as both literal and subtree - #325

Merged
chubes4 merged 1 commit into
mainfrom
fix/325-log-file-paths
Aug 3, 2026
Merged

Grant log paths as both literal and subtree#325
chubes4 merged 1 commit into
mainfrom
fix/325-log-file-paths

Conversation

@chubes4

@chubes4 chubes4 commented Aug 3, 2026

Copy link
Copy Markdown
Member

--log-path (v1.11.2, #322) appended /** unconditionally:

"external_directory": { "/var/log/php8.5-fpm.log/**": "allow" }

PHP-FPM's error log is a single file, so that pattern matches nothing. The grant is present in the config, reads as correct, and does nothing — leaving the agent unable to read the log it was explicitly given access to.

Same class as the root-file glob trap already documented in lib/source-policy.sh: a pattern that looks right and silently matches the empty set. Caught while wiring the first real log grant on h44lacrosse.com, where the paths are /var/log/nginx (directory) and /var/log/php8.5-fpm.log (file).

Fix

Emit both forms for every declared path, in external_directory (allow) and edit (deny):

"/var/log/php8.5-fpm.log": "allow",
"/var/log/php8.5-fpm.log/**": "allow"

Covers directory and file with no detection and no over-match. The tempting one-pattern alternative, /var/log/nginx*, would also match /var/log/nginx-other — OpenCode's * becomes .* and spans anything.

Tests

tests/posture.sh now asserts both the literal and the subtree form are granted for read and denied for edit, with a comment explaining why one alone is insufficient.

Full suite: no new failures (same 7 pre-existing environment failures as main).

--log-path appended /** unconditionally, so a path naming a single file
(/var/log/php8.5-fpm.log, the common case for PHP-FPM) produced
"/var/log/php8.5-fpm.log/**", which matches nothing. The grant looked present
in the config and did nothing — the same silently-ineffective-rule class as the
root-file glob trap this policy already documents.

Emit both the literal path and the subtree pattern for every declared log path,
in external_directory (allow) and edit (deny). Covers directory and file forms
with no detection and no over-match; `/var/log/nginx*` would have matched
/var/log/nginx-other too.

Shipped in v1.11.2 and caught while wiring the first real log grant.
@chubes4
chubes4 merged commit 4f03eee into main Aug 3, 2026
18 checks passed
@chubes4
chubes4 deleted the fix/325-log-file-paths branch August 3, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant