|
| 1 | +# Copyright 2022 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +"""backfiler.py queries past testcases of the given projects |
| 15 | + and filed them to the projects' GitHub repository.""" |
| 16 | + |
| 17 | +from clusterfuzz._internal.datastore import data_types |
| 18 | +from clusterfuzz._internal.datastore import ndb_utils |
| 19 | +from libs.issue_management import oss_fuzz_github |
| 20 | + |
| 21 | + |
| 22 | +def execute(args): |
| 23 | + """Query Testcases of the given projects, |
| 24 | + and conditionally file them to the corresponding GitHub repo.""" |
| 25 | + if not args.script_args: |
| 26 | + print('Need at least one project name (with -p) ' |
| 27 | + 'when running the backfiler.') |
| 28 | + return |
| 29 | + for project_name in args.script_args: |
| 30 | + print(f'Back filing project {project_name}') |
| 31 | + for testcase in data_types.Testcase.query( |
| 32 | + ndb_utils.is_true(data_types.Testcase.open), |
| 33 | + ndb_utils.is_false(data_types.Testcase.one_time_crasher_flag), |
| 34 | + data_types.Testcase.status == 'Processed', |
| 35 | + data_types.Testcase.project_name == project_name, |
| 36 | + ): |
| 37 | + if not testcase.bug_information: |
| 38 | + print(f'Skip testcase without bugs: {testcase.key.id()}') |
| 39 | + continue |
| 40 | + print(f'Back filing testcase id: {testcase.key.id()}') |
| 41 | + if args.non_dry_run: |
| 42 | + oss_fuzz_github.file_issue(testcase) |
0 commit comments