Skip to content

Commit 014bb61

Browse files
chore: Migrate gsutil usage to gcloud storage
1 parent d765b6f commit 014bb61

File tree

10 files changed

+50
-49
lines changed

10 files changed

+50
-49
lines changed

docs/advanced-topics/code_coverage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ corpora by doing the following:
5151
* Check whether you have access to the corpus for your project:
5252

5353
```bash
54-
$ gsutil ls gs://${PROJECT_NAME}-corpus.clusterfuzz-external.appspot.com/
54+
$ gcloud storage ls gs://${PROJECT_NAME}-corpus.clusterfuzz-external.appspot.com/
5555
```
5656

5757
If you see an authorization error from the command above, run this:

docs/advanced-topics/corpora.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ Copy the corpus to a directory on your
5353
machine by running the following command:
5454

5555
```bash
56-
$ gsutil -m cp -r gs://<bucket_path> <local_directory>
56+
$ gcloud storage cp --recursive gs://<bucket_path> <local_directory>
5757
```
5858
Using the expat example above, this would be:
5959

6060
```bash
61-
$ gsutil -m cp -r \
61+
$ gcloud storage cp --recursive \
6262
gs://expat-corpus.clusterfuzz-external.appspot.com/libFuzzer/expat_parse_fuzzer \
6363
<local_directory>
6464
```
@@ -67,4 +67,4 @@ $ gsutil -m cp -r \
6767

6868
We keep daily zipped backups of your corpora. These can be accessed from the
6969
**corpus_backup** column of the fuzzer statistics page. Downloading these can
70-
be significantly faster than running `gsutil -m cp -r` on the corpus bucket.
70+
be significantly faster than running `gcloud storage cp --recursive` on the corpus bucket.

infra/base-images/base-builder/jcc/build_jcc.bash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
go build jcc.go
2020
go build jcc2.go
21-
gsutil cp jcc gs://clusterfuzz-builds/jcc/clang++-jcc
22-
gsutil cp jcc gs://clusterfuzz-builds/jcc/clang-jcc
21+
gcloud storage cp jcc gs://clusterfuzz-builds/jcc/clang++-jcc
22+
gcloud storage cp jcc gs://clusterfuzz-builds/jcc/clang-jcc
2323

24-
gsutil cp jcc2 gs://clusterfuzz-builds/jcc/clang++-jcc2
25-
gsutil cp jcc2 gs://clusterfuzz-builds/jcc/clang-jcc2
24+
gcloud storage cp jcc2 gs://clusterfuzz-builds/jcc/clang++-jcc2
25+
gcloud storage cp jcc2 gs://clusterfuzz-builds/jcc/clang-jcc2

infra/build/functions/project_experiment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def run_experiment(project_name, command, output_path, experiment_name):
8282
]
8383
},
8484
{
85-
'name': 'gcr.io/cloud-builders/gsutil',
85+
'name': 'gcr.io/cloud-builders/gcloud',
8686
'args': [
87-
'-m',
87+
'storage',
8888
'cp',
89-
'-r',
89+
'--recursive',
9090
'/workspace/out/*',
9191
output_path,
9292
]

infra/build/functions/target_experiment.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,21 @@ def run_experiment(project_name,
110110
}
111111
steps.append(build_lib.dockerify_run_step(run_step, build))
112112
steps.append({
113-
'name': 'gcr.io/cloud-builders/gsutil',
114-
'args': ['-m', 'cp', local_output_path, output_path]
113+
'name': 'gcr.io/cloud-builders/gcloud',
114+
'args': ['storage', 'cp', local_output_path, output_path]
115115
})
116116

117117
# Upload corpus.
118118
steps.append({
119119
'name':
120-
'gcr.io/cloud-builders/gsutil',
120+
'gcr.io/cloud-builders/gcloud',
121121
'entrypoint':
122122
'/bin/bash',
123123
'args': [
124124
'-c',
125125
(f'cd {local_corpus_path} && '
126126
f'zip -r {local_corpus_zip_path} * && '
127-
f'gsutil -m cp {local_corpus_zip_path} {upload_corpus_path} || '
127+
f'gcloud storage cp {local_corpus_zip_path} {upload_corpus_path} || '
128128
f'rm -f {local_corpus_zip_path}'),
129129
],
130130
})
@@ -136,36 +136,36 @@ def run_experiment(project_name,
136136
# If multiple files are found, suffix them and upload them all.
137137
steps.append({
138138
'name':
139-
'gcr.io/cloud-builders/gsutil',
139+
'gcr.io/cloud-builders/gcloud',
140140
'entrypoint':
141141
'/bin/bash',
142142
'args': [
143143
'-c',
144144
(f'cp {default_target_path} {local_target_dir} 2>/dev/null || '
145145
f'find {build.out} -type f -name {target_name} -exec bash -c '
146146
f'\'cp "$0" "{local_target_dir}/$(echo "$0" | sed "s@/@_@g")"\' '
147-
f'{{}} \\; && gsutil cp -r {local_target_dir} '
147+
f'{{}} \\; && gcloud storage cp --recursive {local_target_dir} '
148148
f'{upload_reproducer_path}/target_binary || true'),
149149
],
150150
})
151151

152152
# Upload reproducer.
153153
steps.append({
154154
'name':
155-
'gcr.io/cloud-builders/gsutil',
155+
'gcr.io/cloud-builders/gcloud',
156156
'entrypoint':
157157
'/bin/bash',
158158
'args': [
159159
'-c',
160-
(f'gsutil -m cp -r {local_artifact_path} {upload_reproducer_path} '
160+
(f'gcloud storage cp --recursive {local_artifact_path} {upload_reproducer_path} '
161161
'|| true'),
162162
],
163163
})
164164

165165
# Upload stacktrace.
166166
steps.append({
167167
'name':
168-
'gcr.io/cloud-builders/gsutil',
168+
'gcr.io/cloud-builders/gcloud',
169169
'entrypoint':
170170
'/bin/bash',
171171
'args': [
@@ -178,7 +178,7 @@ def run_experiment(project_name,
178178
f'"$target" {local_artifact_path}/* > '
179179
f'"{local_stacktrace_path}/$target.st" 2>&1; '
180180
'done; fi; '
181-
f'gsutil -m cp -r {local_stacktrace_path} {upload_reproducer_path}'
181+
f'gcloud storage cp --recursive {local_stacktrace_path} {upload_reproducer_path}'
182182
' || true'),
183183
],
184184
})
@@ -230,11 +230,11 @@ def run_experiment(project_name,
230230
# Upload raw coverage data.
231231
steps.append({
232232
'name':
233-
'gcr.io/cloud-builders/gsutil',
233+
'gcr.io/cloud-builders/gcloud',
234234
'args': [
235-
'-m',
235+
'storage',
236236
'cp',
237-
'-r',
237+
'--recursive',
238238
os.path.join(build.out, 'dumps'),
239239
os.path.join(upload_coverage_path, 'dumps'),
240240
],
@@ -243,11 +243,11 @@ def run_experiment(project_name,
243243
# Upload coverage report.
244244
steps.append({
245245
'name':
246-
'gcr.io/cloud-builders/gsutil',
246+
'gcr.io/cloud-builders/gcloud',
247247
'args': [
248-
'-m',
248+
'storage',
249249
'cp',
250-
'-r',
250+
'--recursive',
251251
os.path.join(build.out, 'report'),
252252
os.path.join(upload_coverage_path, 'report'),
253253
],
@@ -256,11 +256,11 @@ def run_experiment(project_name,
256256
# Upload textcovs.
257257
steps.append({
258258
'name':
259-
'gcr.io/cloud-builders/gsutil',
259+
'gcr.io/cloud-builders/gcloud',
260260
'args': [
261-
'-m',
261+
'storage',
262262
'cp',
263-
'-r',
263+
'--recursive',
264264
os.path.join(build.out, 'textcov_reports'),
265265
os.path.join(upload_coverage_path, 'textcov_reports'),
266266
],

infra/build/status/deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
#
1616
################################################################################
1717

18-
gsutil -h "Cache-Control:no-cache,max-age=0" -m cp -r bower_components index.html src manifest.json gs://oss-fuzz-build-logs
18+
# gcloud storage cp does not support setting metadata during upload. The -h flag is not translated.
19+
gcloud storage cp --recursive bower_components index.html src manifest.json gs://oss-fuzz-build-logs

infra/cifuzz/filestore/gsutil/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@
2727

2828

2929
def _gsutil_execute(*args, parallel=True):
30-
"""Executes a gsutil command, passing |*args| to gsutil and returns the
30+
"""Executes a gcloud storage command, passing |*args| to it and returns the
3131
stdout, stderr and returncode. Exceptions on failure."""
32-
command = ['gsutil']
32+
command = ['gcloud', 'storage']
3333
if parallel:
34-
command.append('-m')
34+
pass
3535
command += list(args)
36-
logging.info('Executing gsutil command: %s', command)
36+
logging.info('Executing gcloud storage command: %s', command)
3737
return utils.execute(command, check_result=True)
3838

3939

4040
def _rsync(src, dst, recursive=True, delete=False):
41-
"""Executes gsutil rsync on |src| and |dst|"""
41+
"""Executes gcloud storage rsync on |src| and |dst|"""
4242
args = ['rsync']
4343
if recursive:
44-
args.append('-r')
44+
args.append('--recursive')
4545
if delete:
46-
args.append('-d')
46+
args.append('--delete-unmatched-destination-objects')
4747
args += [src, dst]
4848
return _gsutil_execute(*args)
4949

infra/cifuzz/platform_config/gcb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ def workspace(self):
3737
@property
3838
def filestore(self):
3939
"""Returns the filestore used to store persistent data."""
40-
return os.environ.get('FILESTORE', 'gsutil')
40+
return os.environ.get('FILESTORE', 'gcloud storage')

infra/experimental/contrib/arvo/hacks/wolfssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def apply_dockerfile_fixes(self, dft) -> bool:
1010
"""Fix WolfSSL Dockerfile issues."""
1111
# Replace gsutil cp command with a simple touch and zip
1212
dft.str_replace(
13-
'RUN gsutil cp '
13+
'RUN gcloud storage cp '
1414
'gs://wolfssl-backup.clusterfuzz-external.appspot.com/'
1515
'corpus/libFuzzer/wolfssl_cryptofuzz-disable-fastmath/public.zip '
1616
'$SRC/corpus_wolfssl_disable-fastmath.zip', "RUN touch 0xdeadbeef && "

projects/wolfssl/Dockerfile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ RUN git clone https://github.com/wolfssl/oss-fuzz-targets --depth 1 $SRC/fuzz-ta
3131
RUN wget https://storage.googleapis.com/pub/gsutil.tar.gz -O $SRC/gsutil.tar.gz
3232
RUN tar zxf $SRC/gsutil.tar.gz
3333
ENV PATH="${PATH}:$SRC/gsutil"
34-
RUN gsutil cp gs://bearssl-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/bearssl_cryptofuzz-bearssl/public.zip $SRC/corpus_bearssl.zip
35-
RUN gsutil cp gs://nettle-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/nettle_cryptofuzz-nettle-with-mini-gmp/public.zip $SRC/corpus_nettle.zip
36-
RUN gsutil cp gs://libecc-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/libecc_cryptofuzz-libecc/public.zip $SRC/corpus_libecc.zip
37-
RUN gsutil cp gs://relic-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/relic_cryptofuzz-relic/public.zip $SRC/corpus_relic.zip
38-
RUN gsutil cp gs://cryptofuzz-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/cryptofuzz_cryptofuzz-openssl/public.zip $SRC/corpus_cryptofuzz-openssl.zip
39-
RUN gsutil cp gs://cryptofuzz-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/cryptofuzz_cryptofuzz-boringssl/public.zip $SRC/corpus_cryptofuzz-boringssl.zip
40-
RUN gsutil cp gs://cryptofuzz-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/cryptofuzz_cryptofuzz-nss/public.zip $SRC/corpus_cryptofuzz-nss.zip
34+
RUN gcloud storage cp gs://bearssl-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/bearssl_cryptofuzz-bearssl/public.zip $SRC/corpus_bearssl.zip
35+
RUN gcloud storage cp gs://nettle-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/nettle_cryptofuzz-nettle-with-mini-gmp/public.zip $SRC/corpus_nettle.zip
36+
RUN gcloud storage cp gs://libecc-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/libecc_cryptofuzz-libecc/public.zip $SRC/corpus_libecc.zip
37+
RUN gcloud storage cp gs://relic-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/relic_cryptofuzz-relic/public.zip $SRC/corpus_relic.zip
38+
RUN gcloud storage cp gs://cryptofuzz-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/cryptofuzz_cryptofuzz-openssl/public.zip $SRC/corpus_cryptofuzz-openssl.zip
39+
RUN gcloud storage cp gs://cryptofuzz-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/cryptofuzz_cryptofuzz-boringssl/public.zip $SRC/corpus_cryptofuzz-boringssl.zip
40+
RUN gcloud storage cp gs://cryptofuzz-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/cryptofuzz_cryptofuzz-nss/public.zip $SRC/corpus_cryptofuzz-nss.zip
4141

4242
# OpenSSL/LibreSSL corpora, which require a special import procedure
43-
RUN gsutil cp gs://openssl-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/openssl_bignum/public.zip $SRC/corpus_openssl_expmod.zip
44-
RUN gsutil cp gs://libressl-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/libressl_bignum/public.zip $SRC/corpus_libressl_expmod.zip
43+
RUN gcloud storage cp gs://openssl-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/openssl_bignum/public.zip $SRC/corpus_openssl_expmod.zip
44+
RUN gcloud storage cp gs://libressl-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/libressl_bignum/public.zip $SRC/corpus_libressl_expmod.zip
4545

4646
WORKDIR wolfssl
4747

0 commit comments

Comments
 (0)