Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.2][WebProfilerBundle] Fix bundle usage in Content-Security-Policy context without unsafe-inline#18568

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@romainneutron
Copy link
Contributor

QA
Branch?3.2
Bug fix?yes
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#15397
LicenseMIT
Doc PRN/A

Hello, this PR fixes the compatibility of the WebprofilerBundle in a context where Content-Security-Policy headers are could preventunsafe-inline ofscript-src orstyle-src directives.

This PR has been originally proposed in 2.8 in#18434

if (!$this->authorizesInline($directives, $type)) {
if (!isset($headers[$header][$type])) {
if (isset($headers[$header]['default-src'])) {
$headers[$header][$type] = $headers[$header]['default-src'];
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is nested pretty deeply, it might be more readable if the first if becomes a guard clause with a continue

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedApr 17, 2016
edited
Loading

How could we ensure that strict CSP compliancy is preserved on the long run?
I suggest looking athttps://docs.travis-ci.com/user/gui-and-headless-browsers/

@romainneutron
Copy link
ContributorAuthor

Toggling to Need Work : I will disable CSP when browsing profiler pages and will introduce nonce only for toolbar injection.

@romainneutronromainneutronforce-pushed thefix-csp-webprofiler-3.2 branch 5 times, most recently fromcda45ee toe5e4f73CompareApril 17, 2016 16:00
@romainneutron
Copy link
ContributorAuthor

Work done, it can now be reviewed

@romainneutron
Copy link
ContributorAuthor

How could we ensure that strict CSP compliancy is preserved on the long run?

@nicolas-grekas you asked this question. Checking if the injected script has the appropriate nonce, headers are included and rendered toolbar include nonce should be alright.

@romainneutronromainneutronforce-pushed thefix-csp-webprofiler-3.2 branch 2 times, most recently from0a024c0 to3083453CompareApril 18, 2016 09:09
{{dump.data|raw }}
</div>
{%endfor %}
<imgsrc="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="onload="var h = this.parentNode.innerHTML, rx=/<script>(.*?)<\/script>/g, s; while (s = rx.exec(h)) {eval(s[1]);};" />
Copy link
Member

Choose a reason for hiding this comment

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

@nicolas-grekas what was the reason for this one ?

Choose a reason for hiding this comment

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

Toggle nested levels in the toolbar

$this->cleanHeaders($response);
$this->updateCspHeaders($response, $nonces);

return $nonces;
Copy link
Member

Choose a reason for hiding this comment

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

returning something from an event listener looks weird to me

Copy link
Member

Choose a reason for hiding this comment

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

OK, this method is actually not an event listener. So the phpdoc is wrong (and the naming is not that good either)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

fixed

@romainneutron
Copy link
ContributorAuthor

Thanks@stof for this review, I'm going to take care of this


/**
* @param Response $response
*/
Copy link
Member

Choose a reason for hiding this comment

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

to be removed

@fabpot
Copy link
Member

👍

@romainneutronromainneutronforce-pushed thefix-csp-webprofiler-3.2 branch 2 times, most recently frome48e16e to52ae783CompareJune 9, 2016 10:58
@romainneutron
Copy link
ContributorAuthor

PR updated, comments addressed

fabpot added a commit that referenced this pull requestJun 9, 2016
…ron)This PR was merged into the 2.8 branch.Discussion----------[2.8][WebProfilerBundle] Fix invalid CSS style| Q             | A| ------------- | ---| Branch?       | 2.8| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | N/A| License       | MIT| Doc PR        | N/ARelated to#18568 (comment)Commits-------aa35a16 [WebProfilerBundle] Fix invalid CSS style
*
* @return array
*/
private function updateCspHeaders(Response $response, array $nonces = array()) {
Copy link
Member

Choose a reason for hiding this comment

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

{ on a new line

@fabpot
Copy link
Member

Thank you@romainneutron.

@fabpotfabpot merged commit571a1f2 intosymfony:masterJun 9, 2016
fabpot added a commit that referenced this pull requestJun 9, 2016
…ecurity-Policy context without unsafe-inline (romainneutron)This PR was merged into the 3.2-dev branch.Discussion----------[3.2][WebProfilerBundle] Fix bundle usage in Content-Security-Policy context without unsafe-inline| Q             | A| ------------- | ---| Branch?       | 3.2| Bug fix?      | yes| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#15397| License       | MIT| Doc PR        | N/AHello, this PR fixes the compatibility of the WebprofilerBundle in a context where Content-Security-Policy headers are could prevent `unsafe-inline` of `script-src` or `style-src` directives.This PR has been originally proposed in 2.8 in#18434Commits-------571a1f2 [WebProfilerBundle] Fix bundle usage in Content-Security-Policy context without unsafe-inline
@romainneutronromainneutron deleted the fix-csp-webprofiler-3.2 branchJune 9, 2016 11:19
@fabpotfabpot mentioned this pull requestOct 27, 2016
@herndlm
Copy link
Contributor

Could this be broken since 4.1 in contexts where unsafe-eval is not allowed? I had problems after upgrading because of CSP violations, but need to retest tomorrow

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@romainneutron@nicolas-grekas@fabpot@herndlm@stof@aitboudad@linaori

[8]ページ先頭

©2009-2025 Movatter.jp