💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Code cleanup
davidmezzettia5306ae5d7c9
diff --git a/src/python/txtai/archive/zip.py b/src/python/txtai/archive/zip.pyindex 1b0cb7da..e9660201 100644--- a/src/python/txtai/archive/zip.py+++ b/src/python/txtai/archive/zip.py@@ -26,10 +26,11 @@ class Zip(Compress):def unpack(self, path, output):with ZipFile(path, "r") as zfile:- # Validate path if directory specified+ # Validate paths if directory specifiedfor fullpath in zfile.namelist():fullpath = os.path.join(path, fullpath)if os.path.dirname(fullpath) and not self.validate(path, fullpath):raise IOError(f"Invalid zip entry: {fullpath}")+ # Unpack datazfile.extractall(output)diff --git a/test/python/testarchive.py b/test/python/testarchive.pyindex 3d64b4f7..b22217f8 100644--- a/test/python/testarchive.py+++ b/test/python/testarchive.py@@ -75,31 +75,31 @@ class TestArchive(unittest.TestCase):with self.assertRaises(IOError):archive.load(path, "tar")- def testInvalidTar(self):+ def testInvalidTarPath(self):"""- Test invalid tar file+ Test invalid tar file with a path outside of base directory"""- path = os.path.join(tempfile.gettempdir(), "badtar")+ path = os.path.join(tempfile.gettempdir(), "badtarpath")with tarfile.open(path, "w") as tar:tar.add(Utils.PATH, arcname="..")- archive = ArchiveFactory.create(path)+ archive = ArchiveFactory.create()# Validate error is thrown for filewith self.assertRaises(IOError):archive.load(path, "tar")- def testInvalidZip(self):+ def testInvalidZipPath(self):"""- Test invalid zip file+ Test invalid zip file with a path outside of base directory"""- path = os.path.join(tempfile.gettempdir(), "badzip")+ path = os.path.join(tempfile.gettempdir(), "badzippath")with ZipFile(path, "w", ZIP_DEFLATED) as zfile:zfile.write(Utils.PATH + "/article.pdf", arcname="../article.pdf")- archive = ArchiveFactory.create(path)+ archive = ArchiveFactory.create()# Validate error is thrown for filewith self.assertRaises(IOError):