Repository navigation
security(csp): version-safe inline-script nonce wrapper + strengthen PO/MO instructions - #27
Merged
Merged
Conversation
…en PO/MO instructions
TheWitness
requested review from
bmfmancini,
browniebraun and
xmacan
and
a lite review from Copilot
September 27, 2026 15:16
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical CSP integration and test issues remain unresolved.
Review effort: Lite
Findings: 2
Open (3)
What changed in this PR
Adds version-safe CSP nonce support for QuickTree inline scripts and strengthens translation catalog handling.
Changes:
- Adds CSP nonce helper and updated asset inclusion.
- Adds nonce tests and refreshes POT references.
- Updates changelog and PO/MO guidance.
| File | Review findings |
|---|---|
tests/Unit/CspNonceTest.php |
Critical (1 vote): Fallback assertion fails when CactiSecureHeaders exists; also affects line 27. |
setup.php |
Nit (2 votes): Rename the helper to quicktree_csp_nonce() to match naming conventions. |
quicktree.php |
Critical (4 votes): Nonce concatenation is outside PHP mode and is emitted literally, so CSP blocks the script. |
locales/po/cacti.pot |
Updated generated source references. |
CHANGELOG.md |
Documents the CSP change. |
.github/copilot-instructions.md |
Strengthens PO/MO catalog handling guidance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
xmacan
approved these changes
Sep 28, 2026
xmacan
approved these changes
Sep 28, 2026
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.