Commit e726878
authored
fix(bigframes): world-readable temp zip in create_cloud_function (#17522)
Repro against the unpatched `create_cloud_function` archive step:
archive_path : /tmp/tmpXXXX.zip # sibling of the 0700 TemporaryDirectory
dir removed : True
zip remains : True # survives TemporaryDirectory cleanup
zip perms : 0o644 world-readable: True
`shutil.make_archive(directory, "zip", directory)` appends `.zip` to
`base_name`, so the archive lands at `<tempdir>.zip`, a sibling of the
temp dir rather than inside it. That copy of the generated cloud
function source (which embeds the cloudpickled UDF) is created mode 0644
in the shared system temp directory and is not removed when the
`TemporaryDirectory` is cleaned up, so any other local user can read it.
Fix keeps the sources in a subdirectory and writes the archive inside
the 0700 `TemporaryDirectory`, so it inherits the restrictive
permissions and is cleaned up with the rest of the scratch space.
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)1 parent 2f893b1 commit e726878
1 file changed
Lines changed: 11 additions & 2 deletions
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
362 | 369 | | |
363 | 370 | | |
364 | 371 | | |
365 | 372 | | |
366 | 373 | | |
367 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
368 | 377 | | |
369 | 378 | | |
370 | 379 | | |
| |||
0 commit comments