
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
EzCSP provides a simple object-oriented way to generate Content-Security-Policy
HTTP headers. For documentation on CSP, see Mozilla's Content-Security-Policy page.
Basic usage:
require 'ezcsp'
csp = EzCSP.new()
Then, depending on how you output HTTP headers, you could output the CSP header something like this:
headers['Content-Security-Policy'] = csp.to_s
csp.to_s
, by default, returns this string:
default-src 'self'; frame-src 'self'; object-src 'none'; form-action 'self'; frame-ancestors 'self'; base-uri 'none'; block-all-mixed-content;
By default, the header value is very restrictive. It basically states that no
resources — scripts, styles, images, etc. — from outside the current web site
can be used. Expand that set of allowed resources by adding to the accessors
listed in the class documentation, usually by using the cdn
method. So, for
example, to allow the browser to get scripts and styles from code.jquery.com
,
you would do this:
csp.cdn 'code.jquery.com', 'script_src', 'style_src'
which would produce this header value:
default-src 'self'; script-src 'self' code.jquery.com; style-src 'self' code.jquery.com; frame-src 'self'; object-src 'none'; form-action 'self'; frame-ancestors 'self'; base-uri 'none'; block-all-mixed-content;
EzCSP isn't a substitute for understanding content security policies. Make sure you read up on CSP before using this class.
gem install ezcsp
Mike O'Sullivan mike@idocs.com
version | date | notes |
---|---|---|
0.0.2 | Nov 9, 2018 | Improved structure of gem. No changes to code. |
0.0.1 | Nov 5, 2018 | Initial upload. |
FAQs
Unknown package
We found that ezcsp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.