diff options
author | Oliver Chang <oliverchang@users.noreply.github.com> | 2021-09-15 11:49:29 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 11:49:29 +1000 |
commit | d178de5e008adbf176f661b6d05ae0ece10712ee (patch) | |
tree | 37b3221e7fed988bbf1f02070c80faf7d94b94a3 /infra/cifuzz | |
parent | 1194a4d59c9a7e1f1d3f343096849b1200223ca3 (diff) | |
download | oss-fuzz-d178de5e008adbf176f661b6d05ae0ece10712ee.tar.gz |
CFLite: Fix corpus pruning for git store. (#6434)
Fixes #6376.
Diffstat (limited to 'infra/cifuzz')
-rw-r--r-- | infra/cifuzz/clusterfuzz_deployment.py | 10 | ||||
-rw-r--r-- | infra/cifuzz/filestore/__init__.py | 2 | ||||
-rw-r--r-- | infra/cifuzz/filestore/git/__init__.py | 9 | ||||
-rw-r--r-- | infra/cifuzz/filestore/github_actions/__init__.py | 5 | ||||
-rw-r--r-- | infra/cifuzz/run_fuzzers.py | 3 |
5 files changed, 18 insertions, 11 deletions
diff --git a/infra/cifuzz/clusterfuzz_deployment.py b/infra/cifuzz/clusterfuzz_deployment.py index 169c83fb3..fdc3738df 100644 --- a/infra/cifuzz/clusterfuzz_deployment.py +++ b/infra/cifuzz/clusterfuzz_deployment.py @@ -63,7 +63,7 @@ class BaseClusterFuzzDeployment: """Uploads crashes in |crashes_dir| to filestore.""" raise NotImplementedError('Child class must implement method.') - def upload_corpus(self, target_name, corpus_dir): # pylint: disable=no-self-use,unused-argument + def upload_corpus(self, target_name, corpus_dir, replace=False): # pylint: disable=no-self-use,unused-argument """Uploads the corpus for |target_name| to filestore.""" raise NotImplementedError('Child class must implement method.') @@ -152,12 +152,12 @@ class ClusterFuzzLite(BaseClusterFuzzDeployment): """Returns the name of the crashes artifact.""" return 'current' - def upload_corpus(self, target_name, corpus_dir): + def upload_corpus(self, target_name, corpus_dir, replace=False): """Upload the corpus produced by |target_name|.""" logging.info('Uploading corpus in %s for %s.', corpus_dir, target_name) name = self._get_corpus_name(target_name) try: - self.filestore.upload_corpus(name, corpus_dir) + self.filestore.upload_corpus(name, corpus_dir, replace=replace) logging.info('Done uploading corpus.') except Exception as error: # pylint: disable=broad-except logging.error('Failed to upload corpus for target: %s. Error: %s.', @@ -272,7 +272,7 @@ class OSSFuzz(BaseClusterFuzzDeployment): """Noop Implementation of upload_build.""" logging.info('Not uploading latest build because on OSS-Fuzz.') - def upload_corpus(self, target_name, corpus_dir): # pylint: disable=no-self-use,unused-argument + def upload_corpus(self, target_name, corpus_dir, replace=False): # pylint: disable=no-self-use,unused-argument """Noop Implementation of upload_corpus.""" logging.info('Not uploading corpus because on OSS-Fuzz.') @@ -323,7 +323,7 @@ class NoClusterFuzzDeployment(BaseClusterFuzzDeployment): logging.info('Not uploading latest build because no ClusterFuzz ' 'deployment.') - def upload_corpus(self, target_name, corpus_dir): # pylint: disable=no-self-use,unused-argument + def upload_corpus(self, target_name, corpus_dir, replace=False): # pylint: disable=no-self-use,unused-argument """Noop Implementation of upload_corpus.""" logging.info('Not uploading corpus because no ClusterFuzz deployment.') diff --git a/infra/cifuzz/filestore/__init__.py b/infra/cifuzz/filestore/__init__.py index 49999d081..d112f7b8c 100644 --- a/infra/cifuzz/filestore/__init__.py +++ b/infra/cifuzz/filestore/__init__.py @@ -29,7 +29,7 @@ class BaseFilestore: """Uploads the crashes at |directory| to |name|.""" raise NotImplementedError('Child class must implement method.') - def upload_corpus(self, name, directory): + def upload_corpus(self, name, directory, replace=False): """Uploads the corpus at |directory| to |name|.""" raise NotImplementedError('Child class must implement method.') diff --git a/infra/cifuzz/filestore/git/__init__.py b/infra/cifuzz/filestore/git/__init__.py index 742aebdb7..5414003da 100644 --- a/infra/cifuzz/filestore/git/__init__.py +++ b/infra/cifuzz/filestore/git/__init__.py @@ -112,10 +112,13 @@ class GitFilestore(filestore.BaseFilestore): """Uploads the crashes at |directory| to |name|.""" return self._ci_filestore.upload_crashes(name, directory) - def upload_corpus(self, name, directory): + def upload_corpus(self, name, directory, replace=False): """Uploads the corpus at |directory| to |name|.""" - self._upload_to_git('Corpus upload', self.config.git_store_branch, - os.path.join(_CORPUS_DIR, name), directory) + self._upload_to_git('Corpus upload', + self.config.git_store_branch, + os.path.join(_CORPUS_DIR, name), + directory, + replace=replace) def upload_build(self, name, directory): """Uploads the build at |directory| to |name|.""" diff --git a/infra/cifuzz/filestore/github_actions/__init__.py b/infra/cifuzz/filestore/github_actions/__init__.py index 6d04ccfbd..8b9b5986e 100644 --- a/infra/cifuzz/filestore/github_actions/__init__.py +++ b/infra/cifuzz/filestore/github_actions/__init__.py @@ -75,8 +75,11 @@ class GithubActionsFilestore(filestore.BaseFilestore): """Uploads the crashes at |directory| to |name|.""" return _raw_upload_directory(self.CRASHES_PREFIX + name, directory) - def upload_corpus(self, name, directory): + def upload_corpus(self, name, directory, replace=False): """Uploads the corpus at |directory| to |name|.""" + # Not applicable as the the entire corpus is uploaded under a single + # artifact name. + del replace return self._upload_directory(self.CORPUS_PREFIX + name, directory) def upload_build(self, name, directory): diff --git a/infra/cifuzz/run_fuzzers.py b/infra/cifuzz/run_fuzzers.py index 347615772..67c4c66fd 100644 --- a/infra/cifuzz/run_fuzzers.py +++ b/infra/cifuzz/run_fuzzers.py @@ -178,7 +178,8 @@ class PruneTargetRunner(BaseFuzzTargetRunner): result = fuzz_target_obj.prune() logging.debug('Corpus path contents: %s.', os.listdir(result.corpus_path)) self.clusterfuzz_deployment.upload_corpus(fuzz_target_obj.target_name, - result.corpus_path) + result.corpus_path, + replace=True) return result def cleanup_after_fuzz_target_run(self, fuzz_target_obj): # pylint: disable=no-self-use |