From 421aa1add1cbae1fd51b8d9efa4ed47dce7a06ac Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 12 Sep 2024 14:58:33 +0200 Subject: [PATCH] Add tests for invalid file names in NARs Note: in general, we rely on the OS to tell us if a name is invalid or if two names normalize in the same way. But for security, we do want to make sure that we catch '.', '..', slashes and NUL characters. (NUL characters aren't really a security issue, but since they would be truncated when we pass them to the OS, it would be canonicity problem.) --- tests/functional/dot.nar | Bin 0 -> 288 bytes tests/functional/dotdot.nar | Bin 0 -> 288 bytes tests/functional/empty.nar | Bin 0 -> 280 bytes tests/functional/nars.sh | 20 ++++++++++++++++++++ tests/functional/nul.nar | Bin 0 -> 288 bytes tests/functional/slash.nar | Bin 0 -> 288 bytes 6 files changed, 20 insertions(+) create mode 100644 tests/functional/dot.nar create mode 100644 tests/functional/dotdot.nar create mode 100644 tests/functional/empty.nar create mode 100644 tests/functional/nul.nar create mode 100644 tests/functional/slash.nar diff --git a/tests/functional/dot.nar b/tests/functional/dot.nar new file mode 100644 index 0000000000000000000000000000000000000000..3a9452f67fd7dc8b8c9328c767337c5c51b006c4 GIT binary patch literal 288 zcmd;OfPlQr3f;t_keEJ{r-$uFve z@>!vDYF-Ig43{~1iMe2NVDfrUeK33S@>5Xcak+yXs;?+Dy)-AWh=BvjPtMOPNzE%M XW`puGQgd?hxe)%+go?xL$HfN#TmTz& literal 0 HcmV?d00001 diff --git a/tests/functional/dotdot.nar b/tests/functional/dotdot.nar new file mode 100644 index 0000000000000000000000000000000000000000..f8d019c3926a8285fd3258798a8f88efc65df48d GIT binary patch literal 288 zcmd;OfPlQr3f;t_keEJ{r-$uFve z@>!vDYF-Ig43{~1iMe2Nn4s$Q^dJnFJ$d;lV0m2nVeVjuXk#c!O)t$!EMnk*@{{xP bN>cMmirJw2jMSW*d@h8)G@;@!^KtP3cfuQ_ literal 0 HcmV?d00001 diff --git a/tests/functional/empty.nar b/tests/functional/empty.nar new file mode 100644 index 0000000000000000000000000000000000000000..43434f2b4404161a74e8a90c0b5c8e3a11194fdf GIT binary patch literal 280 zcmd;OfPlQr3f;t_keEJ{r-$uFve z@>!vDYF-Ig43{~1iMe2NpvoCw=I7<7fW>j?gW1mx)mW68UYe6w#J~aNC+Fvtq~?_r XvqAY8sX00MTnPVYLd9X`keEJ{r-$uFve z@>!vDYF-Ig43{~1iMe2Nn4#*^81lg^m_2#keEJ{r-$uFve z@>!vDYF-Ig43{~1iMe2Nn4#(`^dTm|?8(bd0n6jk4|4}QRDV%wdTCB#5d#O5pPZjp blA2di%m(FWq~_%0b0Pet2^EK#kBbig>(3l% literal 0 HcmV?d00001