Skip to content

Commit 2cc3251

Browse files
authored
Merge branch 'master' into fluentd_removal
2 parents 8f7c8b7 + 9ca3802 commit 2cc3251

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

src/clusterfuzz/_internal/bot/fuzzers/afl/launcher.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
4444
from clusterfuzz._internal.fuzzing import strategy
4545
from clusterfuzz._internal.metrics import logs
46-
from clusterfuzz._internal.metrics import profiler
4746
from clusterfuzz._internal.platforms import android
4847
from clusterfuzz._internal.system import environment
4948
from clusterfuzz._internal.system import new_process
@@ -1661,7 +1660,6 @@ def main(argv):
16611660
# same python process.
16621661
logs.configure('run_fuzzer')
16631662
_verify_system_config()
1664-
profiler.start_if_needed('afl_launcher')
16651663

16661664
build_directory = environment.get_value('BUILD_DIR')
16671665
fuzzer_path = engine_common.find_fuzzer_path(build_directory, target_name)

src/clusterfuzz/_internal/bot/fuzzers/centipede/engine.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ def _parse_centipede_logs(log_lines: List[str]) -> Dict[str, int]:
147147
class Engine(engine.Engine):
148148
"""Centipede engine implementation."""
149149

150-
def __init__(self):
151-
super().__init__()
152-
self.workdir = self._create_temp_dir('workdir')
153-
154150
@property
155151
def name(self):
156152
return 'centipede'
@@ -202,7 +198,8 @@ def prepare(self, corpus_dir, target_path, build_dir):
202198
# 1. Centipede-readable corpus file;
203199
# 2. Centipede-readable feature file;
204200
# 3. Crash reproducing inputs.
205-
arguments[constants.WORKDIR_FLAGNAME] = str(self.workdir)
201+
workdir = self._create_temp_dir('workdir')
202+
arguments[constants.WORKDIR_FLAGNAME] = str(workdir)
206203

207204
# Directory corpus_dir saves the corpus files required by ClusterFuzz.
208205
arguments[constants.CORPUS_DIR_FLAGNAME] = corpus_dir
@@ -301,7 +298,12 @@ def fuzz(self, target_path, options, reproducers_dir, max_time): # pylint: disa
301298
int(fuzz_result.time_executed)))
302299

303300
stats_filename = f'fuzzing-stats-{os.path.basename(target_path)}.000000.csv'
304-
stats_file = os.path.join(self.workdir, stats_filename)
301+
args = fuzzer_options.FuzzerArguments.from_list(options.arguments)
302+
assert args is not None
303+
assert constants.WORKDIR_FLAGNAME in args
304+
305+
workdir = args[constants.WORKDIR_FLAGNAME]
306+
stats_file = os.path.join(workdir, stats_filename)
305307
stats = _parse_centipede_stats(stats_file)
306308
if not stats:
307309
stats = {}
@@ -505,9 +507,10 @@ def minimize_testcase(self, target_path, arguments, input_path, output_path,
505507
TimeoutError: If the testcase minimization exceeds max_time.
506508
"""
507509
runner = _get_runner(target_path)
510+
workdir = self._create_temp_dir('workdir')
508511
args = [
509512
f'--binary={target_path}',
510-
f'--workdir={self.workdir}',
513+
f'--workdir={workdir}',
511514
f'--minimize_crash={input_path}',
512515
f'--num_runs={constants.NUM_RUNS_PER_MINIMIZATION}',
513516
'--seed=1',
@@ -517,7 +520,7 @@ def minimize_testcase(self, target_path, arguments, input_path, output_path,
517520
logs.warning(
518521
'Testcase minimization timed out.', fuzzer_output=result.output)
519522
raise TimeoutError('Minimization timed out.')
520-
minimum_testcase = self._get_smallest_crasher(self.workdir)
523+
minimum_testcase = self._get_smallest_crasher(workdir)
521524
if minimum_testcase:
522525
shutil.copyfile(minimum_testcase, output_path)
523526
else:

src/clusterfuzz/_internal/bot/fuzzers/libFuzzer/engine.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from clusterfuzz._internal.bot.fuzzers.libFuzzer import stats
3030
from clusterfuzz._internal.fuzzing import strategy
3131
from clusterfuzz._internal.metrics import logs
32-
from clusterfuzz._internal.metrics import profiler
3332
from clusterfuzz._internal.system import environment
3433
from clusterfuzz._internal.system import shell
3534
from clusterfuzz.fuzz import engine
@@ -280,7 +279,6 @@ def fuzz(self, target_path, options, reproducers_dir, max_time):
280279
Returns:
281280
A FuzzResult object.
282281
"""
283-
profiler.start_if_needed('libfuzzer_fuzz')
284282
libfuzzer.set_sanitizer_options(target_path)
285283
runner = libfuzzer.get_runner(target_path)
286284

src/clusterfuzz/_internal/bot/tasks/commands.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,13 @@ def process_command_impl(task_name, task_argument, job_name, high_end,
320320
# A misconfiguration led to this point. Clean up the job if necessary.
321321
# TODO(ochang): Remove the first part of this check once we migrate off the
322322
# old untrusted worker architecture.
323+
# If the job base quque is '-android', which is the default Android queue
324+
# ignore the mismatch since with subqueues, it is expected
323325
if (not environment.get_value('DEBUG_TASK') and
324326
not environment.is_tworker() and
325327
not environment.is_trusted_host(ensure_connected=False) and
326-
job_base_queue_suffix != bot_base_queue_suffix):
328+
job_base_queue_suffix != bot_base_queue_suffix and
329+
job_base_queue_suffix != '-android'):
327330
# This happens rarely, store this as a hard exception.
328331
logs.error('Wrong platform for job %s: job queue [%s], bot queue [%s].' %
329332
(job_name, job_base_queue_suffix, bot_base_queue_suffix))

src/clusterfuzz/_internal/metrics/profiler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
# limitations under the License.
1414
"""Profiling functions."""
1515
from clusterfuzz._internal.base import utils
16+
from clusterfuzz._internal.config import local_config
1617
from clusterfuzz._internal.metrics import logs
1718
from clusterfuzz._internal.system import environment
1819

1920

2021
def start_if_needed(service):
21-
"""Start Google Cloud Profiler if |USE_PYTHON_PROFILER| environment variable
22-
is set."""
23-
if not environment.get_value('USE_PYTHON_PROFILER'):
22+
"""Start Google Cloud Profiler if profiling key in project config
23+
is enabled."""
24+
config = local_config.ProjectConfig()
25+
if not config.get('profiling.enabled', False):
2426
return True
2527

2628
project_id = utils.get_application_id()

src/local/butler/package.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
MIN_SUPPORTED_NODEJS_VERSION = 4
2828

2929

30-
def _clear_zip(target_zip_path):
30+
def _clear_zip(target_zip_path, clear_manifest=True):
3131
"""Remove zip and manifest file."""
32-
if os.path.exists(constants.PACKAGE_TARGET_MANIFEST_PATH):
32+
if clear_manifest and os.path.exists(constants.PACKAGE_TARGET_MANIFEST_PATH):
3333
os.remove(constants.PACKAGE_TARGET_MANIFEST_PATH)
3434

3535
if os.path.exists(target_zip_path):
@@ -144,7 +144,7 @@ def package(revision,
144144
add_target_zip_name = utils.get_platform_deployment_filename(
145145
platform_name, release=add_release)
146146
add_target_zip_path = os.path.join(target_zip_dir, add_target_zip_name)
147-
_clear_zip(add_target_zip_path)
147+
_clear_zip(add_target_zip_path, clear_manifest=False)
148148
shutil.copy2(target_zip_path, add_target_zip_path)
149149
print('\n%s is ready.' % add_target_zip_path)
150150
targets_zip_paths.append(add_target_zip_path)

0 commit comments

Comments
 (0)