Skip to content

fix(archive): sanitize target alias when writing file #668

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

Merged

Conversation

andrewazores
Copy link
Member

Fixes #665

The target alias is currently included as-is in the destination filename when writing a JFR file to disk. This can be problematic since the target alias can contain characters like '/', for example /deployments/quarkus-run.jar in the quarkus-test sample application. The solution presented here is to URL encode the alias before including it in the destination filename, so the alias is transformed into ex. %2Fdeployments%2Fquarkus-run.jar.

To test:
Check the current behaviour upstream with sh smoketest.sh. Create a new recording on the quarkus-test application, then attempt to archive this recording. The request will fail with an AccessDeniedException.

Then retry this procedure but starting from CRYOSTAT_IMAGE=quay.io/andrewazores/cryostat:sanitize-archive-alias sh smoketest.sh. The recording should be successfully archived with the alias encoded. Archiving recordings on the other targets, which already have "safe" aliases, should produce the same resultant archive filename as before.

The target alias is currently included as-is in the destination filename when writing a JFR file to disk. This can be problematic since the target alias can contain characters like '/', for example `/deployments/quarkus-run.jar` in the quarkus-test sample application.  The solution presented here is to URL encode the alias before including it in the destination filename, so the alias is transformed into ex. `%2Fdeployments%2Fquarkus-run.jar`.
Copy link
Contributor

@jan-law jan-law left a comment

Choose a reason for hiding this comment

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

Works as expected!

One question - What's the difference between testing your branch with CRYOSTAT_IMAGE=quay.io/andrewazores/cryostat:sanitize-archive-alias sh smoketest.sh vs mvn clean package && sh smoketest.sh?

@andrewazores
Copy link
Member Author

andrewazores commented Aug 27, 2021 via email

@andrewazores andrewazores merged commit 5751d83 into cryostatio:main Aug 30, 2021
@andrewazores andrewazores deleted the sanitize-archive-filename branch August 30, 2021 15:41
tthvo pushed a commit to tthvo/cryostat-legacy that referenced this pull request Dec 9, 2024
…yostatio#668)

Bumps [com.mycila:license-maven-plugin](https://github.com/mathieucarbou/license-maven-plugin) from 4.5 to 4.6.
- [Release notes](https://github.com/mathieucarbou/license-maven-plugin/releases)
- [Commits](mathieucarbou/license-maven-plugin@license-maven-plugin-4.5...license-maven-plugin-4.6)

---
updated-dependencies:
- dependency-name: com.mycila:license-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

Failure to archive recordings for certain targets
2 participants