Skip to content

Commit

Permalink
Skipping CCd users without GAIA accounts for buganizer issues (#4406)
Browse files Browse the repository at this point in the history
### Motivation

oss_fuzz_build_status and oss_fuzz_apply_ccs are broken due to buganizer
rejecting emails without associated accounts. This serves as a
workaround so at least some notifications can suceeed.
(google/oss-fuzz#12536)

### Why this works

Buganizer throws 400 errors listing out all rejected emails in the
exception, so we can just parse the non gaia emails from that and
complete the execution by ignoring those.

### Testing strategy

Ran both cronjobs locally with the proposed new code, and verified they
ran to completion.
  • Loading branch information
vitorguidi authored Nov 15, 2024
1 parent 737b835 commit f918c36
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/clusterfuzz/_internal/cron/oss_fuzz_apply_ccs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def cc_users_for_job(job_type, security_flag):


def main():
"""Cron handler for adding new CC's to oss-fuzz bugs.."""
"""Cron handler for adding new CC's to oss-fuzz bugs."""
some_issue_failed = False
for testcase in get_open_testcases_with_bugs():
issue_tracker = issue_tracker_utils.get_issue_tracker_for_testcase(testcase)
if not issue_tracker:
Expand Down Expand Up @@ -67,7 +68,16 @@ def main():
logging.info('CCing %s on %s', cc, issue.id)
issue.ccs.add(cc)

issue.save(notify=True)
try:
issue.save(notify=True)
except Exception as e:
some_issue_failed = True
logging.error('Failed to apply ccs for test case '
'%s: %s.', testcase.key, e)

if some_issue_failed:
logging.error('OSS fuzz apply ccs failed.')
return False

logging.info('OSS fuzz apply ccs succeeded.')
return True
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import datetime
import enum
import functools
import re
from typing import List
from typing import Optional
from typing import Sequence
Expand Down Expand Up @@ -68,6 +70,24 @@ def _get_access_limit_from_labels(labels: issue_tracker.LabelStore):
return None


def retry_on_invalid_gaia_accounts(func):
"""Decorator to retry saving an issue, skipping CCs
without a GAIA account."""

@functools.wraps(func)
def wrapper(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except Exception as e:
# Try to handle the case where a 400 buganizer response is
# received due to a non gaia email.
email_regex = r'[\w\.\-\+]+@[\w\.-]+'
emails_to_skip = re.findall(email_regex, str(e))
return func(self, *args, **kwargs, skip_emails=emails_to_skip)

return wrapper


class IssueTrackerError(Exception):
"""Base issue tracker error."""

Expand Down Expand Up @@ -719,8 +739,10 @@ def _update_issue(self, new_comment=None, notify=True):
issueId=str(self.id)))
return result

def save(self, new_comment=None, notify=True):
@retry_on_invalid_gaia_accounts
def save(self, new_comment=None, notify=True, skip_emails=[]): # pylint: disable=dangerous-default-value
"""Saves the issue."""
logs.info(f'Skipping supposed non gaia emails emails: {skip_emails}.')
if self._is_new:
logs.info('google_issue_tracker: Creating new issue..')
priority = _extract_label(self.labels, 'Pri-') or _DEFAULT_PRIORITY
Expand Down Expand Up @@ -793,7 +815,9 @@ def save(self, new_comment=None, notify=True):

if self.component_id:
self._data['issueState']['componentId'] = int(self.component_id)
ccs = list(self._ccs)
# TODO(vitorguidi): delete this hack once we have a solution for GAIA.
# Skip CCd users w/o a GAIA account
ccs = list(set(self._ccs) - set(skip_emails))
if ccs:
self._data['issueState']['ccs'] = _make_users(ccs)
collaborators = list(self._collaborators)
Expand Down Expand Up @@ -822,6 +846,10 @@ def save(self, new_comment=None, notify=True):
self._is_new = False
else:
logs.info('google_issue_tracker: Updating issue..')
# TODO(vitorguidi): remove this once we have a fix for GAIA.
# Remove all CCd users w/o GAIA accounts
for email in skip_emails:
self.ccs.remove(email)
result = self._update_issue(new_comment=new_comment, notify=notify)
self._reset_tracking()
self._data = result
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"target": "linux/arm64", "reproduce": false, "workdir": "/home/vitorguidi/projects/clusterfuzz/src/clusterfuzz/_internal/tests/core/bot/fuzzers/syzkaller/input/syzkaller", "http": "localhost:0", "syzkaller": "/home/vitorguidi/projects/clusterfuzz/src/clusterfuzz/_internal/tests/core/bot/fuzzers/syzkaller/build/syzkaller", "suppressions": ["do_rt_sigqueueinfo", "do_rt_tgsigqueueinfo"], "vm": {"devices": ["172.18.0.2:6520"]}, "kernel_obj": "/home/vitorguidi/projects/clusterfuzz/src/clusterfuzz/_internal/tests/core/bot/fuzzers/syzkaller/build", "sandbox": "android", "ignores": ["WARNING:", "INFO:"], "type": "adb", "procs": 1, "cover": true}

0 comments on commit f918c36

Please sign in to comment.