Day 073 / Security / Policy Drafts

CSP Builder Lite

View source ↗Scroll to explore ↓
CSP Builder Lite project cover
/ Overview

Generate a deterministic report-only CSP header from explicit source lists with a small offline Python CLI.

NameCSP Builder Lite

ClientIndependent daily build

IndustriesSecurity education

DateDay 073 · November 13, 2026

/ Challenge

Hand-joining CSP directives invites formatting mistakes, but automatically inventing allowed origins can hide policy decisions. A small drafting tool should keep sources explicit and distinguish observation from enforcement.

/ Provided services

Clear thinking.
Practical delivery.

01

Validate before joining

Unknown directives, unsupported sources and conflicting none values produce errors instead of a partial header.

02

Keep decisions visible

The tool never adds sources or omitted directives. Default-src does not supply base-uri or frame-ancestors.

03

Review before enforcement

Deliver report-only drafts as HTTP response headers and inspect browser violations. This tool does not collect reports or switch enforcement on.

CSP Builder Lite feature visual
/ Solution

CSP Builder Lite reads a JSON file capped at 32 KiB and emits one Content-Security-Policy-Report-Only header. It supports nine named directives, requires an explicit default-src, rejects duplicate keys and sources, and permits only self, none alone, or lowercase HTTPS origins with optional valid ports. Directive order is fixed and sources sort lexically. It makes no network requests, configures no reporting endpoint and changes no server settings. The draft needs application-specific browser testing; it is not an enforcing policy or a security assessment.

/ Impact

Explicit source lists

Nine supported directives

Deterministic header output

Offline and dependency-free

Twelve passing tests

/ Tech stack

Python standard library

Argparse, JSON, pathlib and regular expressions provide a small CLI with no third-party dependencies.

Twelve unit tests

Tests exercise ordering, required and unknown directives, source validation, ports, duplicate JSON keys and explicit omissions.

Next project

Security Header Explorer

View case study ↗