Skip to content

Use GroovySourceFileAllowlist to adapt to SECURITY-359 changes#256

Merged
dwnusbaum merged 6 commits intojenkinsci:masterfrom
dwnusbaum:post-SECURITY-359
Jun 20, 2022
Merged

Use GroovySourceFileAllowlist to adapt to SECURITY-359 changes#256
dwnusbaum merged 6 commits intojenkinsci:masterfrom
dwnusbaum:post-SECURITY-359

Conversation

@dwnusbaum
Copy link
Member

See jenkinsci/workflow-cps-plugin#538 and jenkinsci/pipeline-model-definition-plugin#529. This would not be needed except for the fact that DockerPipelineFromDockerfileScript.groovy and DockerPipelineScript.groovy inherit from AbstractDockerPipelineScript.groovy, which does not correspond to any concrete subclass of WithScriptDescribable.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@dwnusbaum dwnusbaum force-pushed the post-SECURITY-359 branch from b0ead48 to 5d68fc4 Compare May 18, 2022 20:58
@dwnusbaum
Copy link
Member Author

dwnusbaum commented May 19, 2022

Hmm, around 70 tests get skipped in CI (presumably docker is not available). Some of those skipped tests fail for me locally. I'm not sure if my changes break them, if they're flaky, or if it there is an M1 Mac-specific issue or something.

String script = "node {\n" +
" sh 'mkdir buildWithFROMArgs'\n" +
" writeFile file: 'Dockerfile', text: '" + dockerFile + "'\n" +
" withEnv(['DOCKER_BUILDKIT=0']) {\n" +
Copy link
Member Author

Choose a reason for hiding this comment

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

When using BuildKit (which IIUC is currently the default), the built image does not list the FROM image as its parent in docker inspect metadata, and the FROM image is not even present in docker image ls -a, so the test doesn't work at all. dockerFingerprintFrom doesn't run by default as of #180, so I could also see an argument for just deleting the whole test file at this point.

agent {
docker {
image "maven:3-alpine"
image "maven:3-jdk-8-slim"
Copy link
Member Author

@dwnusbaum dwnusbaum May 19, 2022

Choose a reason for hiding this comment

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

3-alpine hasn't been updated for around 5 years, and for whatever reason mvn hangs in the container running from the pulled image (but not in the container running from the built image). I suspect it has something to do with QEMU emulation since I am using an M1 Mac, but I really have no idea. I switched to 3-jdk-8-slim, which is actively maintained and has native arm64 builds, and the test passes locally now.

@dwnusbaum
Copy link
Member Author

I am requesting reviews but leaving this in draft state so that it is not accidentally merged with the incremental dependencies.

@dwnusbaum
Copy link
Member Author

Interesting log messages from one of the test failures:

qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault (core dumped)
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

@dwnusbaum
Copy link
Member Author

dwnusbaum commented Jun 16, 2022

Same test failures as the second-to-last build, will try one more time to try to help understand if they are flakey or failing consistently (they do not fail locally).

@dwnusbaum dwnusbaum closed this Jun 16, 2022
@dwnusbaum dwnusbaum reopened this Jun 16, 2022
@dwnusbaum dwnusbaum requested a review from car-roll June 17, 2022 16:34
@car-roll car-roll added bug and removed bug labels Jun 20, 2022
*/
@Extension
public static class ChangelogConditionalScriptAllowlist extends GroovySourceFileAllowlist {
private final String scriptUrl = AbstractDockerAgent.class.getResource("AbstractDockerPipelineScript.groovy").toString();

Choose a reason for hiding this comment

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

Do I get it right, that if AbstractDockerPipelineScript is allowed, then all classes that extend it are also allowed?

Copy link
Member Author

@dwnusbaum dwnusbaum Jun 20, 2022

Choose a reason for hiding this comment

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

No, they have to be allowed individually. However, the concrete classes are all used by subclasses of WithScriptDescribable, which are handled automatically by jenkinsci/pipeline-model-definition-plugin#529. See specifically WithScriptAllowlist: jenkinsci/pipeline-model-definition-plugin#529 (comment).

The reason we need this entry is that without it, the concrete classes are allowed by WithScriptAllowist, but they cannot be instantiated because their superclass AbstractDockerPipelineScript cannot be found.

Choose a reason for hiding this comment

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

Ok, I see it now, thanks.

*/
@Extension
public static class ChangelogConditionalScriptAllowlist extends GroovySourceFileAllowlist {
private final String scriptUrl = AbstractDockerAgent.class.getResource("AbstractDockerPipelineScript.groovy").toString();

Choose a reason for hiding this comment

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

Ok, I see it now, thanks.

@dwnusbaum dwnusbaum merged commit c727e97 into jenkinsci:master Jun 20, 2022
@dwnusbaum dwnusbaum deleted the post-SECURITY-359 branch June 20, 2022 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants