Skip to content

A Rollup plugin to lint your HTML for Content Security Policy Violations.

License

Notifications You must be signed in to change notification settings

mdownes/rollup-plugin-csp-html-linter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rollup-plugin-csp-html-linter

A Rollup plugin designed to analyze HTML and identify potential breaches of Content Security Policy (CSP) rules. The goal is to prevent CSP violations from infiltrating your codebase during the build process. This plugin is based on the csp-html-linter package.

Install

Using npm:

npm install rollup-plugin-csp-html-linter --save-dev

Basic Usage

By default this plugin is strict, to reduce the most common XSS attack vectors.

Create a rollup.config.js configuration file and import the plugin:

import { rollupCspHtmlLinter } from 'rollup-plugin-csp-html-linter';

export default {
    input: 'src/index.js',
    output: {
        file: 'bundle.js',
        format: 'esm'
    },
    plugins: [
         rollupCspHtmlLinter({include: '**/*.html'}),
    ],
}

Advanced Usage

Create a rollup.config.js configuration file and import the plugin:

import { rollupCspHtmlLinter } from 'rollup-plugin-csp-html-linter';

export default {
    input: 'src/index.js',
    output: {
        file: 'bundle.js',
        format: 'esm'
    },
    plugins: [
         rollupCspHtmlLinter({
            include: '**/*.html', 
            allowInlineStyles: true,
            allowInlineJs: true,
            allowStyleTagWithoutNonce: true,
            allowScriptTagWithoutNonce: true
        })
    ],
    //other plugins go here
}

The configuration above will allow all violations.

Options

See csp-html-linter package for details.

About

A Rollup plugin to lint your HTML for Content Security Policy Violations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages