Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Disable symlinks option #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2024
Merged

Disable symlinks option #454

merged 3 commits into from
Jun 11, 2024

Conversation

joseluisq
Copy link
Collaborator

@joseluisq joseluisq commented Jun 10, 2024

Description

This PR adds support to disable symlinks via the boolean --disable-symlinks by preventing following files or directories if any path name component is a symbolic link and returning 403 Forbidden in case accessing a path directly if the feature is enabled.
This applies also to the directory listing. In this case, the file or directory won't be shown in the list.

The feature is off (false) by default.

      --disable-symlinks[=<DISABLE_SYMLINKS>]
          Prevent following files or directories if any path name component is a symbolic link [env: SERVER_DISABLE_SYMLINKS=] [default: false] [possible values: true, false]\

Related Issue

Motivation and Context

How Has This Been Tested?

Feature disabled (default)

curl -I http://127.0.0.1:8787/static-web-server/
# HTTP/1.1 200 OK
# content-type: text/html; charset=utf-8
# content-length: 4423
# cache-control: public, max-age=86400
# date: Mon, 10 Jun 2024 20:20:56 GMT

Feature enabled

curl -I http://127.0.0.1:8787/static-web-server/
# HTTP/1.1 403 Forbidden
# content-type: text/html; charset=utf-8
# content-length: 106
# accept-ranges: bytes
# cache-control: public, max-age=86400
# date: Mon, 10 Jun 2024 20:22:38 GMT

Screenshots (if appropriate):

--disable-symlinks[=<DISABLE_SYMLINKS>]
  Prevent following files or directories if any path name component is
  a symbolic link [env: SERVER_DISABLE_SYMLINKS=] [default: false]
  [possible values: true, false]
Copy link

semanticdiff-com bot commented Jun 10, 2024

Review changes with SemanticDiff.

Analyzed 11 of 16 files.

Overall, the semantic diff is 2% smaller than the GitHub diff.

Filename Status
docs/content/configuration/command-line-arguments.md Unsupported file format
docs/content/configuration/environment-variables.md Unsupported file format
docs/content/features/disable-symlinks.md Unsupported file format
docs/mkdocs.yml Unsupported file format
✔️ src/directory_listing.rs 6.79% smaller
✔️ src/handler.rs Analyzed
✔️ src/server.rs Analyzed
✔️ src/settings/cli.rs Analyzed
✔️ src/settings/file.rs Analyzed
✔️ src/settings/mod.rs Analyzed
✔️ src/static_files.rs Analyzed
✔️ src/testing.rs Analyzed
✔️ tests/compression_static.rs Analyzed
✔️ tests/dir_listing.rs Analyzed
tests/fixtures/public/symlink Unsupported file format
✔️ tests/static_files.rs 1.24% smaller

@joseluisq joseluisq added enhancement New feature or request v2 v2 release general Related to general server configuration labels Jun 10, 2024
@joseluisq joseluisq merged commit eeb88da into master Jun 11, 2024
@joseluisq joseluisq deleted the feat-disable-symlinks branch June 11, 2024 20:46
@joseluisq joseluisq added this to the v2.32.0 milestone Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request general Related to general server configuration v2 v2 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant