Skip to content

Commit

Permalink
fix: resolve directory before appending filename
Browse files Browse the repository at this point in the history
We did the order wrong, causing the security measure to think the
file was not a child of the directory that was allowed to serve.

This happens in pyinstaller for OSX, where some files in
/Contents/Resources link to files in /Contents/Frameworks.
  • Loading branch information
maartenbreddels committed Sep 5, 2024
1 parent 4686075 commit 1dd6d2d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ jobs:
# only 1 version, it's heavy
python-version: ["3.10"]
env:
LOCK_FILE_LOCATION: .ci-package-locks/qt/os${{ matrix.os }}-python${{ matrix.python-version }}.txt
LOCK_FILE_LOCATION: .ci-package-locks/qt-test/os${{ matrix.os }}-python${{ matrix.python-version }}.txt
steps:
- uses: ConorMacBride/install-package@v1
with:
Expand Down Expand Up @@ -391,6 +391,7 @@ jobs:
if: github.event_name == 'schedule' || steps.prepare.outputs.LOCKS_EXIST == 'false'
id: install_no_lock
run: |
mkdir -p .ci-package-locks/qt-test
pip install pyside6 qtpy pyinstaller
pip install `echo dist/*.whl`[all]
pip install `echo packages/solara-server/dist/*.whl`[all]
Expand All @@ -399,7 +400,6 @@ jobs:
git diff --exit-code | tee ${{ env.DIFF_FILE_LOCATION }}
[ -s ${{ env.DIFF_FILE_LOCATION }} ] || echo "HAS_DIFF=true" >> "$GITHUB_OUTPUT"
- name: Install
if: github.event_name != 'schedule' && steps.prepare.outputs.LOCKS_EXIST == 'true'
run: |
Expand Down
2 changes: 1 addition & 1 deletion pyinstaller/embedded_browser/solara-qt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ codesign_identity = os.environ.get("DEVELOPER_ID_APPLICATION")
datas = [
(Path(sys.prefix) / "share" / "jupyter", "./share/jupyter"),
(Path(sys.prefix) / "etc" / "jupyter", "./etc/jupyter"),
("test_pywebview.vue", "."),
("render_test.vue", "."),
]

block_cipher = None
Expand Down
2 changes: 1 addition & 1 deletion solara/server/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ def get_directories(
# from https://github.com/encode/starlette/pull/1377/files
def lookup_path(self, path: str) -> typing.Tuple[str, typing.Optional[os.stat_result]]:
for directory in self.all_directories:
directory = os.path.realpath(directory)
original_path = os.path.join(directory, path)
full_path = os.path.realpath(original_path)
directory = os.path.realpath(directory)
# return early if someone tries to access a file outside of the directory
if not path_is_child_of(Path(original_path), Path(directory)):
return "", None
Expand Down

0 comments on commit 1dd6d2d

Please sign in to comment.