-
Notifications
You must be signed in to change notification settings - Fork 524
feat(integrations): Azure DevOps browse endpoints (PR 5/N) #7629
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9c7bb3d
docs(superpowers): add PR 5 implementation plan for Azure DevOps inte…
asaphko fb00ec5
feat(integrations): add TypedDicts for Azure DevOps browse responses
asaphko 43c44fc
feat(integrations): add list_repositories to the Azure DevOps client
asaphko f07e7bd
feat(integrations): add list_pull_requests to the Azure DevOps client
asaphko 41d8b7d
feat(integrations): add list_work_items to the Azure DevOps client
asaphko 5b3b000
feat(integrations): add Azure DevOps browse query-param serializers
asaphko ed621f7
feat(integrations): add Azure DevOps browse views (no URL wiring yet)
asaphko 4f30297
feat(integrations): wire Azure DevOps browse URLs
asaphko bed431a
fix(integrations): catch ADO NotFound, validate work-item token, cove…
asaphko 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,37 @@ | ||
| from integrations.azure_devops.client.api import list_projects | ||
| from integrations.azure_devops.client.api import ( | ||
| list_projects, | ||
| list_pull_requests, | ||
| list_repositories, | ||
| list_work_items, | ||
| ) | ||
| from integrations.azure_devops.client.exceptions import ( | ||
| AzureDevOpsAuthError, | ||
| AzureDevOpsError, | ||
| AzureDevOpsNotFoundError, | ||
| ) | ||
| from integrations.azure_devops.client.types import AdoProject, AdoProjectsPage | ||
| from integrations.azure_devops.client.types import ( | ||
| AdoProject, | ||
| AdoProjectsPage, | ||
| AdoPullRequest, | ||
| AdoPullRequestsPage, | ||
| AdoRepository, | ||
| AdoWorkItem, | ||
| AdoWorkItemsPage, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "AdoProject", | ||
| "AdoProjectsPage", | ||
| "AdoPullRequest", | ||
| "AdoPullRequestsPage", | ||
| "AdoRepository", | ||
| "AdoWorkItem", | ||
| "AdoWorkItemsPage", | ||
| "AzureDevOpsAuthError", | ||
| "AzureDevOpsError", | ||
| "AzureDevOpsNotFoundError", | ||
| "list_projects", | ||
| "list_pull_requests", | ||
| "list_repositories", | ||
| "list_work_items", | ||
| ] |
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
File renamed without changes.
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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| from rest_framework import serializers | ||
|
|
||
| _PR_STATE_CHOICES = ("active", "completed", "abandoned", "all") | ||
|
|
||
|
|
||
| class AdoBrowseQueryParamsSerializer(serializers.Serializer[None]): | ||
| top = serializers.IntegerField(default=100, min_value=1, max_value=200) | ||
| continuation_token = serializers.CharField(required=False, allow_blank=True) | ||
|
|
||
|
|
||
| class AdoRepositoriesQueryParamsSerializer(AdoBrowseQueryParamsSerializer): | ||
| ado_project_id = serializers.CharField() | ||
|
|
||
|
|
||
| class AdoPullRequestsQueryParamsSerializer(AdoRepositoriesQueryParamsSerializer): | ||
| state = serializers.ChoiceField(choices=_PR_STATE_CHOICES, default="active") | ||
|
|
||
|
|
||
| class AdoWorkItemsQueryParamsSerializer(AdoRepositoriesQueryParamsSerializer): | ||
| # Override the base CharField — the work-items client interprets the | ||
| # token as a non-negative integer offset into the WIQL ID list. | ||
| # Validating here prevents negative-slice leaks and ValueErrors. | ||
| # The ignore below is for the intentional field-type narrowing; DRF | ||
| # supports replacing inherited field types but Mypy flags the variance. | ||
| continuation_token = serializers.IntegerField( # type: ignore[assignment] | ||
| required=False, min_value=0 | ||
| ) | ||
| search_text = serializers.CharField(required=False, allow_blank=True) | ||
| state = serializers.CharField(required=False, allow_blank=True) | ||
| work_item_type = serializers.CharField(required=False, allow_blank=True) | ||
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,5 +1,17 @@ | ||
| from integrations.azure_devops.views.browse_azure_devops import ( | ||
| BrowseAdoProjects, | ||
| BrowseAdoPullRequests, | ||
| BrowseAdoRepositories, | ||
| BrowseAdoWorkItems, | ||
| ) | ||
| from integrations.azure_devops.views.configuration import ( | ||
| AzureDevOpsConfigurationViewSet, | ||
| ) | ||
|
|
||
| __all__ = ["AzureDevOpsConfigurationViewSet"] | ||
| __all__ = [ | ||
| "AzureDevOpsConfigurationViewSet", | ||
| "BrowseAdoProjects", | ||
| "BrowseAdoPullRequests", | ||
| "BrowseAdoRepositories", | ||
| "BrowseAdoWorkItems", | ||
| ] |
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.
Security Vulnerability: Path Traversal in
ado_project_idThe
ado_project_idquery parameter is interpolated directly into the Azure DevOps API request paths (e.g.,f"{ado_project_id}/_apis/git/repositories"). Since there is no validation onado_project_id, an attacker with access to the browse endpoints could pass path traversal sequences (such as../../) to manipulate the request URL. This would allow them to perform unauthorized API requests against other organizations or projects using the stored Personal Access Token (PAT).Remediation:
Add a
RegexValidatortoado_project_idinAdoRepositoriesQueryParamsSerializerto ensure it does not contain slashes (/) or backslashes (\\), which are forbidden in valid Azure DevOps project IDs and names anyway.