You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug 2079840 - allow @username in the textarea like github - #2776
Bug 2079840 - Support GitHub-style @Nickname mentions to needinfo and CC users
Summary
When a user with editbugs adds a comment to an existing bug that contains @nickname, each mentioned user is CC'd and gets a needinfo request. Several mentions in one comment (@alice, @bob) each get a needinfo. Safeguards limit who can trigger mentions, how many are processed, and make sure a mention never grants access to a restricted bug.
Behavior
Matching: a mention matches the profile nickname field of an enabled account. If a nickname matches several accounts, or none, it is skipped silently. It is never guessed.
Ignored: email addresses (foo@example.com), quoted lines (> ...), inline code (any number of backticks), fenced code blocks, and mentioning yourself.
Needinfo vs CC: mentioned users are always CC'd. The needinfo is skipped if the user blocks needinfo or already has a needinfo pending. If a site's needinfo type is not multiplicable, at most one needinfo is requested.
Never blocks saving: each mentioned user is processed in an eval under ERROR_MODE_DIE. A failure, such as add_cc's strict_isolation check, skips that user and logs a WARN instead of rolling back the comment.
Private comments: a mention that appears only in private comments counts only if that user is an insider.
Scope: only comments added to existing bugs. The description of a new bug is not parsed.
Mass edit: mentions are processed on every bug in a mass edit.
Safeguards
Only editbugs users trigger mentions (product-specific, the same check core uses). For everyone else, @nickname is plain text, so there is no lookup, CC or needinfo.
At most 10 mentions per update: only the first 10 distinct nicknames are processed (MAX_MENTIONS), and the rest are ignored. This prevents notification spam from one comment.
No access by mention: mentioned users who cannot already see the bug are skipped entirely, with no CC and no needinfo. A typo, or a nickname someone else has claimed (squatting), can never expose a security bug.
Implementation
extensions/Needinfo/Extension.pm
The needinfo flag type is now created with is_multiplicable => 1, matching production. This only affects new installs.
bug_start_of_update now calls the existing form handling (moved unchanged into _process_needinfo_params), then _process_mentions. Mentions run second, so a needinfo just requested through the form is detected and not duplicated.
_extract_mentions parses the comment text. It is a pure function covered by unit tests.
_users_for_mentions resolves nicknames with one query and drops nicknames shared by more than one account.
_process_mentions applies the safeguards. Updates with no mentions return before any database work.
_cc_and_needinfo adds the CC and needinfo for one user.
extensions/Needinfo/t/mentions.t
Parser tests.
Behavior tests for CC plus needinfo, skipping yourself, skipping users who can't see the bug, the cap of 10, the editbugs gate, non-multiplicable types, no duplicate needinfo, and a failing CC not throwing.
Known limitations
Mentions are parsed with regexes, not the Markdown renderer, so indented code blocks and HTML <code> are not ignored.
_users_for_mentions (one SQL query) has no unit test.
Unknown or ambiguous nicknames count toward the cap of 10.
Testing
test_sanity: extensions/Needinfo/t/mentions.t, t/001compile.t, t/002goodperl.t, t/005whitespace.t, t/critic.t all pass.
Not yet covered: webservices or Selenium tests, and a manual check in the dev stack.
…fo and CC users
Each @Nickname in a new comment on an existing bug CCs the matching user
and requests needinfo from them. Mentions in quotes, code and email
addresses are ignored, ambiguous nicknames are skipped, and a mention
never blocks the comment from being saved.
Only editbugs users can trigger mentions, at most 10 distinct nicknames
are processed per update, and mentioned users who cannot already see the
bug are skipped so a mention, typo or squatted nickname never grants
access to a restricted bug.
- Create the needinfo flag type as multiplicable, matching production.
- With a non-multiplicable needinfo type, request at most one needinfo
instead of throwing flag_type_not_multiplicable.
- Process each mentioned user in an eval under ERROR_MODE_DIE so a failure
(e.g. add_cc's strict_isolation check) skips that user instead of rolling
back the update.
- Ignore mentions in multi-backtick code spans and allow | in nicknames,
matching extract_nicks.
The reason will be displayed to describe this comment to others. Learn more.
Thanks Dave! Just one issue with the "no access by mention" safeguard when groups change in the same update, one question about API/bot comments, and a small test addition. The rest looks good to me.
Require valid closing fences during code extraction
extensions/Needinfo/Extension.pm:274
The closing-fence matcher accepts arbitrary trailing text. For ~~~text\n@before\n~~~not-a-closing-fence\n@inside\n~~~\n\n@after, extraction returns inside instead of after, potentially notifying someone mentioned only inside code. Require a closing run of the same fence character, at least as long as the opener, followed only by whitespace. Add a regression test for a fence-like line with trailing text.
Preserve mention boundaries when removing inline code
extensions/Needinfo/Extension.pm:277
Removing an inline code span joins the surrounding text: @alice`code`bob becomes @alicebob, potentially notifying the wrong account. Likewise, foo`code`@alice loses the mention. Replace removed spans with whitespace to preserve token boundaries, and add regression tests for both cases.
Use case-insensitive nickname matching consistently
extensions/Needinfo/Extension.pm:299
_mentioned_users lowercases every nickname, but this query compares against the original column. On case-sensitive backends such as PostgreSQL, nickname Alice cannot be mentioned even as @Alice. If both Alice and alice exist, only the latter is returned, bypassing the ambiguity safeguard. Use sql_istring for the column and lowercase the requested values so lookup and ambiguity detection agree.
Reject accent-insensitive nickname mismatches
extensions/Needinfo/Extension.pm:302
The MySQL collation (Bugzilla/DB/Mysql.pm:818–820) is accent-insensitive, so querying @jose can return an account named josé. Grouping by lowercase does not reject that unmentioned nickname, and _mentioned_users accepts it if the account is an insider and passes the visibility checks. This can CC and request needinfo from the wrong user. Filter returned rows against the requested lowercase nicknames before resolving accounts.
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
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.
Bug 2079840 - Support GitHub-style @Nickname mentions to needinfo and CC users
Summary
When a user with
editbugsadds a comment to an existing bug that contains@nickname, each mentioned user is CC'd and gets a needinfo request. Several mentions in one comment (@alice, @bob) each get a needinfo. Safeguards limit who can trigger mentions, how many are processed, and make sure a mention never grants access to a restricted bug.Behavior
nicknamefield of an enabled account. If a nickname matches several accounts, or none, it is skipped silently. It is never guessed.foo@example.com), quoted lines (> ...), inline code (any number of backticks), fenced code blocks, and mentioning yourself.ERROR_MODE_DIE. A failure, such asadd_cc's strict_isolation check, skips that user and logs a WARN instead of rolling back the comment.Safeguards
editbugsusers trigger mentions (product-specific, the same check core uses). For everyone else,@nicknameis plain text, so there is no lookup, CC or needinfo.MAX_MENTIONS), and the rest are ignored. This prevents notification spam from one comment.Implementation
extensions/Needinfo/Extension.pmneedinfoflag type is now created withis_multiplicable => 1, matching production. This only affects new installs.bug_start_of_updatenow calls the existing form handling (moved unchanged into_process_needinfo_params), then_process_mentions. Mentions run second, so a needinfo just requested through the form is detected and not duplicated._extract_mentionsparses the comment text. It is a pure function covered by unit tests._users_for_mentionsresolves nicknames with one query and drops nicknames shared by more than one account._process_mentionsapplies the safeguards. Updates with no mentions return before any database work._cc_and_needinfoadds the CC and needinfo for one user.extensions/Needinfo/t/mentions.teditbugsgate, non-multiplicable types, no duplicate needinfo, and a failing CC not throwing.Known limitations
<code>are not ignored._users_for_mentions(one SQL query) has no unit test.Testing
test_sanity:extensions/Needinfo/t/mentions.t,t/001compile.t,t/002goodperl.t,t/005whitespace.t,t/critic.tall pass.