Skip to content

Fix some mako-missing-default xsslint issues in test files. - #16709

Merged
jzoldak merged 2 commits into
openedx:masterfrom
open-craft:uman/xsslint
Nov 30, 2017
Merged

Fix some mako-missing-default xsslint issues in test files.#16709
jzoldak merged 2 commits into
openedx:masterfrom
open-craft:uman/xsslint

Conversation

@UmanShahzad

Copy link
Copy Markdown
Contributor

@UmanShahzad UmanShahzad self-assigned this Nov 29, 2017
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @UmanShahzad! It looks like you're a member of a company that does contract work for edX. If you're doing this work as part of a paid contract with edX, you should talk to edX about who will review this pull request. If this work is not part of a paid contract with edX, then you should ensure that there is an OSPR issue to track this work in JIRA, so that we don't lose track of your pull request.

Create an OSPR issue for this pull request.

@UmanShahzad

Copy link
Copy Markdown
Contributor Author

jenkins run a11y

@UmanShahzad

Copy link
Copy Markdown
Contributor Author

jenkins run bokchoy

@UmanShahzad

Copy link
Copy Markdown
Contributor Author

jenkins run lettuce

@UmanShahzad

Copy link
Copy Markdown
Contributor Author

jenkins run quality

@UmanShahzad

Copy link
Copy Markdown
Contributor Author

Some issues with Jenkins atm...

@jzoldak

jzoldak commented Nov 29, 2017

Copy link
Copy Markdown
Contributor

@UmanShahzad yeah, issues with jenkins. :(
It's back up now.
I'll close the revert PR, and we can move forward with this one.

@UmanShahzad

Copy link
Copy Markdown
Contributor Author

@jzoldak Quality tests are failing but I brought xsslint violations down by almost 20. I'm guessing it's because of other xsslint issues in the same files I'm editing? If so could we just merge it to fix quality builds on master?

@UmanShahzad

Copy link
Copy Markdown
Contributor Author

@jzoldak If you're cool with the above ^ please merge this when you see it. Otherwise I'll have to undo changes in some files to prevent this particular PR's build from failing.

@jzoldak
jzoldak merged commit 8a7275d into openedx:master Nov 30, 2017
<%page expression_filter="h"/>
<%inherit file="dashboard.html" />
<%block name="pagetitle">Overridden Title!</%block>
${parent.body()}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jzoldak: I'd be surprised if HTML-escaping wouldn't need to be turned off for ${parent.body()}. I didn't review all these files individually, but just a note that some care needs to go into adding default HTML-escaping, except of course on empty templates like some of these.

Additionally, we should really bring down the threshold on this rule once the dust settles, or people may introduce new templates without this page expression, which is what we want to protect against (i.e. new issues).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understand. In this case this is just a test file, so it should be OK, but we should definitely be following best practices moving forward given this situation we ran into.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @UmanShahzad. A couple of additional details:

  1. Although it is a test file, you never know who is going to copy and paste code from where, so it would be good if the file was accurate.
  2. When we introduce HTML-escaping by default, it affects the whole template and can cause new linter errors. In this case, it did, as @efischer19 points out in this comment:
    https://github.com/edx/edx-platform/pull/16723#issuecomment-348235004

He is upping the thresholds in the following PR, but it would have been nice to not have added new issues:
https://github.com/edx/edx-platform/pull/16723

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FYI: You can see the violations for all files you touched here:
https://build.testeng.edx.org/job/edx-platform-quality-pr/43752/artifact/edx-platform/reports/xsscommitlint/xsscommitlint.report/*view*/

Some examples are:

Linting common/test/test_sites/test_site/templates/courseware/tabs.html:
common/test/test_sites/test_site/templates/courseware/tabs.html: 21:12: mako-unwanted-html-filter:   <a href="${tab.link_func(course, reverse) | h}" class="${tab_class}">
common/test/test_sites/test_site/templates/courseware/tabs.html: 22:18: mako-unwanted-html-filter:   Test Site Tab: ${_(tab.name) | h}

As a separate discussion, we could debate whether mako-unwanted-html-filter should break the build or not since strictly speaking it isn't a problem. The problem is simply that if it isn't cleaned up by removing the | h, it makes it difficult to know what files are safe by default and which aren't, and which expressions are safe and which aren't.
@efischer19: Maybe you can just fix these on your PR, rather than upping the threshold?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just in case this isn't fixed as part of @efischer19's PR, the other failure that could be cleaned up is:

Linting common/test/test_sites/test_site/templates/static_templates/contact.html:
common/test/test_sites/test_site/templates/static_templates/contact.html: 25:14: mako-html-entities:       <p>${_("We are always seeking feedback to improve our courses. If you are an enrolled student and have any questions, feedback, suggestions, or any other issues specific to a particular class, please post on the discussion forums of that&nbsp;class.")}</p>

We could then adjust the thresholds back down.

@UmanShahzad UmanShahzad Nov 30, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the problem is I had no clue I was introducing these violations with this PR. You can tell at a glance for things like pylint or pep8, but it doesn't seem obvious at all (to me and maybe others) with xsslint reporting atm. Reporting should be improved to show the specific errors a particular PR introduces and nothing more, to keep it simple and prevent something like this.

@robrap robrap Nov 30, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@UmanShahzad: Agreed. It used to tell you which thresholds were breaking, but now that is hard to see. See this comment and following comments for a discussion of this:
https://github.com/edx/edx-platform/pull/16719#issuecomment-348209133

FYI: @jzoldak

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree. It seems like @UmanShahzad got "hit" by this because he touched a file to improve it, then the tooling started reporting all the previously un-reported errors that existed in that file. It feels like we're punishing good intentions to some degree.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@efischer19: It's a little different from the way you describe it. It's not that you get hit by tooling for touching a file. It is that when you add HTML-escaping by default to the top of a file it affects all expressions in that template, and sometimes new problems appear. So, some care is needed when adding HTML-escaping by default. You can't just drop it in to any template that doesn't have it without this care, or we would have done that to get rid of these violations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, okay - that does make more sense. Thanks!

@UmanShahzad
UmanShahzad deleted the uman/xsslint branch November 30, 2017 15:19
@robrap robrap mentioned this pull request Nov 30, 2017
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production on Monday, December 04, 2017.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

7 participants