diff options
author | 2023-03-11 20:02:27 -0500 | |
---|---|---|
committer | 2023-03-11 20:02:27 -0500 | |
commit | 6601b36940a9a64834d8368bac515706e26f4ef9 (patch) | |
tree | de542f522e2c1a0b25d39b2c176f9fc84b8723f3 /tests | |
parent | Provide files_timeout to `MemFS.files_list` call (diff) |
Add unit test for deeply nested path file parsing
Using example for reproducing issue #172
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_nsjail.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index 456046b..c701d3a 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -227,6 +227,29 @@ class NsJailTests(unittest.TestCase): ) self.assertEqual(result.stderr, None) + def test_file_parsing_depth_limit(self): + code = dedent( + """ + import os + + x = "" + for _ in range(1000): + x += "a/" + os.mkdir(x) + + open(f"{x}test.txt", "w").write("test") + """ + ).strip() + + nsjail = NsJail(memfs_instance_size=32 * Size.MiB, files_timeout=5) + result = nsjail.python3(["-c", code]) + self.assertEqual(result.returncode, None) + self.assertEqual( + result.stdout, + "FileParsingError: Exceeded directory depth limit while parsing attachments", + ) + self.assertEqual(result.stderr, None) + def test_file_write_error(self): """Test errors during file write.""" result = self.nsjail.python3( |