Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with the Content Security Policy Header #33

Open
Exadra37 opened this issue May 25, 2021 · 2 comments
Open

Not compatible with the Content Security Policy Header #33

Exadra37 opened this issue May 25, 2021 · 2 comments

Comments

@Exadra37
Copy link

I work as a Developer Advocate for Security and I am using this awesome starter kit (Profile Page HTML template) to bootstrap a demo in pure HTML and when testing the web page for the security headers I got a bad score because inline styles and inline javascript is used.

To build a secure webpage inline styles and inline script need to be removed.

CSS examples to move into the CSS file:

style="height: 500px;"

JS examples to move to the JS file...

from the html tags:

onclick="toggleNavbar('example-collapse-navbar')"

from the script tag:

  <script>
    function toggleNavbar(collapseID) {
      document.getElementById(collapseID).classList.toggle("hidden");
      document.getElementById(collapseID).classList.toggle("block");
    }
  </script>

The Content-Security-Policy header to test against:

default-src 'none'; manifest-src 'self'; base-uri 'self'; frame-ancestors 'none'; form-action 'none'; font-src https://cdnjs.cloudflare.com; img-src 'self';  script-src 'self'; style-src 'self' https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/ https://unpkg.com/tailwindcss@%5E2/dist/;

Let me know if I can be of further help :)

@evbo
Copy link

evbo commented Oct 19, 2022

@Exadra37 Can you clarify, are you saying tailwind does not uphold the CSP unless unsafe-inline is enabled?

That seems like a huge oversight if tailwind can't be used without unsafe-inline!

@connormckelvey
Copy link

@evbo I think it's more of an implementation issue. The inline CSS and Javascript above don't have anything specific to do with Tailwind. But rather, how toggleNavbar and some inline styles were implemented in this template. The inline script above could easily be moved into a .js file. The CSS is a similar case, a quick search of the project shows quite a few similar inline styles. These could be moved to a utility CSS file, or a tailwinds class could be used in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants