1# Copyright 2021 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"""Utilities for scripts from gcr.io/oss-fuzz-base/base-runner.""" 15 16import os 17 18import config_utils 19 20 21def get_env(config, workspace): 22 """Returns a dictionary containing the current environment with additional env 23 vars set to values needed to run a fuzzer.""" 24 env = os.environ.copy() 25 env['SANITIZER'] = config.sanitizer 26 env['FUZZING_LANGUAGE'] = config.language 27 env['OUT'] = workspace.out 28 env['CIFUZZ'] = 'True' 29 env['FUZZING_ENGINE'] = config_utils.DEFAULT_ENGINE 30 env['ARCHITECTURE'] = config_utils.DEFAULT_ARCHITECTURE 31 # Do this so we don't fail in tests. 32 env['FUZZER_ARGS'] = '-rss_limit_mb=2560 -timeout=25' 33 return env 34