|
21 | 21 | import json |
22 | 22 | import subprocess |
23 | 23 |
|
24 | | -import requests |
25 | | - |
26 | 24 | import bad_patch |
27 | 25 | import logic_error_patch |
28 | 26 |
|
29 | 27 | logger = logging.getLogger(__name__) |
30 | 28 |
|
31 | | -OSS_FUZZ_BUILD_HISTORY_URL = ( |
32 | | - 'https://oss-fuzz-build-logs.storage.googleapis.com/status.json') |
33 | | -OSS_FUZZ_BUILD_HISTORY = [] |
34 | | - |
35 | | -RUN_TEST_HEURISTIC_0 = 'make test' |
36 | | -RUN_TEST_HEURISTIC_1 = 'make tests' |
37 | | -RUN_TEST_HEURISTIC_2 = 'make check' |
38 | | - |
39 | | -RUN_TESTS_TO_TRY = [ |
40 | | - RUN_TEST_HEURISTIC_0, RUN_TEST_HEURISTIC_1, RUN_TEST_HEURISTIC_2 |
41 | | -] |
42 | | - |
43 | | - |
44 | | -def _get_oss_fuzz_build_status(project): |
45 | | - """Returns the build status of a project in OSS-Fuzz.""" |
46 | | - if not OSS_FUZZ_BUILD_HISTORY: |
47 | | - # Load the build history from a file or other source. |
48 | | - # This is a placeholder for actual implementation. |
49 | | - build_status = requests.get(OSS_FUZZ_BUILD_HISTORY_URL, timeout=30) |
50 | | - OSS_FUZZ_BUILD_HISTORY.extend( |
51 | | - json.loads(build_status.text).get('projects', [])) |
52 | | - |
53 | | - for project_data in OSS_FUZZ_BUILD_HISTORY: |
54 | | - if project_data['name'] == project: |
55 | | - logger.info('Found project %s in OSS-Fuzz build history.', project) |
56 | | - return project_data.get('history', [{ |
57 | | - 'success': False |
58 | | - }])[0].get('success', False) |
59 | | - |
60 | | - logger.info('Project %s not found in OSS-Fuzz build history.', project) |
61 | | - return False |
62 | | - |
63 | | - |
64 | 29 | def _get_project_cached_named(project, sanitizer='address'): |
65 | 30 | """Gets the name of the cached project image.""" |
66 | 31 | return f'us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/{project}-ofg-cached-{sanitizer}' |
@@ -394,25 +359,6 @@ def check_run_tests_script(project, |
394 | 359 | 'Error: %s run_test.sh does alter files or directories content.', |
395 | 360 | project) |
396 | 361 |
|
397 | | - |
398 | | -def _get_project_language(project): |
399 | | - """Returns the language of the project.""" |
400 | | - project_path = os.path.join('projects', project) |
401 | | - if not os.path.isdir(project_path): |
402 | | - return '' |
403 | | - |
404 | | - # Check for a .lang file or similar to determine the language |
405 | | - project_yaml = os.path.join(project_path, 'project.yaml') |
406 | | - if os.path.exists(project_yaml): |
407 | | - with open(project_yaml, 'r', encoding='utf-8') as f: |
408 | | - for line in f: |
409 | | - if 'language' in line: |
410 | | - return line.split(':')[1].strip() |
411 | | - |
412 | | - # Default to C++ if no specific language file is found |
413 | | - return '' |
414 | | - |
415 | | - |
416 | 362 | def extract_test_coverage(project): |
417 | 363 | """Extract code coverage report from run_tests.sh script.""" |
418 | 364 | build_project_image(project) |
|
0 commit comments