aboutsummaryrefslogtreecommitdiff
path: root/infra/cifuzz
diff options
context:
space:
mode:
authorjonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>2021-08-04 17:04:55 -0700
committerGitHub <noreply@github.com>2021-08-04 17:04:55 -0700
commitaac1cb8c76aa95afaf22d8eb4ba31839ab9bbea7 (patch)
tree1e920f488cda1834dd2607d236c5d3755fdd4b04 /infra/cifuzz
parentf0a42fbb1f9f03c851fb5711b7a86f5f0c7ef4b9 (diff)
downloadoss-fuzz-aac1cb8c76aa95afaf22d8eb4ba31839ab9bbea7.tar.gz
[infra][NFC] Use one source of truth for engines, languages etc. (#6163)
Do this only where it makes sense. For example, since CIFuzz doesn't support dataflow, maintain a separate source of truth.
Diffstat (limited to 'infra/cifuzz')
-rw-r--r--infra/cifuzz/config_utils.py29
-rw-r--r--infra/cifuzz/config_utils_test.py4
-rw-r--r--infra/cifuzz/docker.py14
3 files changed, 16 insertions, 31 deletions
diff --git a/infra/cifuzz/config_utils.py b/infra/cifuzz/config_utils.py
index d9a8f0c45..cac076212 100644
--- a/infra/cifuzz/config_utils.py
+++ b/infra/cifuzz/config_utils.py
@@ -24,26 +24,10 @@ import environment
# pylint: disable=wrong-import-position,import-error
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-import helper
+import constants
RUN_FUZZERS_MODES = ['batch', 'ci', 'coverage']
-
-# TODO(metzman): Make one source of truth for these in helper.py
SANITIZERS = ['address', 'memory', 'undefined', 'coverage']
-LANGUAGES = [
- 'c',
- 'c++',
- 'go',
- 'jvm',
- 'python',
- 'rust',
- 'swift',
-]
-
-DEFAULT_ENGINE = 'libfuzzer'
-DEFAULT_ARCHITECTURE = 'x86_64'
-DEFAULT_LANGUAGE = 'c++'
-DEFAULT_SANITIZER = 'address'
# This module deals a lot with env variables. Many of these will be set by users
# and others beyond CIFuzz's control. Thus, you should be careful about using
@@ -60,7 +44,7 @@ def _get_pr_ref(event):
def _get_sanitizer():
- return os.getenv('SANITIZER', DEFAULT_SANITIZER).lower()
+ return os.getenv('SANITIZER', constants.DEFAULT_SANITIZER).lower()
def _is_dry_run():
@@ -75,7 +59,7 @@ def _get_language():
# getting it from the project.yaml) is outweighed by the complexity in
# implementing this. A lot of the complexity comes from our unittests not
# setting a proper projet at this point.
- return os.getenv('LANGUAGE', DEFAULT_LANGUAGE)
+ return os.getenv('LANGUAGE', constants.DEFAULT_LANGUAGE)
# pylint: disable=too-few-public-methods,too-many-instance-attributes
@@ -211,7 +195,8 @@ class BaseConfig:
self.sanitizer = _get_sanitizer()
- self.build_integration_path = helper.DEFAULT_RELATIVE_BUILD_INTEGRATION_PATH
+ self.build_integration_path = (
+ constants.DEFAULT_EXTERNAL_BUILD_INTEGRATION_PATH)
self.language = _get_language()
self.low_disk_space = environment.get_bool('LOW_DISK_SPACE', False)
@@ -239,9 +224,9 @@ class BaseConfig:
self.sanitizer, SANITIZERS)
return False
- if self.language not in LANGUAGES:
+ if self.language not in constants.LANGUAGES:
logging.error('Invalid LANGUAGE: %s. Must be one of: %s.', self.language,
- LANGUAGES)
+ constants.LANGUAGES)
return False
return True
diff --git a/infra/cifuzz/config_utils_test.py b/infra/cifuzz/config_utils_test.py
index d904fbfbb..a8da59ad8 100644
--- a/infra/cifuzz/config_utils_test.py
+++ b/infra/cifuzz/config_utils_test.py
@@ -17,6 +17,7 @@ import unittest
from unittest import mock
import config_utils
+import constants
import test_helpers
# pylint: disable=no-self-use,protected-access
@@ -72,8 +73,7 @@ class BaseConfigTest(unittest.TestCase):
config = self._create_config()
self.assertFalse(config.validate())
mocked_error.assert_called_with('Invalid LANGUAGE: %s. Must be one of: %s.',
- os.environ['LANGUAGE'],
- config_utils.LANGUAGES)
+ os.environ['LANGUAGE'], constants.LANGUAGES)
@mock.patch('logging.error')
def test_validate_invalid_sanitizer(self, mocked_error):
diff --git a/infra/cifuzz/docker.py b/infra/cifuzz/docker.py
index 15858b458..e20e5ca00 100644
--- a/infra/cifuzz/docker.py
+++ b/infra/cifuzz/docker.py
@@ -16,10 +16,10 @@ import logging
import os
import sys
-import config_utils
# pylint: disable=wrong-import-position,import-error
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+import constants
import utils
BASE_BUILDER_TAG = 'gcr.io/oss-fuzz-base/base-builder'
@@ -29,8 +29,8 @@ PROJECT_TAG_PREFIX = 'gcr.io/oss-fuzz/'
_DEFAULT_DOCKER_RUN_ARGS = [
'--cap-add', 'SYS_PTRACE', '-e',
- 'FUZZING_ENGINE=' + config_utils.DEFAULT_ENGINE, '-e',
- 'ARCHITECTURE=' + config_utils.DEFAULT_ARCHITECTURE, '-e', 'CIFUZZ=True'
+ 'FUZZING_ENGINE=' + constants.DEFAULT_ENGINE, '-e',
+ 'ARCHITECTURE=' + constants.DEFAULT_ARCHITECTURE, '-e', 'CIFUZZ=True'
]
EXTERNAL_PROJECT_IMAGE = 'external-project'
@@ -69,8 +69,8 @@ def delete_images(images):
def get_base_docker_run_args(workspace,
- sanitizer=config_utils.DEFAULT_SANITIZER,
- language=config_utils.DEFAULT_LANGUAGE):
+ sanitizer=constants.DEFAULT_SANITIZER,
+ language=constants.DEFAULT_LANGUAGE):
"""Returns arguments that should be passed to every invocation of 'docker
run'."""
docker_args = _DEFAULT_DOCKER_RUN_ARGS.copy()
@@ -92,8 +92,8 @@ def get_base_docker_run_args(workspace,
def get_base_docker_run_command(workspace,
- sanitizer=config_utils.DEFAULT_SANITIZER,
- language=config_utils.DEFAULT_LANGUAGE):
+ sanitizer=constants.DEFAULT_SANITIZER,
+ language=constants.DEFAULT_LANGUAGE):
"""Returns part of the command that should be used everytime 'docker run' is
invoked."""
docker_args, docker_container = get_base_docker_run_args(