abseil / abseil/abseil-py

Unintended behaviour in absltest.py

Aperta
#248 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
2.5k
Fork
279
Merge medio
2g 1h
PR unite (30g)
1

Descrizione

It seems like this section of code allows someone to pass in an arbitrary path name in tempfile, which then causes the code to zero out the provided path (rather than a temporary file) if the person running the test also happens to own the file: https://github.com/abseil/abseil-py/blob/976413320682f8fd1c05c36f24a9475050702699/absl/testing/absltest.py#L390-L396
Example:
```
import pathlib

from adric-work.testing.pybase import test

class BugTest(test.TestCase):

def testBug(self):
# bad_path = pathlib.Path.home() / 'hello_bug' / 'a_file.txt'
# my_file = self.create_tempfile(bad_path.as_posix())
bad_path = '/usr/local/work/home/adric-work/hello_bug/a_file.txt'
my_file = self.create_tempfile(bad_path)

if __name__ == '__main__':
test.main()
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.