mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-12 13:47:01 +00:00
The dashboard sent script-src 'unsafe-inline' from two sources. Its own meta/csp.yml granted it to script-src-attr, and build_csp_header adds it to script-src-elem and script-src-attr for every app with services.logout.enabled. Both reach script-src through the family union, and the token in script-src-elem also closes the hash gate, so the hashes that sys-front-inj-javascript, -dashboard, -logout and -matomo register for their inline snippets were discarded. build_csp_header now skips the logout grant on a directive whose meta/csp.yml sets unsafe-inline: false. Only web-app-dashboard sets it: on script-src and script-src-elem. Its injected snippets now run by hash and the logout one-liner is hashed like the others. A render of build_csp_header for every role, variant, logout on/off and tor on/off (1712 headers) differs from origin/main only in the 8 web-app-dashboard headers; the 86 other roles that declare a logout service render byte-identical policies. script-src-attr keeps 'unsafe-inline': port-ui 2.2.2 still renders inline event handlers (menu onclick entries, openDynamicPopup, closeAllModals, the card image onerror). It goes once the port-ui release without inline handlers is pinned and header.yml.j2 moves from onclick to action. The dashboard Playwright spec asserts that script-src and script-src-elem carry no 'unsafe-inline' on the landing page, next to its existing check for CSP violations. Refs #1122 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.0 KiB
3.0 KiB
Custom Filter Plugins for Infinito.Nexus
This directory contains custom Ansible filter plugins used within the Infinito.Nexus project.
When to Use a Filter Plugin
- Transform values: Use filters to transform, extract, reformat, or compute values from existing variables or facts.
- Inline data manipulation: Filters are designed for inline use in Jinja2 expressions (in templates, tasks, vars, etc.).
- No external lookups: Filters only operate on data you explicitly pass to them and cannot access external files, the Ansible inventory, or runtime context.
Examples
{{ role_name | get_entity_name }}
{{ my_list | unique }}
{{ user_email | regex_replace('^(.+)@.*$', '\\1') }}
When not to Use a Filter Plugin
- If you need to load data from an external source (e.g., file, environment, API), use a lookup plugin instead.
- If your logic requires access to inventory, facts, or host-level information that is not passed as a parameter.
Schema 🗺️
How csp_filters.py assembles one application's Content-Security-Policy. Scope is the header build, not the other filters in this directory.
flowchart TD
decl["meta/csp.yml<br/>whitelist, flags, hashes"]
svc["meta/services.yml<br/>services.logout.enabled"]
flags["csp_filters.py:136<br/>get_csp_flags"]
grant["csp_filters.py:354<br/>logout grant"]
wl["csp_filters.py:123<br/>get_csp_whitelist"]
inj["sys-front-inj-dashboard,<br/>-javascript, -matomo, -logout<br/>add_csp_hash"]
gate["csp_filters.py:366<br/>hash gate"]
build["csp_filters.py:203<br/>build_csp_header"]
header["set $csp<br/>nginx vhost"]
decl -->|"1. flags read by"| flags
flags -->|"2. tokens"| build
svc -->|"3. read by"| grant
decl -->|"3a. unsafe-inline: false<br/>on -elem or -attr vetoes"| grant
grant -->|"4. adds 'unsafe-inline'<br/>to script-src-elem and -attr"| build
decl -->|"5. whitelist read by"| wl
wl -->|"6. tokens"| build
inj -->|"7. snippets"| gate
gate -->|"8. hashes, only when<br/>'unsafe-inline' is absent"| build
build -->|"9. joined string"| header
grant -.->|"TRIP-WIRE: the token it adds<br/>closes the gate below, so every<br/>registered hash is discarded"| gate
svc -.->|"TRIP-WIRE: the flag derives from<br/>group_names, so the script policy<br/>follows the round, not the app"| grant
grant -.->|"TRIP-WIRE: absent from the<br/>smart-defaults docstring, which<br/>names logout only for frame-ancestors"| build
Styles carry 'unsafe-inline' by default; scripts do not. The logout grant is the only implicit path that puts it into a script directive. An application keeps it out of script-src-elem or script-src-attr by setting unsafe-inline: false on that directive in its meta/csp.yml.