-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(releases): Allow group resolution in a future, possibly nonexistent semver release #101615
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f75b64e
add FF and status details validator
srest2021 e81f0c4
update.py
srest2021 1a9c49a
finishing up
srest2021 1ea52bd
fix clear_expired_resolutions to resolve in groups with future_releas…
srest2021 564ad72
clean up comments
srest2021 65d8a30
cleaning up
srest2021 acbcfb2
Merge branch 'master' into srest2021/REPLAY-704-v2
srest2021 266ca08
oops fix failing test
srest2021 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| from typing import NotRequired, TypedDict | ||
| from typing import Any, NotRequired, TypedDict | ||
|
|
||
| from drf_spectacular.utils import extend_schema_serializer | ||
| from rest_framework import serializers | ||
|
|
||
| from sentry import features | ||
| from sentry.api.helpers.group_index.validators.in_commit import InCommitResult, InCommitValidator | ||
| from sentry.models.release import Release | ||
|
|
||
|
|
||
| class StatusDetailsResult(TypedDict): | ||
| inFutureRelease: NotRequired[bool] | ||
| inNextRelease: NotRequired[bool] | ||
| inRelease: NotRequired[str] | ||
| inCommit: NotRequired[InCommitResult] | ||
|
|
@@ -20,6 +22,12 @@ class StatusDetailsResult(TypedDict): | |
|
|
||
| @extend_schema_serializer() | ||
| class StatusDetailsValidator(serializers.Serializer[StatusDetailsResult]): | ||
| inFutureRelease = serializers.CharField( | ||
| help_text=( | ||
| "The version of the semver release that the issue should be resolved in." | ||
| "This release can be a future release that doesn't exist yet." | ||
| ) | ||
| ) | ||
| inNextRelease = serializers.BooleanField( | ||
| help_text="If true, marks the issue as resolved in the next release." | ||
| ) | ||
|
|
@@ -87,3 +95,56 @@ def validate_inNextRelease(self, value: bool) -> "Release": | |
| raise serializers.ValidationError( | ||
| "No release data present in the system to form a basis for 'Next Release'" | ||
| ) | ||
|
|
||
| def validate_inFutureRelease(self, value: str) -> "Release | None": | ||
| project = self.context["project"] | ||
|
|
||
| if not features.has("organizations:resolve-in-future-release", project.organization): | ||
| raise serializers.ValidationError( | ||
| "Your organization does not have access to this feature." | ||
| ) | ||
|
|
||
| if not Release.is_valid_version(value): | ||
| raise serializers.ValidationError( | ||
| "Invalid release version format. Please use semver format: [email protected][-prerelease][+build]." | ||
| ) | ||
|
|
||
| try: | ||
| # release doesn't have to be semver if it exists | ||
| # because we'll just use the resolveInRelease logic | ||
| release = Release.objects.get( | ||
| projects=project, organization_id=project.organization_id, version=value | ||
| ) | ||
| except Release.DoesNotExist: | ||
| # release must be semver if it doesn't exist | ||
| if not Release.is_semver_version(value): | ||
| raise serializers.ValidationError( | ||
| "Invalid semver format. Please use format: [email protected][-prerelease][+build]" | ||
| ) | ||
| release = None | ||
|
|
||
| return release | ||
|
|
||
| def validate(self, attrs: dict[str, Any]) -> dict[str, Any]: | ||
| """ | ||
| Cross-field validation hook called by DRF after individual field validation. | ||
| """ | ||
| return self._preserve_future_release_version(attrs) | ||
|
|
||
| def _preserve_future_release_version(self, attrs: dict[str, Any]) -> dict[str, Any]: | ||
| """ | ||
| Store the original future release version string for inFutureRelease since the validator | ||
| transforms it to a Release object or None, but we need the version string for | ||
| process_group_resolution. | ||
| """ | ||
| if "inFutureRelease" in attrs: | ||
| initial_data = getattr(self, "initial_data", {}) | ||
| # If this is a nested serializer, try to get the data from the parent's initial_data | ||
| if not initial_data and hasattr(self, "parent"): | ||
| parent_initial_data = getattr(self.parent, "initial_data", {}) | ||
| initial_data = parent_initial_data.get("statusDetails", {}) | ||
|
|
||
| future_release_version = initial_data.get("inFutureRelease") | ||
| if future_release_version: | ||
| attrs["_future_release_version"] = future_release_version | ||
| return attrs | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High severity vulnerability may affect your project—review required:
Line 665 lists a dependency (django) with a known High severity vulnerability.
ℹ️ Why this matters
Affected versions of Django are vulnerable to Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'). SQL injection in Django's ORM column aliases: when using QuerySet.annotate(), QuerySet.alias(), QuerySet.aggregate(), or QuerySet.extra() with dictionary expansion (**kwargs), the dictionary keys are used unescaped as SQL column aliases. On MySQL and MariaDB backends, an attacker who can influence those keys (for example, by passing a crafted dict of annotations) can inject arbitrary SQL into the generated query.
References: GHSA, CVE
To resolve this comment:
Check if you are using Django with MySQL or MariaDB.
/fp we don't use this [condition]💬 Ignore this finding
To ignore this, reply with:
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasonsYou can view more details on this finding in the Semgrep AppSec Platform here.