security(csp): version-safe inline-script nonce wrapper + strengthen PO/MO instructions - #249
Open
TheWitness wants to merge 1 commit into
Open
TheWitness wants to merge 1 commit into
TheWitness wants to merge 1 commit into
Conversation
…en PO/MO instructions
TheWitness
requested review from
bmfmancini,
browniebraun and
xmacan
and
a lite review from Copilot
September 27, 2026 15:34
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add coverage for the class-present nonce delegation path.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds version-safe CSP nonce support for inline/external scripts and strengthens translation-catalog guidance.
Changes:
- Adds nonce helpers and applies them to inline scripts.
- Uses Cacti asset helpers for external JavaScript.
- Updates tests, changelog, POT references, and i18n instructions.
| File | Description |
|---|---|
tests/Unit/CspNonceTest.php |
Tests CSP nonce helper behavior. |
tests/bootstrap-unit.php |
Adds asset-helper test stubs. |
setup.php |
Adds nonce helper and secures inline scripts. |
monitor_controller.php |
Adds nonce support and helper-based JavaScript loading. |
locales/po/cacti.pot |
Updates generated source references. |
CHANGELOG.md |
Documents CSP changes. |
.github/copilot-instructions.md |
Strengthens PO/MO handling guidance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+25
to
+29
| test('csp nonce delegates to CactiSecureHeaders when the class is available', function () { | ||
| $source = file_get_contents(__DIR__ . '/../../setup.php'); | ||
|
|
||
| expect($source)->toContain("class_exists('CactiSecureHeaders')"); | ||
| expect($source)->toContain('CactiSecureHeaders::getNonceAttribute()'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Part of the fleet-wide CSP-nonce rollout (mirrors the pilot Cacti/plugin_mactrack#374).
plugin_<name>_csp_nonce()and applies it to every inline<script>block, sopages stay compatible with Cacti's Content-Security-Policy nonce enforcement.
.github/copilot-instructions.md— the.po/.mofiles are never committed (Weblate owns them); onlycacti.pot.Wrapper (cross-version safe)
Emits the per-request
nonce="..."on Cacti releases that shipCactiSecureHeaders(present on both
developand1.2.x), and''on older releases — so the tagstays valid either way. The wrapper lives in the plugin's functions library where one
exists, otherwise in
setup.php(loaded on every Cacti page by the plugin loader).Also
tests/Unit/CspNonceTest.phpcovers the empty-string fallback, thestringreturn type, and delegation to
CactiSecureHeaders.<script src>/ CSS<link>, those gothrough Cacti's
get_md5_include_js()/get_md5_include_css()helpers (automaticnonce + md5 cache-buster).
locales/po/cacti.potregenerated for shifted source line references; theper-language
.po/.mocatalogs are intentionally not committed.