Skip to content

Restrict Hackbot triggers to authorized user with editbugs permissions - #6444

Open
ayoubdiourin7 wants to merge 3 commits into
mozilla:masterfrom
ayoubdiourin7:feat/hackbot-editbugs-auth-clean
Open

Restrict Hackbot triggers to authorized user with editbugs permissions#6444
ayoubdiourin7 wants to merge 3 commits into
mozilla:masterfrom
ayoubdiourin7:feat/hackbot-editbugs-auth-clean

Conversation

@ayoubdiourin7

@ayoubdiourin7 ayoubdiourin7 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Changes

  • Check the author of each @hackbot comment.
  • Process comments only from users authorized to edit revisions.
  • Ignore comments from unauthorized users before creating a Hackbot run.
  • Add test coverage for authorized, unauthorized

Resolves #6423

@ayoubdiourin7
ayoubdiourin7 requested a review from a team as a code owner July 31, 2026 14:24
matches.append(
HackbotMention(
raw=raw,
author_phid=transaction.get("authorPHID", ""),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do not think there is a comment transaction without authorPHID, if that is a possibility, we should skip the transaction altogether.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated in ef9701c

)
return None

authorized_members = await client.get_project_members(EDITBUGS_GROUP_PHID)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We might want to implement TTL cache, and re-fetch if a user is not exist in the list. So we optimize for the happy path. We could do it now or file a follow up issue and we do it later.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I added a TTL cache for it in 8ae7728

Comment on lines +143 to +155
comments: list[str] = []
for mention in mentions:
if mention.author_phid in authorized_members:
comments.append(mention.raw)
else:
log.warning(
"Ignoring %s mention from non-editbugs user %s on %s",
webhook.mention_token,
mention.author_phid or "<missing PHID>",
object_phid,
)
if not comments:
return None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would move this before No %s mention found in triggering, so we have only one check for the comments.

@ayoubdiourin7
ayoubdiourin7 force-pushed the feat/hackbot-editbugs-auth-clean branch from 28a08b1 to 1f5820a Compare August 1, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Control who can trigger Hackbot from a Phabricator comment

2 participants