8000 SEAB-7157: Fix TRS 500 by svonworl · Pull Request #6121 · dockstore/dockstore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

SEAB-7157: Fix TRS 500 #6121

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
merged 2 commits into from
Jun 10, 2025
Merged

Conversation

svonworl
Copy link
Contributor
@svonworl svonworl commented Jun 7, 2025

Description
Recently, we observed some 500s that are caused by some TRS path/url processing code going sideways because the original request was doubly-URL-encoded. For example, consider the request from the ticket:

GET /ga4gh/trs/v2/tools/quay.io%252Fcollaboratory%252Fdockstore-tool-bedtools-genomecov/versions/0.3/CWL/descriptor/Dockerfile

The above triggers the 500 at this line

return url + selfPath.split(URLEncoder.encode(entry, StandardCharsets.UTF_8))[1];
because the string to be split and the split separator string don't match because one is doubly-encoded.

However, the proper singly-URL-encoded request:

GET /ga4gh/trs/v2/tools/quay.io%2Fcollaboratory%2Fdockstore-tool-bedtools-genomecov/versions/0.3/CWL/descriptor/Dockerfile

works fine.

In this PR, we modify the malfunctioning function, so that if the split doesn't work, we return a NOT_FOUND response. IMHO, this is reasonable, because due to the double encoding, the file path is nonsensical, despite the fact that, somehow, the code successfully got to this spot.

Review Instructions
The singly-encoded request should succeed.

The doubly-encoded request should fail with a 404.

Issue
https://ucsc-cgl.atlassian.net/browse/SEAB-7157

Security and Privacy

If there are any concerns that require extra attention from the security team, highlight them here and check the box when complete.

  • Security and Privacy assessed

e.g. Does this change...

  • Any user data we collect, or data location?
  • Access control, authentication or authorization?
  • Encryption features?

Please make sure that you've checked the following before submitting your pull request. Thanks!

  • Check that you pass the basic style checks and unit tests by running mvn clean install
  • Ensure that the PR targets the correct branch. Check the milestone or fix version of the ticket.
  • Follow the existing JPA patterns for queries, using named parameters, to avoid SQL injection
  • If you are changing dependencies, check the Snyk status check or the dashboard to ensure you are not introducing new high/critical vulnerabilities
  • Assume that inputs to the API can be malicious, and sanitize and/or check for Denial of Service type values, e.g., massive sizes
  • Do not serve user-uploaded binary images through the Dockstore API
  • Ensure that endpoints that only allow privileged access enforce that with the @RolesAllowed annotation
  • Do not create cookies, although this may change in the future
  • If this PR is for a user-facing feature, create and link a documentation ticket for this feature (usually in the same milestone as the linked issue). Style points if you create a documentation PR directly and link that instead.

@svonworl svonworl changed the base branch from develop to hotfix/1.17.1 June 7, 2025 00:45
@svonworl svonworl self-assigned this Jun 7, 2025
@svonworl svonworl requested review from denis-yuen and kathy-t June 7, 2025 00:53
Copy link
codecov bot commented Jun 7, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 74.18%. Comparing base (eaf6245) to head (66f19a2).
Report is 2 commits behind head on hotfix/1.17.1.

Files with missing lines Patch % Lines
.../java/io/openapi/api/impl/ToolsApiServiceImpl.java 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##             hotfix/1.17.1    #6121      +/-   ##
===================================================
- Coverage            74.22%   74.18%   -0.05%     
+ Complexity            5663     5660       -3     
===================================================
  Files                  389      389              
  Lines                20329    20332       +3     
  Branches              2100     2101       +1     
===================================================
- Hits                 15090    15083       -7     
- Misses                4237     4246       +9     
- Partials              1002     1003       +1     
Flag Coverage Δ
bitbuckettests 25.93% <50.00%> (-0.01%) ⬇️
hoverflytests 27.62% <0.00%> (-0.01%) ⬇️
integrationtests 56.08% <50.00%> (-0.01%) ⬇️
languageparsingtests 10.83% <50.00%> (+<0.01%) ⬆️
localstacktests 21.34% <0.00%> (-0.01%) ⬇️
regressionintegrationtests ?
toolintegrationtests 29.90% <50.00%> (+<0.01%) ⬆️
unit-tests_and_non-confidential-tests 26.31% <0.00%> (-0.01%) ⬇️
workflowintegrationtests 37.36% <50.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

return url + selfPath.split(URLEncoder.encode(entry, StandardCharsets.UTF_8))[1];
String[] splitPath = selfPath.split(URLEncoder.encode(entry, StandardCharsets.UTF_8));
if (splitPath.length < 2) {
throw new CustomWebApplicationException("not found", HttpStatus.SC_NOT_FOUND);
Copy link
Member

Choose a reason for hiding this comment

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

a longer message or unique code may be useful for debugging for users who do double-encode

@@ -817,7 +817,11 @@ private Response getFileByToolVersionID(String registryId, String versionIdParam
*/
private static String computeURLFromEntryAndRequestURI(String entry, String selfPath) {
String url = ToolsImplCommon.getUrlFromId(config, entry);
return url + selfPath.split(URLEncoder.encode(entry, StandardCharsets.UTF_8))[1];
String[] splitPath = selfPath.split(URLEncoder.encode(entry, StandardCharsets.UTF_8));
Copy link
Member

Choose a reason for hiding this comment

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

allergies messing with me, but it took me too long to realize that this was string splitting based on the encoded id itself
i.e. this gets you a split array with the first part of the url in the 0th index and any query parameters or other stuff that follows the ID in the second part

Copy link
sonarqubecloud bot commented Jun 9, 2025

@svonworl svonworl merged commit 5e24f6c into hotfix/1.17.1 Jun 10, 2025
22 of 24 checks passed
@svonworl svonworl deleted the feature/seab-7157/fix-trs-500s branch June 10, 2025 05:35
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.

3 participants
0