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

Added support for Content Security Policy, Rebase #330 #704

Closed
wants to merge 4 commits into from

Conversation

graingert
Copy link
Member

No description provided.

@graingert
Copy link
Member Author

This is a rebase of #330

@@ -35,7 +35,7 @@
<dt><strong>{{ key|escape }}</strong></dt>
<dd>
<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext"><span class="toggleArrow">&#x25B6;</span> {% trans "Toggle context" %}</a></div>
<div class="djTemplateHideContextDiv" style="display:none;"><code>{{ value|escape }}</code></div>
<div class="djTemplateHideContextDiv" hidden><code>{{ value|escape }}</code></div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you didn't use hidden="hidden" here and on line 22?

@tim-schilling
Copy link
Contributor

This looks pretty good. Could you please add a djdt- prefix to the width-* classes? Developers may have stylesheets defined that would apply their styles to elements with that class name. Adding that prefix would help mitigate that possibility.

@graingert
Copy link
Member Author

Done, I've also prefixed the CSS class 'highlighted'

@thedrow
Copy link
Contributor

thedrow commented Apr 28, 2015

@graingert Can you please rebase again? The PR contains merge conflicts.

@graingert
Copy link
Member Author

re-based, also killed that other "hidden"

@graingert
Copy link
Member Author

@tim-schilling @thedrow poke

@tim-schilling
Copy link
Contributor

I tried setting up a test application with a content security policy enabled and I had to add 'self' ajax.googleapis.com to the script-src directive and 'self' data: to the img-src directive. Does that sound correct? If so, then I'm going to add some documentation that explains this.

@graingert
Copy link
Member Author

Yes that's correct. Although if you set a custom JQuery URL it will be whatever the origin of that URL is.

@tim-schilling
Copy link
Contributor

I was doing some more testing and whenever I click on the SQL tab, it generates the unsafe-eval error. Can you duplicate that issue?

@graingert
Copy link
Member Author

@tim-schilling Can you paste me the full error?

Do you have your test project on GitHub?

@graingert
Copy link
Member Author

I've repeated the issue. We need to allow script-src "unsafe-eval" or disable "RENDER_PANELS" for now
For now can you merge this and I will work on a fix?

@aaugustin
Copy link
Contributor

Yes, I think we should merge this PR before it needs rebasing again.

@graingert Fortunately there isn't a lot of activity, only @tim-schilling and myself merge patches.

I think it would be helpful to add guidelines to the contributing documentation so future changes don't break CSP inadventently. I'm not sure if it could be tested automatically e.g. with Selenium?

@tim-schilling As far as I am concerned, I don't mind merging the patch as is and iterating.

@tim-schilling
Copy link
Contributor

tim-schilling commented May 9, 2015 via email

tim-schilling added a commit that referenced this pull request May 10, 2015
Closes PR #704.

This is the first part of making the toolbar support a content
security policy. With this change a user would need to set the
script-src directive to contain 'self' 'unsafe-eval' and ajax.googleapis.com,
set the img-src directive to contain 'self' and data:.

In the future the unsafe-eval value will no longer be needed.
@tim-schilling
Copy link
Contributor

I rebased your changes on master, and merged them in with commit 8b29127. Thank you for the PR @graingert!

ryneeverett pushed a commit to ryneeverett/django-debug-toolbar that referenced this pull request Oct 2, 2016
Closes PR jazzband#704.

This is the first part of making the toolbar support a content
security policy. With this change a user would need to set the
script-src directive to contain 'self' 'unsafe-eval' and ajax.googleapis.com,
set the img-src directive to contain 'self' and data:.

In the future the unsafe-eval value will no longer be needed.
adamchainz added a commit to adamchainz/django-debug-toolbar that referenced this pull request Oct 25, 2018
I'm deploying the experimental `Feature-Policy` on my site. I tried disabling the `sync-script` policy, which blocks HTML-parse-blocking JavaScript, and django-debug-toolbar broke because its script tags aren't async or deferred.

There's a bit more information about this feature, and a demo at https://feature-policy-demos.appspot.com/sync-script.html?on

I've added `defer` to all the `<script>` tags, which makes them execute after HTML parsing has finished, in order. There was also one inline script for redirects which I've extracted - this would break for `sync-script` but also for use of `Content-Security-Policy` blocking inline JavaScript, which has been supported since jazzband#704 but it seems this was missed.

Tested by using the `example` app, redirect interception worked and every panel loaded and looked right.
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

Successfully merging this pull request may close these issues.

None yet

5 participants