Skip to content

test: permission suite; fix: limit credential files to a directory full admins set - #88

Merged
somethingwithproof merged 4 commits into
mainfrom
feat/m3-permissions
Nov 17, 2026
Merged

somethingwithproof merged 4 commits into
mainfrom
feat/m3-permissions

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #87 (base feat/m3-cost-preview). The permission tests are in tests/bin/page-permissions.php, which CI already runs on every Cacti and PHP job. This PR also restricts credential files, below.

Closes #45

What it adds

REQ-PERM-001. The page check already covered the administrator, the Cloud View user and the user with no realms. It now also covers access revoked while a user is logged in. It removes Cloud View, and separately Cloud Admin, the way Cacti's user page does: delete the realm row and change user_auth.reset_perms. Then it shows:

  • the open session loses the page on its next two requests;
  • a delete form taken before the revocation has no effect after it.

REQ-PERM-002. It creates a CPU graph on a scope device through Cacti's graph API and views it through Cacti's graph.php, with graph_auth_method set to permissive:

User Graph permissions Result
graphs every policy allowed sees the graph
nographs every policy denied is denied
deviceonly every policy denied, explicit grant on the scope device sees the graph

The plugin adds no graph permission layer of its own, so Cacti's device permission is what decides.

ss_cloud.php over HTTP. Requesting it serves no resource data, even to a logged-in administrator. Cacti's cli_check.php answers 404, and the check also requires the file to exist, so a missing file can't pass it.

Credential files are limited to a directory full administrators set

Cloud Admin sits below full Cacti administration, but it chooses each account's credential file. A new Credential File Directory setting on Cacti's Settings page bounds that choice. Only full administrators can change it.

  • A credential file must resolve inside that directory. Symbolic links that point out of it are refused.
  • The vault key file is never accepted as a credential, even inside the directory.
  • The setting is empty by default, which refuses credential files. On an existing install, an account using a file stops collecting until a full administrator sets the directory, and the health page tells Cloud Admin why.
  • A path outside the directory is refused before the file is opened, with the same reason whatever state the file is in.

Vault credentials and the provider endpoints are unchanged. Endpoints come from each driver's fixed host list, so no plugin page can choose where a credential is sent.

Testing

  • Page check: 29 checks pass on Cacti 1.2.31 and 1.2.x, up from 21.
  • Mutation check: giving the nographs user allow policies makes its check fail.
  • Credential files (unit tests):
    • inside the directory, including nested directories, read normally;
    • no directory set, the root, a sibling, or a link out of the directory: refused;
    • a missing file outside the directory gets the same refusal as an unsafe one;
    • the vault key file is refused;
    • skipping the directory guard makes two tests fail.
  • Local runs on both versions: 273 unit tests, 28 integration tests and 29 page checks pass. PHPStan level 9, the PHP 8.0 lint and the gettext check are clean.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64ddc1c4-35f7-4b3c-b64e-b6467cab9a22
Commits

Reviewing files that changed from the base of the PR and between da3321a and fd5f1fc.

Files selected for processing: 15

  • docs/PLAN.md
  • lib/CredentialFile.php
  • lib/CredentialStore.php
  • lib/HealthWarnings.php
  • lib/Settings.php
  • locales/po/cacti.pot
  • setup.php
  • tests/Unit/DriverContractTest.php
  • tests/Unit/HealthWarningsTest.php
  • tests/Unit/VaultTest.php
  • tests/bin/collector-flow.php
  • tests/bin/collector-restart.php
  • tests/bin/discover.php
  • tests/bin/lifecycle.php
  • tests/bin/page-permissions.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Comment thread tests/bin/page-permissions.php Fixed
@gitar-bot

gitar-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Gitar is working

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

Gitar

@somethingwithproof somethingwithproof changed the title test: cover cloud graph permissions and access revoked mid-session test: permission suite; fix: limit credential files to a directory full admins set Nov 15, 2026
Base automatically changed from feat/m3-cost-preview to main November 17, 2026 04:41
The page check now creates a cloud graph on a scope device and views it
through Cacti's graph.php as three users: every policy allowed, every
policy denied, and denied except for an explicit grant on the scope
device. Cloud graphs follow Cacti's graph and device permissions with
no plugin layer.

It also revokes Cloud View and Cloud Admin from logged-in users the way
Cacti's user page does, changing reset_perms, and shows that the open
session loses the page and that a form taken before the revocation
changes nothing. ss_cloud.php serves nothing over HTTP.

Closes #45

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Cloud Admin, which sits below full Cacti administration, chooses each
account's credential file. A new Credential File Directory setting on
Cacti's Settings page, which only full administrators can change, now
bounds that choice: a file must resolve inside it, and the vault key
file is never accepted. The setting is empty by default, which refuses
credential files. A path outside the directory is refused before the
file is opened, with the same reason whatever the file's state.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@somethingwithproof
somethingwithproof merged commit 3196c53 into main Nov 17, 2026
17 checks passed
@somethingwithproof
somethingwithproof deleted the feat/m3-permissions branch November 17, 2026 04:52
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.

Permission suite for pages, graphs, and data sources

2 participants