diff --git a/src/clusterfuzz/_internal/cron/cleanup.py b/src/clusterfuzz/_internal/cron/cleanup.py index 891cca6647b..41588ed7a00 100644 --- a/src/clusterfuzz/_internal/cron/cleanup.py +++ b/src/clusterfuzz/_internal/cron/cleanup.py @@ -57,6 +57,9 @@ FUZZ_TARGET_UNUSED_THRESHOLD = 15 UNUSED_HEARTBEAT_THRESHOLD = 15 +VRP_UPLOAD_COMPONENT_ID = 1600865 +CHROMIUM_COMPONENT_ID = 1363614 + ProjectMap = collections.namedtuple('ProjectMap', 'jobs platforms') @@ -1056,6 +1059,18 @@ def update_component_labels_and_id(policy, testcase, issue): component_id = _get_predator_result_item(testcase, 'suspected_buganizer_component_id') + # These bugs were filed via the direct upload and hence specific to the + # google issue tracker. + if getattr(issue, 'component_id', None) == VRP_UPLOAD_COMPONENT_ID: + # Reset the component to the top level for this bug to be triaged properly. + issue.component_id = CHROMIUM_COMPONENT_ID + + # Bugs in the direct upload component are filed as type 'Task'. + if testcase.security_flag: + issue.labels.add('Type-VULNERABILITY') + else: + issue.labels.add('Type-BUG') + # Remove components already in issue or whose more specific variants exist. filtered_components = [] for component in components: diff --git a/src/clusterfuzz/_internal/tests/appengine/handlers/cron/cleanup_test.py b/src/clusterfuzz/_internal/tests/appengine/handlers/cron/cleanup_test.py index 0d2be014646..08ec0108d48 100644 --- a/src/clusterfuzz/_internal/tests/appengine/handlers/cron/cleanup_test.py +++ b/src/clusterfuzz/_internal/tests/appengine/handlers/cron/cleanup_test.py @@ -1494,6 +1494,30 @@ def test_label_added_for_unrelated_component(self): self.assertIn('D', self.issue.components) self.assertIn('Test-Predator-Auto-Components', self.issue.labels) + def test_vrp_security_upload_overrides_bug_type_and_components(self): + """Ensure that the type and component gets reset for a processed VRP direct + uploaded security bug. This test is specific to the Google Issue Tracker.""" + self.testcase.security_flag = True + self.testcase.put() + setattr(self.issue, 'component_id', cleanup.VRP_UPLOAD_COMPONENT_ID) + + cleanup.update_component_labels_and_id( + policy=self.policy, testcase=self.testcase, issue=self.issue) + self.assertIn('Type-VULNERABILITY', self.issue.labels) + self.assertEqual(cleanup.CHROMIUM_COMPONENT_ID, self.issue.component_id) + + def test_vrp_non_security_upload_overrides_bug_type_and_components(self): + """Ensure that the type and component gets reset for a processed VRP direct + uploaded non-security bug. This test is specific to the Google Issue Tracker.""" + self.testcase.security_flag = False + self.testcase.put() + setattr(self.issue, 'component_id', cleanup.VRP_UPLOAD_COMPONENT_ID) + + cleanup.update_component_labels_and_id( + policy=self.policy, testcase=self.testcase, issue=self.issue) + self.assertIn('Type-BUG', self.issue.labels) + self.assertEqual(cleanup.CHROMIUM_COMPONENT_ID, self.issue.component_id) + @test_utils.with_cloud_emulators('datastore') class UpdateIssueCCsFromOwnersFileTest(unittest.TestCase):