semgrep / testo

Test framework for OCaml
ISC License
16 stars 1 forks source link

mask_temp_paths should not mask temporary paths that are don't start a path #55

Closed mjambon closed 6 months ago

mjambon commented 6 months ago

We want:

utop # Testo.mask_temp_paths ~tmpdir:"/tmp" () "/var/tmp/aaa";;
- : string = "/var/tmp/aaa"
utop # Testo.mask_temp_paths ~tmpdir:"/tmp" () "/tmp/aaa";;
- : string = "<TMP>/<MASKED>"

This is the current behavior and it's incorrect:

utop # Testo.mask_temp_paths ~tmpdir:"/tmp" () "/var/tmp/aaa";;
- : string = "/var<TMP>/<MASKED>"

It's a problem on some MacOS hosts where the original temp folder path (a symlink) is a substring of the physical temp folder path obtained with Unix.realpath, and we call Testo.mask_temp_paths twice, once per variant of the temp folder path.