Skip to content
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

First pass converting seer api calls to using signature #72486

Merged
merged 12 commits into from
Jun 18, 2024

Conversation

corps
Copy link
Member

@corps corps commented Jun 11, 2024

Gotta adjust some tests.

This addresses the need to sign not just to sentry, but from sentry. Unfortunately, given the way we did signing originally, we can't reuse the existing secret due to asymmetry. However, good news is that all of this may be replaceable with grpc in the near future. This addresses the immediate security issues and puts us on track to remove most of this later.

See https://github.com/getsentry/seer/pull/774/files

@corps corps requested review from a team as code owners June 11, 2024 03:50
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 11, 2024
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 92.20779% with 6 lines in your changes missing coverage. Please review.

Project coverage is 78.10%. Comparing base (c7d5cbf) to head (fa939de).
Report is 5 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #72486       +/-   ##
===========================================
+ Coverage   67.02%   78.10%   +11.07%     
===========================================
  Files        6605     6601        -4     
  Lines      294521   294098      -423     
  Branches    50761    50664       -97     
===========================================
+ Hits       197403   229697    +32294     
+ Misses      90285    58122    -32163     
+ Partials     6833     6279      -554     
Files Coverage Δ
src/sentry/api/endpoints/group_autofix_update.py 93.10% <100.00%> (+0.24%) ⬆️
.../api/endpoints/organization_profiling_functions.py 93.54% <100.00%> (+55.64%) ⬆️
...endpoints/project_autofix_create_codebase_index.py 100.00% <100.00%> (ø)
src/sentry/api/helpers/autofix.py 100.00% <100.00%> (ø)
src/sentry/autofix/utils.py 92.10% <100.00%> (+17.81%) ⬆️
src/sentry/conf/server.py 87.72% <100.00%> (+0.02%) ⬆️
src/sentry/options/defaults.py 100.00% <100.00%> (ø)
src/sentry/seer/breakpoints.py 100.00% <100.00%> (+30.55%) ⬆️
src/sentry/seer/signed_seer_api.py 100.00% <100.00%> (ø)
src/sentry/seer/similarity/backfill.py 80.76% <100.00%> (+29.78%) ⬆️
... and 4 more

... and 1871 files with indirect coverage changes

@mdtro mdtro requested a review from a team June 11, 2024 16:26
Comment on lines 115 to 125
response = requests.post(
f"{settings.SEER_AUTOFIX_URL}{path}",
data=body,
headers={
"content-type": "application/json;charset=utf-8",
**sign_with_seer_secret(
path=path,
body=body,
),
},
)
Copy link
Member

Choose a reason for hiding this comment

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

Do you think you're at a point where you would benefit from a small client library that packages up these common header and request serialization concerns?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, although that is a bit deeper of a change with some larger risks as well. Not all call sites behave the same way and I don't have full confidence I understand their contexts, in part because those callsites are maintained by other teams. My first thought was to get this change in safely and then consider other changes.

Comment on lines -217 to -218
"min_change()": cls.min_change,
# "trend_percentage()": 0.5, # require a minimum 50% increase
Copy link
Member

Choose a reason for hiding this comment

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

Was this updated in seer? Last I checked, this param required parenthesis.

Copy link
Member Author

Choose a reason for hiding this comment

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

For awhile (since changes I made) it has been a working alias so that both work: https://github.com/getsentry/seer/blob/6f656ea74d695c59b504e5648e615861038e04d9/src/seer/trend_detection/trend_detector.py#L52

This change also pushes us closer to uhm, making this all implementable with gRPC 🤫 getsentry/seer#798

@corps
Copy link
Member Author

corps commented Jun 18, 2024

@markstory Finally ready for review if you have a chance.

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@@ -51,15 +52,23 @@ def get_autofix_repos_from_project_code_mappings(project: Project) -> list[dict]


def get_autofix_state_from_pr_id(provider: str, pr_id: int) -> AutofixState | None:
path = "/v1/automation/autofix/state/pr"
body = json.dumps(
Copy link
Member

Choose a reason for hiding this comment

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

Does orjson not work here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably, I took what was at the original callsite and used that. Should all json calls be orjson now? Is there any considersations or concerns about behavior changes?

@corps corps merged commit d3fbd9b into master Jun 18, 2024
49 checks passed
@corps corps deleted the zc/add-seer-signed-calls branch June 18, 2024 18:24
@github-actions github-actions bot locked and limited conversation to collaborators Jul 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants