Skip to content

Commit

Permalink
Handle absolute paths and .. in paths and linknames.
Browse files Browse the repository at this point in the history
No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner committed Dec 5, 2023
1 parent 2225280 commit d044bf1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lint/format/black:
# ---------------------------------------------------------

.PHONY: test
test: lint test/unit test/functional
test: lint test/unit test/integration
@echo "ALL MAKE TARGET TESTS SUCCESSFUL"

.PHONY: test/unit
Expand Down
7 changes: 5 additions & 2 deletions galaxy_importer/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def _import_collection(file, filename, file_url, logger, cfg):
def _extract_archive(fileobj, extract_dir):
fileobj.seek(0)
with tarfile.open(fileobj=fileobj, mode="r") as tf:
if any((item.startswith("/") or item.startswith("../")) for item in tf.getnames()):
raise exc.ImporterError("Invalid file paths detected.")
for item in tf.getmembers():
if item.name.startswith("/") or "../" in item.name:
raise exc.ImporterError("Invalid file paths detected.")
if item.linkname and (item.linkname.startswith("/") or "../" in item.linkname):
raise exc.ImporterError("Invalid linkname detected.")
tf.extractall(extract_dir)

0 comments on commit d044bf1

Please sign in to comment.