Skip to content

Commit abfa5f1

Browse files
authored
Fixed Auto assignment (#102)
* Update 1763927762 * Update 1763931046 * Update 1763932028 * Update 1763941949 * Update 1763943179 * Update 1763946296
1 parent f068aea commit abfa5f1

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

.coderabbit.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
3+
language: 'en-US'
4+
early_access: false
5+
chat:
6+
auto_reply: true
7+
reviews:
8+
profile: 'assertive'
9+
poem: false
10+
request_changes_workflow: true
11+
high_level_summary: true
12+
review_status: true
13+
collapse_walkthrough: false
14+
auto_review:
15+
enabled: true
16+
drafts: false
17+
base_branches:
18+
- develop
19+
- main
20+
path_filters:
21+
- '!**/docs/**'
22+
- '!*.html'
23+
- '!*.md'
24+
- '!*.svg'

.github/workflows/auto-assign.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,50 @@ jobs:
149149
* Author is the owner of the repository.
150150
*/
151151
152+
// Restrict /assign based on issue creator's permissions
153+
// We don't want non repo members using the feature to
154+
// grab assignments from issues created by other non-members
155+
if (isAssign) {
156+
const issueCreator = issue.user.login;
157+
let issueCreatorAssociation;
158+
159+
// Fetch author_association via REST API since it's no longer in event payload
160+
try {
161+
const issueDetails = await github.rest.issues.get({
162+
owner,
163+
repo,
164+
issue_number: issueNumber
165+
});
166+
issueCreatorAssociation = issueDetails.data.author_association;
167+
} catch (error) {
168+
console.error(`Error fetching issue details for #${issueNumber}:`, error);
169+
await github.rest.issues.createComment({
170+
owner,
171+
repo,
172+
issue_number: issueNumber,
173+
body: `❌ Failed to verify issue permissions. Please contact a maintainer or try again later.`,
174+
});
175+
return;
176+
}
177+
console.log(`Issue #${issueNumber} creator ${issueCreator} has association: ${issueCreatorAssociation}`);
178+
179+
// Only allow /assign on issues created by OWNER, MEMBER, COLLABORATOR or CONTRIBUTOR
180+
const allowedAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR', 'CONTRIBUTOR'];
181+
182+
if (!allowedAssociations.includes(issueCreatorAssociation)) {
183+
await github.rest.issues.createComment({
184+
owner,
185+
repo,
186+
issue_number: issueNumber,
187+
body: `❌ @${user} The \`/assign\` feature is only available for issues created by OWNER, MEMBER, COLLABORATOR or CONTRIBUTOR user associations. This issue was created by @${issueCreator} who has the association: ${issueCreatorAssociation}.`,
188+
});
189+
console.log(`Denied /assign for ${user} - Issue creator ${issueCreator} has insufficient association (${issueCreatorAssociation})`);
190+
return;
191+
}
192+
193+
console.log(`Issue creator ${issueCreator} has sufficient association (${issueCreatorAssociation}), allowing /assign for ${user}`);
194+
}
195+
152196
// Log the type of user association
153197
console.log(`Commenting user ${user} is a ${association}`);
154198

0 commit comments

Comments
 (0)