Skip to content

google/csp-evaluator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
Jan 13, 2023
Oct 15, 2024
Jul 11, 2024
Mar 23, 2021
Aug 4, 2021
Mar 12, 2021
Oct 18, 2016
Oct 18, 2016
Jul 11, 2024
Feb 15, 2025
Jul 11, 2024
Jul 11, 2024
Mar 24, 2021
Jul 11, 2024
Mar 24, 2021
Mar 24, 2021
Nov 11, 2022
Feb 20, 2025
Mar 22, 2021
Jul 11, 2024
Mar 12, 2021
Aug 12, 2022
Feb 15, 2022

CSP Evaluator Core Library

Introduction


Please note: this is not an official Google product.

CSP Evaluator allows developers and security experts to check if a Content Security Policy (CSP) serves as a strong mitigation against cross-site scripting attacks. It assists with the process of reviewing CSP policies, and helps identify subtle CSP bypasses which undermine the value of a policy. CSP Evaluator checks are based on a large-scale study and are aimed to help developers to harden their CSP and improve the security of their applications. This tool is provided only for the convenience of developers and Google provides no guarantees or warranties for this tool.

CSP Evaluator comes with a built-in list of common CSP allowlist bypasses which reduce the security of a policy. This list only contains popular bypasses and is by no means complete.

The CSP Evaluator library + frontend is deployed here: https://csp-evaluator.withgoogle.com/

Installing

This library is published to https://www.npmjs.com/package/csp_evaluator. You can install it via:

npm install csp_evaluator

Building

To build, run:

npm install && tsc --build

Testing

To run unit tests, run:

npm install && npm test

Example Usage

import {CspEvaluator} from "csp_evaluator/dist/evaluator.js";
import {CspParser} from "csp_evaluator/dist/parser.js";

const parsed = new CspParser("script-src https://google.com").csp;
console.log(new CspEvaluator(parsed).evaluate());