Skip to content

Commit 4738a5e

Browse files
authoredMar 7, 2025··
Merge branch 'dev' into generic-webhook
2 parents 6381f30 + 9210d44 commit 4738a5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1918
-291
lines changed
 

‎SECURITY.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Instead, please report them via:
2020
- Please provide detailed reports with reproducible steps
2121
- Include the version/commit hash where you discovered the vulnerability
2222
- Allow us a 90-day security fix window before any public disclosure
23+
- After patch is released, allow 30 days for users to update before public disclosure (for a total of 120 days max between update time and fix time)
2324
- Share any potential mitigations or workarounds if known
2425

2526
## Supported Versions

‎autogpt_platform/backend/backend/blocks/github/_api.py

+53
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,59 @@ def _get_headers(credentials: GithubCredentials) -> dict[str, str]:
3838
}
3939

4040

41+
def convert_comment_url_to_api_endpoint(comment_url: str) -> str:
42+
"""
43+
Converts a GitHub comment URL (web interface) to the appropriate API endpoint URL.
44+
45+
Handles:
46+
1. Issue/PR comments: #issuecomment-{id}
47+
2. PR review comments: #discussion_r{id}
48+
49+
Returns the appropriate API endpoint path for the comment.
50+
"""
51+
# First, check if this is already an API URL
52+
parsed_url = urlparse(comment_url)
53+
if parsed_url.hostname == "api.github.com":
54+
return comment_url
55+
56+
# Replace pull with issues for comment endpoints
57+
if "/pull/" in comment_url:
58+
comment_url = comment_url.replace("/pull/", "/issues/")
59+
60+
# Handle issue/PR comments (#issuecomment-xxx)
61+
if "#issuecomment-" in comment_url:
62+
base_url, comment_part = comment_url.split("#issuecomment-")
63+
comment_id = comment_part
64+
65+
# Extract repo information from base URL
66+
parsed_url = urlparse(base_url)
67+
path_parts = parsed_url.path.strip("/").split("/")
68+
owner, repo = path_parts[0], path_parts[1]
69+
70+
# Construct API URL for issue comments
71+
return (
72+
f"https://api.github.com/repos/{owner}/{repo}/issues/comments/{comment_id}"
73+
)
74+
75+
# Handle PR review comments (#discussion_r)
76+
elif "#discussion_r" in comment_url:
77+
base_url, comment_part = comment_url.split("#discussion_r")
78+
comment_id = comment_part
79+
80+
# Extract repo information from base URL
81+
parsed_url = urlparse(base_url)
82+
path_parts = parsed_url.path.strip("/").split("/")
83+
owner, repo = path_parts[0], path_parts[1]
84+
85+
# Construct API URL for PR review comments
86+
return (
87+
f"https://api.github.com/repos/{owner}/{repo}/pulls/comments/{comment_id}"
88+
)
89+
90+
# If no specific comment identifiers are found, use the general URL conversion
91+
return _convert_to_api_url(comment_url)
92+
93+
4194
def get_api(
4295
credentials: GithubCredentials | GithubFineGrainedAPICredentials,
4396
convert_urls: bool = True,

0 commit comments

Comments
 (0)
Please sign in to comment.