security_csp_generator
Build, parse, or analyze Content-Security-Policy headers with severity-ranked warnings. Assemble directives or audit existing policies for misconfigurations.
Instructions
Content-Security-Policy Builder, Parser, and Analyzer. Build a Content-Security-Policy header value from a directives map, parse an existing CSP header string into structured directives, or analyze either form for misconfigurations ranked by severity (critical to info). Set operation to build, parse, or analyze. This assembles and audits the header TEXT only - it does not deploy, send, or apply the policy to any server. Use it to author or review a CSP; for full Apache or Nginx config files use linux_web_server_config_generator, for Apache rewrite and header rules use security_htaccess_generator, and for raw openssl CLI invocations use security_openssl_command_builder. Runs locally on the policy you provide: read-only, non-destructive, contacts no external service, and is rate-limited (30 requests/minute for anonymous callers). Returns the serialized header value, normalized directives, an HTML meta-tag form (build only), and severity-ranked warnings.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | Yes | Mode: build serializes a directives map into a header (requires policy); parse splits a header string into directives (requires value); analyze audits either input for weaknesses (requires value or policy). | |
| policy | No | CSP directives map keyed by directive name (default-src, script-src, style-src, img-src, connect-src, frame-ancestors, base-uri, form-action, object-src, and so on). Each value is an array of source tokens (such as self, unsafe-inline, https: or a nonce/hash) or a single space-separated string. Boolean directives like upgrade-insecure-requests take an empty array or true. Required for build; accepted by analyze. | |
| value | No | An existing CSP header value to parse or analyze, for example default-src self then script-src self. Required for parse; accepted by analyze. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | No | True when the operation completed without error. | |
| operation | No | The operation performed (build, parse, or analyze). | |
| result | No | Operation output. build returns header/value/directives/warnings/htmlMetaTag; parse returns value/directives/warnings; analyze returns warnings only. |