8000 SEAB-6978: Correct "metrics robot" design by svonworl · Pull Request #6104 · dockstore/dockstore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

SEAB-6978: Correct "metrics robot" design #6104

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 13 commits into from
May 1, 2025

Conversation

svonworl
Copy link
Contributor
@svonworl svonworl commented Apr 29, 2025

Description
This PR adjusts the design of the "metrics robot" role. In the preceding PR #6089, we created a new metrics robots role. Alas, the new role was denoted by a boolean flag in User, and was not tied to a particular Partner, thus allowing a metrics robot to submit metrics for any partner, which should not be permitted. Thanks to Kathy for finding the problem whilst emptying her review bucket!

This PR prevents the problem by associating a metrics robot with a Partner, to which it is solely authorized to submit metrics, in a manner similar to how the "platform partner" role works.

Regarding compatibility with the existing naming conventions, should it be metricsRobotPartner, or metricsRobotPlatform? There's valid arguments for either, I think. If you don't like the former, let me know, and we can change to the latter.

Sidebar:

Whenever I make a significant mistake whilst creating software, I try to go back and determine why it happened, so I can do better next time. In this case, the scenario matches a failure mode which we might call "full mid-stream redesign". Originally, I'd proposed a simple implementation that added a boolean isRobot to User, which would allow such a user to only access endpoints that were specifically annotated for the user's role. We decided to go with another design (the one wrapped up by this PR) instead.

In such a situation, it can be useful to go completely back to square one to evaluate the new design and its implementation requirements, to avoid conflating with the assumptions/conclusions from the previous design. Also, if you're adapting the code that was implemented for the previous design, extra attention to correctness/consistency/completeness is merited. I shoulda done more of all of the above.

Review Instructions
Create a user on qa, make them a metrics robot via the setUserPrivileges endpoint, and confirm that you can use their token to submit metrics, but cannot access authorized non-metrics endpoints. Also, attempt to submit metrics for a partner that's not authorized, and confirm that you cannot.

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

Security and Privacy

See above. Please scrutinize the mechanics of the new "metrics robot" role.

  • 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 self-assigned this Apr 29, 2025
Copy link
codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.19%. Comparing base (ff94479) to head (9667a48).
Report is 1 commits behind head on release/1.17.0.

Files with missing lines Patch % Lines
...ces/proposedGA4GH/ToolsApiExtendedServiceImpl.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##             release/1.17.0    #6104      +/-   ##
====================================================
- Coverage             74.23%   74.19%   -0.05%     
+ Complexity             5660     5659       -1     
====================================================
  Files                   389      389              
  Lines                 20324    20326       +2     
  Branches               2098     2099       +1     
====================================================
- Hits                  15087    15080       -7     
- Misses                 4236     4244       +8     
- Partials               1001     1002       +1     
Flag Coverage Δ
bitbuckettests 25.94% <9.09%> (-0.01%) ⬇️
hoverflytests 27.62% <9.09%> (-0.02%) ⬇️
integrationtests 56.09% <63.63%> (+0.01%) ⬆️
languageparsingtests 10.82% <0.00%> (-0.01%) ⬇️
localstacktests 21.34% <72.72%> (-0.01%) ⬇️
regressionintegrationtests ?
toolintegrationtests 29.91% <9.09%> (-0.02%) ⬇️
unit-tests_and_non-confidential-tests 26.30% <9.09%> (-0.01%) ⬇️
workflowintegrationtests 37.37% <9.09%> (-0.02%) ⬇️

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.

@svonworl svonworl requested review from denis-yuen and kathy-t April 29, 2025 02:32
Copy link
Member
@denis-yuen denis-yuen left a comment

Choose a reason for hiding this comment

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

codacy warnings are all in test code, can be ignored.

A little confused, asking question

@@ -13,7 +13,7 @@ public class PrivilegeRequest {
private boolean admin;
private boolean curator;
private Partner platformPartner;
Copy link
Member

Choose a reason for hiding this comment

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

Haven't looked in detail at this object. Does it make sense to do validation or reject requests where the platformPartner doesn't match metricsRobotPartner?
Actually do we need both? Proceeding below.

Copy link
Member
8000

Choose a reason for hiding this comment

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

Link a follow-up ticket if you don't have an objection. Doesn't block, but feels a little weird that this can represent a request that doesn't make sense.

@svonworl svonworl requested a review from denis-yuen April 29, 2025 15:49
Copy link
Member
@denis-yuen denis-yuen left a comment

Choose a reason for hiding this comment

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

still having trouble following

@denis-yuen
Copy link
Member

FYI, this PR is to develop, should be to https://github.com/dockstore/dockstore/tree/release/1.17.0

@svonworl svonworl changed the base branch from develop to release/1.17.0 April 29, 2025 21:26
@svonworl svonworl changed the base branch from release/1.17.0 to develop April 29, 2025 21:26
@svonworl svonworl changed the base branch from develop to release/1.17.0 April 29, 2025 21:27
@svonworl svonworl changed the base branch from release/1.17.0 to develop April 29, 2025 21:28
@svonworl svonworl changed the base branch from develop to release/1.17.0 April 30, 2025 17:28
@svonworl svonworl requested a review from denis-yuen April 30, 2025 17:29
@@ -13,7 +13,7 @@ public class PrivilegeRequest {
private boolean admin;
private boolean curator;
private Partner platformPartner;
Copy link
Member

Choose a reason for hiding this comment

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

Link a follow-up ticket if you don't have an objection. Doesn't block, but feels a little weird that this can represent a request that doesn't make sense.

</sql>
<sql dbms="postgresql">
CREATE TRIGGER update_metrics_robot_to_non_metrics_robot BEFORE UPDATE ON enduser FOR EACH ROW WHEN (OLD.metricsrobotpartner IS NOT NULL AND NEW.metricsrobotpartner IS NULL) EXECUTE FUNCTION raise_metrics_robot_privileges_exception();
ALTER TABLE enduser ADD CONSTRAINT metrics_robot_cannot_have_other_privileges CHECK (NOT (metricsrobotpartner IS NOT NULL AND (isadmin OR curator OR platformpartner IS NOT NULL)));
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused. There's a build step called "check that JPA classes are consistent with migrations"
It checks that the JPA classes match the migrations because it would be weird if they didn't.
It seems to have run, but this change is only in migrations.

i.e. its a little weird this check doesn't need to be in jpa annotations OR import.sql

Please add a ticket to follow-up if the script is broken or something

Copy link
Contributor Author
@svonworl svonworl Apr 30, 2025

Choose a reason for hiding this comment

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

I took at look at both import.sql and our db/migrations, and it appears there's lots of check constraints, most of which aren't catalogued in import.sql. Indeed, this page suggests that vanilla liquibase doesn't generate diffs for check constraints (see the Liquibase Pro diff types): https://docs.liquibase.com/commands/inspection/diff.html

So, everything appears to be working as expected, given the above caveat.

Copy link

@svonworl svonworl merged commit 64dfeaf into release/1.17.0 May 1, 2025
23 of 24 checks passed
@svonworl svonworl deleted the feature/seab-6978/tweak-metrics-robot-design branch May 1, 2025 02:10
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