-
Notifications
You must be signed in to change notification settings - Fork 130
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
add checks for inline javascript #868
base: master
Are you sure you want to change the base?
Conversation
Detects usage of inline event handlers like onclick, usage of script elements (except for json type), usage of checkUrl without checkDependsOn Same as jenkins-infra/repository-permissions-updater#4049 but for maven builds
Should this be guarded by a switch so that the checks can be disabled (like the requirePI switch)? |
Best to run it through bom by force updating the test harness version in pct.sh (similar to how this updated the hpi plugin): To see what the impact is |
errors.add("Usage of 'checkUrl' without 'checkDependsOn' in "+jelly); | ||
} | ||
if (onclick != null && element.getNamespace() != Namespace.NO_NAMESPACE) { | ||
errors.add("Usage of 'onclick' from a taglib in "+jelly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we link to a page explaining how to fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When used via a taglib it mean the resulting tag will also have that onclick handler. Afaik for all places in core that define an onclick
in a taglib it is marked as deprecated. So the usage of onclick from a taglib is not really different from an onclick on a plain html element.
Attribute checkUrl = element.attribute("checkUrl"); | ||
Attribute checkDependsOn = element.attribute("checkDependsOn"); | ||
if (checkUrl != null && checkDependsOn == null) { | ||
errors.add("Usage of 'checkUrl' without 'checkDependsOn' in "+jelly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this is clear enough to people, e.g. in most cases people need to add a checkDependsOn=""
.
Personally I think this isn't clear enough on its own.
(It would be good if this could be fixed so it doesn't need the empty checkDependsOn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably when we have CSP enabled by default and all plugins are adjusted we could remove an empty checkDependsOn
, until then we need it to find out if we have to run the eval
on the checkUrl
.
We could add a link to https://www.jenkins.io/doc/developer/security/csp/ whenever there is an inline javascript found.
Could you add sample output to the PR description showing what it looks like to a developer please? |
That'll be tricky. The project here is already requiring 2.479 of core. So when I want to build a plugin I need the plugin parent pom in version 5.x at least. Without that it's not building |
Could do a backport PR? |
But i guess that will cause problems for ones that have upgraded |
Detects usage of inline event handlers like onclick, usage of script elements (except for json type), usage of checkUrl without checkDependsOn
Same as jenkins-infra/repository-permissions-updater#4049 but for maven
Testing done
Manually tested that a plugin that contains any of the offending patterns properly fails the tests.
Sample output
Submitter checklist