Beispiel #1
0
    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:
            issue_tracker = monorail.IssueTracker(
                IssueTrackerManager(project_name))

            self.testcase1.security_flag = True
            self.testcase1.security_severity = security_severity
            self.testcase1.put()

            issue_filer.file_issue(self.testcase1, issue_tracker)
            self.assertIn(security_severity_string_map[security_severity],
                          issue_tracker._itm.last_issue.labels)
            self.assertEqual(
                1,
                len(
                    issue_tracker._itm.last_issue.get_labels_by_prefix(
                        'Security_Severity-')))
Beispiel #2
0
 def test_testcase_metadata_invalid(self):
     """Tests issue filing with invalid metadata."""
     issue_tracker = monorail.IssueTracker(IssueTrackerManager('chromium'))
     issue_filer.file_issue(self.testcase6, issue_tracker)
     self.assertItemsEqual([
         'ClusterFuzz', 'Reproducible', 'Pri-1', 'Stability-Crash',
         'Type-Bug'
     ], issue_tracker._itm.last_issue.labels)
Beispiel #3
0
    def test_memory_tool_used(self, project_name):
        """Test memory tool label is correctly set."""
        for entry in label_utils.MEMORY_TOOLS_LABELS:
            issue_tracker = monorail.IssueTracker(
                IssueTrackerManager(project_name))

            self.testcase1.crash_stacktrace = '\n\n%s\n' % entry['token']
            self.testcase1.put()
            issue_filer.file_issue(self.testcase1, issue_tracker)
            self.assertIn(entry['label'], issue_tracker._itm.last_issue.labels)
Beispiel #4
0
    def test_security_severity_functional_bug(self, project_name):
        """Test security severity label is not set for a functional bug."""
        issue_tracker = monorail.IssueTracker(
            IssueTrackerManager(project_name))

        self.testcase1.security_flag = False
        self.testcase1.security_severity = None
        self.testcase1.put()
        issue_filer.file_issue(self.testcase1, issue_tracker)
        self.assertFalse(
            issue_tracker._itm.last_issue.has_label_by_prefix(
                'Security_Severity-'))
Beispiel #5
0
    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."""
        issue_tracker = monorail.IssueTracker(
            IssueTrackerManager(project_name))

        self.testcase1.security_flag = True
        self.testcase1.security_severity = None
        self.testcase1.put()
        issue_filer.file_issue(self.testcase1, issue_tracker)
        self.assertIn('Security_Severity-High',
                      issue_tracker._itm.last_issue.labels)
        self.assertEqual(
            1,
            len(
                issue_tracker._itm.last_issue.get_labels_by_prefix(
                    'Security_Severity-')))
Beispiel #6
0
    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."""
        issue_tracker = monorail.IssueTracker(
            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,
            issue_tracker,
            security_severity=data_types.SecuritySeverity.MEDIUM)
        self.assertNotIn('Security_Severity-High',
                         issue_tracker._itm.last_issue.labels)
        self.assertIn('Security_Severity-Medium',
                      issue_tracker._itm.last_issue.labels)
        self.assertEqual(
            1,
            len(
                issue_tracker._itm.last_issue.get_labels_by_prefix(
                    'Security_Severity-')))
Beispiel #7
0
  def create_issue(testcase, severity, cc_me):
    """Create an issue."""
    issue_tracker = helpers.get_issue_tracker_for_testcase(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,
        issue_tracker,
        security_severity=severity,
        user_email=user_email,
        additional_ccs=additional_ccs)

    if not issue_id:
      raise helpers.EarlyExitException('Unable to create new issue.', 500)
Beispiel #8
0
    def test_filed_issues_oss_fuzz(self):
        """Tests issue filing for oss-fuzz."""
        issue_tracker = monorail.IssueTracker(IssueTrackerManager('oss-fuzz'))
        issue_filer.file_issue(self.testcase1, issue_tracker)
        self.assertTrue(
            issue_tracker._itm.last_issue.has_label_matching(
                'restrict-view-commit'))
        self.assertFalse(
            issue_tracker._itm.last_issue.has_label_matching(
                'reported-2016-01-01'))
        self.assertNotIn(issue_filer.DEADLINE_NOTE,
                         issue_tracker._itm.last_issue.body)

        issue_filer.file_issue(self.testcase1_security, issue_tracker)
        self.assertTrue(
            issue_tracker._itm.last_issue.has_label_matching(
                'restrict-view-commit'))
        self.assertFalse(
            issue_tracker._itm.last_issue.has_label_matching(
                'reported-2016-01-01'))
        self.assertNotIn(issue_filer.DEADLINE_NOTE,
                         issue_tracker._itm.last_issue.body)

        issue_filer.file_issue(self.testcase2, issue_tracker)
        self.assertFalse(
            issue_tracker._itm.last_issue.has_label_matching(
                'restrict-view-commit'))
        self.assertTrue(
            issue_tracker._itm.last_issue.has_label_matching(
                'reported-2016-01-01'))
        self.assertNotIn(issue_filer.DEADLINE_NOTE,
                         issue_tracker._itm.last_issue.body)

        issue_filer.file_issue(self.testcase2_security, issue_tracker)
        self.assertTrue(
            issue_tracker._itm.last_issue.has_label_matching(
                'restrict-view-commit'))
        self.assertTrue(
            issue_tracker._itm.last_issue.has_label_matching(
                'reported-2016-01-01'))
        self.assertIn(issue_filer.DEADLINE_NOTE,
                      issue_tracker._itm.last_issue.body)

        issue_filer.file_issue(self.testcase3, issue_tracker)
        self.assertFalse(
            issue_tracker._itm.last_issue.has_label_matching(
                'restrict-view-commit'))
        self.assertFalse(
            issue_tracker._itm.last_issue.has_label_matching(
                'reported-2016-01-01'))
        self.assertNotIn(issue_filer.DEADLINE_NOTE,
                         issue_tracker._itm.last_issue.body)

        issue_filer.file_issue(self.testcase3_security, issue_tracker)
        self.assertFalse(
            issue_tracker._itm.last_issue.has_label_matching(
                'restrict-view-commit'))
        self.assertTrue(
            issue_tracker._itm.last_issue.has_label_matching(
                'reported-2016-01-01'))
        self.assertNotIn(issue_filer.DEADLINE_NOTE,
                         issue_tracker._itm.last_issue.body)
Beispiel #9
0
 def test_filed_issues_chromium(self):
     """Tests issue filing for chromium."""
     issue_tracker = monorail.IssueTracker(IssueTrackerManager('chromium'))
     issue_filer.file_issue(self.testcase4, issue_tracker)
     self.assertIn('OS-Chrome', issue_tracker._itm.last_issue.labels)