def test_testcase_metadata_invalid(self): """Tests issue filing with invalid metadata.""" itm = IssueTrackerManager('chromium') issue_filer.file_issue(self.testcase6, itm) self.assertListEqual( ['ClusterFuzz', 'Reproducible', 'Pri-1', 'Stability-Crash', 'Type-Bug'], itm.last_issue.labels)
def test_memory_tool_used(self, project_name): """Test memory tool label is correctly set.""" for entry in label_utils.MEMORY_TOOLS_LABELS: itm = IssueTrackerManager(project_name) self.testcase1.crash_stacktrace = '\n\n%s\n' % entry['token'] self.testcase1.put() issue_filer.file_issue(self.testcase1, itm) self.assertIn(entry['label'], itm.last_issue.labels)
def test_security_severity_functional_bug(self, project_name): """Test security severity label is not set for a functional bug.""" itm = IssueTrackerManager(project_name) self.testcase1.security_flag = False self.testcase1.security_severity = None self.testcase1.put() issue_filer.file_issue(self.testcase1, itm) self.assertFalse(itm.last_issue.has_label_by_prefix('Security_Severity-'))
def test_security_severity_security_bug_default_severity(self, project_name): """Test security severity label is set when testcase is a security bug and no severity can be determined.""" itm = IssueTrackerManager(project_name) self.testcase1.security_flag = True self.testcase1.security_severity = None self.testcase1.put() issue_filer.file_issue(self.testcase1, itm) self.assertIn('Security_Severity-High', itm.last_issue.labels) self.assertEqual( 1, len(itm.last_issue.get_labels_by_prefix('Security_Severity-')))
def test_testcase_metadata_labels(self): """Tests issue filing with additional labels.""" itm = IssueTrackerManager('chromium') issue_filer.file_issue(self.testcase5, itm) self.assertListEqual([ 'ClusterFuzz', 'Reproducible', 'Pri-1', 'Stability-Crash', 'Type-Bug', 'label1', 'label2', ], itm.last_issue.labels)
def test_security_severity_security_bug_severity_override(self, project_name): """Test security severity label is set correct when testcase has its own severity but there is an override provided.""" itm = IssueTrackerManager(project_name) self.testcase1.security_flag = True self.testcase1.security_severity = data_types.SecuritySeverity.HIGH self.testcase1.put() issue_filer.file_issue( self.testcase1, itm, security_severity=data_types.SecuritySeverity.MEDIUM) self.assertNotIn('Security_Severity-High', itm.last_issue.labels) self.assertIn('Security_Severity-Medium', itm.last_issue.labels) self.assertEqual( 1, len(itm.last_issue.get_labels_by_prefix('Security_Severity-')))
def test_security_severity_security_bug_with_severity_set(self, project_name): """Test security severity label is set when testcase is a security bug and has a security severity.""" security_severity_string_map = { data_types.SecuritySeverity.HIGH: 'Security_Severity-High', data_types.SecuritySeverity.MEDIUM: 'Security_Severity-Medium', data_types.SecuritySeverity.LOW: 'Security_Severity-Low', } for security_severity in security_severity_string_map: itm = IssueTrackerManager(project_name) self.testcase1.security_flag = True self.testcase1.security_severity = security_severity self.testcase1.put() issue_filer.file_issue(self.testcase1, itm) self.assertIn(security_severity_string_map[security_severity], itm.last_issue.labels) self.assertEqual( 1, len(itm.last_issue.get_labels_by_prefix('Security_Severity-')))
def create_issue(testcase, severity, cc_me): """Create an issue.""" itm = helpers.get_issue_tracker_manager(testcase) user_email = helpers.get_user_email() if severity is not None: severity = helpers.cast( severity, int, 'Invalid value for security severity (%s).' % severity) additional_ccs = [] if cc_me == 'true': additional_ccs.append(user_email) issue_id = issue_filer.file_issue(testcase, itm, security_severity=severity, user_email=user_email, additional_ccs=additional_ccs) if not issue_id: raise helpers.EarlyExitException('Unable to create new issue.', 500)
def test_filed_issues_oss_fuzz(self): """Tests issue filing for oss-fuzz.""" itm = IssueTrackerManager('oss-fuzz') issue_filer.file_issue(self.testcase1, itm) self.assertTrue(itm.last_issue.has_label_matching('restrict-view-commit')) self.assertFalse(itm.last_issue.has_label_matching('reported-2016-01-01')) self.assertNotIn(issue_filer.DEADLINE_NOTE, itm.last_issue.body) issue_filer.file_issue(self.testcase1_security, itm) self.assertTrue(itm.last_issue.has_label_matching('restrict-view-commit')) self.assertFalse(itm.last_issue.has_label_matching('reported-2016-01-01')) self.assertNotIn(issue_filer.DEADLINE_NOTE, itm.last_issue.body) issue_filer.file_issue(self.testcase2, itm) self.assertFalse(itm.last_issue.has_label_matching('restrict-view-commit')) self.assertTrue(itm.last_issue.has_label_matching('reported-2016-01-01')) self.assertNotIn(issue_filer.DEADLINE_NOTE, itm.last_issue.body) issue_filer.file_issue(self.testcase2_security, itm) self.assertTrue(itm.last_issue.has_label_matching('restrict-view-commit')) self.assertTrue(itm.last_issue.has_label_matching('reported-2016-01-01')) self.assertIn(issue_filer.DEADLINE_NOTE, itm.last_issue.body) issue_filer.file_issue(self.testcase3, itm) self.assertFalse(itm.last_issue.has_label_matching('restrict-view-commit')) self.assertFalse(itm.last_issue.has_label_matching('reported-2016-01-01')) self.assertNotIn(issue_filer.DEADLINE_NOTE, itm.last_issue.body) issue_filer.file_issue(self.testcase3_security, itm) self.assertFalse(itm.last_issue.has_label_matching('restrict-view-commit')) self.assertTrue(itm.last_issue.has_label_matching('reported-2016-01-01')) self.assertNotIn(issue_filer.DEADLINE_NOTE, itm.last_issue.body)
def test_filed_issues_chromium(self): """Tests issue filing for chromium.""" itm = IssueTrackerManager('chromium') issue_filer.file_issue(self.testcase4, itm) self.assertIn('OS-Chrome', itm.last_issue.labels)
def get(self): """Handle a get request.""" try: grouper.group_testcases() except: logs.log_error('Error occurred while grouping test cases.') return # Free up memory after group task run. utils.python_gc() # Get list of jobs excluded from bug filing. excluded_jobs = get_excluded_jobs() for testcase_id in data_handler.get_open_testcase_id_iterator(): try: testcase = data_handler.get_testcase_by_id(testcase_id) except errors.InvalidTestcaseError: # Already deleted. continue # Skip if testcase's job type is in exclusions list. if testcase.job_type in excluded_jobs: continue # If the testcase has a bug filed already, no triage is needed. if is_bug_filed(testcase): continue # Check if the crash is important, i.e. it is either a reproducible crash # or an unreproducible crash happening frequently. if not is_crash_important(testcase): continue # Require that all tasks like minimizaton, regression testing, etc have # finished. if not data_handler.critical_tasks_completed(testcase): continue # For testcases that are not part of a group, wait an additional time till # group task completes. # FIXME: In future, grouping might be dependent on regression range, so we # would have to add an additional wait time. if not testcase.group_id and not dates.time_has_expired( testcase.timestamp, hours=data_types.MIN_ELAPSED_TIME_SINCE_REPORT): continue # If this project does not have an associated issue tracker, we cannot # file this crash anywhere. issue_tracker_manager = issue_tracker_utils.get_issue_tracker_manager( testcase, use_cache=True) if not issue_tracker_manager: continue # If there are similar issues to this test case already filed or recently # closed, skip filing a duplicate bug. if is_similar_bug_open_or_recently_closed(testcase, issue_tracker_manager): continue # File the bug first and then create filed bug metadata. issue_filer.file_issue(testcase, issue_tracker_manager) create_filed_bug_metadata(testcase) logs.log('Filed new issue %s for testcase %d.' % (testcase.bug_information, testcase_id))