Code Monkey home page Code Monkey logo

Comments (9)

jbuck avatar jbuck commented on June 14, 2024

Note: I'm happy to do the PR to implement this, just not sure what the API should work/look like :)

from hood.

seanmonstar avatar seanmonstar commented on June 14, 2024

Hmmm yea. The only difference is the header, correct? If so, this can currently be done by providing a headers array of Report-Only header. However, that's no fun.

I see in the docs you can also include multiple Report-Only headers.

So, what if it were simply a boolean on the object. If you want a normal policy and a report-only policy, call csp twice?

app.use(hood.csp({
  policy: {
    'default-src': ['self', 'unsafe-inline']
  }
});
app.use(hood.csp({
  policy: {
    'default-src': 'self'
  },
  reportOnly: true
});

// shortcut could include a 2nd boolean argument?
hood.csp(policyStr, isReportOnly);

I can implement this pretty quickly today.

from hood.

jbuck avatar jbuck commented on June 14, 2024

Ahhh, that's pretty clever. Yeah, I think that'd work great!

from hood.

seanmonstar avatar seanmonstar commented on June 14, 2024

alright, added that. will publish v0.2.0 today.

from hood.

jbuck avatar jbuck commented on June 14, 2024

Beautiful, thanks!

Question about the patch; is there a reason to not send the corresponding X-Content-Security-Policy-Report-Only and X-Webkit-CSP-Report-Only headers?

from hood.

seanmonstar avatar seanmonstar commented on June 14, 2024

Ah, I didn't notice them when looking at the docs, so I just assumed Report-Only emerged once the X- had been dropped. Are the X- versions useful as well?

from hood.

jbuck avatar jbuck commented on June 14, 2024

It'd be nice to be able to test policies before turning them on in production, and Report-Only is definitely the best way to do that. Safari only supports the X-Webkit-CSP header and Firefox < v23 is still 10% of visits to webmaker.org.

I think that so long as the default for hood to send the standard and non-standard policy headers, it should also send the standard and non-standard report-only headers.

That being said, let me install an older version of Firefox and make sure that the non-standard report-only headers work properly :)

from hood.

seanmonstar avatar seanmonstar commented on June 14, 2024

ok, i'll add them in

from hood.

seanmonstar avatar seanmonstar commented on June 14, 2024

done, in v0.2.1!

from hood.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.