Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afeb478ee1 | ||
|
|
df2869993a | ||
|
|
d49ab67904 | ||
|
|
cfff84306a | ||
|
|
72faf6dd3c | ||
|
|
a789f29cee | ||
|
|
74b13db3fa | ||
|
|
773b30102c | ||
|
|
0b925cbca9 | ||
|
|
9dd7c7d099 | ||
|
|
b24e43b06c | ||
|
|
91e68edb8c | ||
|
|
ac11538f08 | ||
|
|
f6fb8f6bf5 | ||
|
|
e6d70cf24c | ||
|
|
41e2b1bbba | ||
|
|
41b01a7404 | ||
|
|
0dd8905886 | ||
|
|
032271bafa | ||
|
|
50125a5d21 | ||
|
|
bc3d75a94a | ||
|
|
fb6aeba9ea | ||
|
|
67e893eee7 | ||
|
|
4a4b0f8c84 | ||
|
|
660d84661d | ||
|
|
392253c563 | ||
|
|
328f629181 | ||
|
|
4c3cb4bc9b | ||
|
|
3213b605be | ||
|
|
610e0b09e9 | ||
|
|
7453c78c98 | ||
|
|
cd5749dff8 | ||
|
|
4daddec6f2 | ||
|
|
9bd79c3aae | ||
|
|
6c69b5cd89 | ||
|
|
4b8a8d72ce | ||
|
|
8ddd3d1db9 | ||
|
|
9fffee387f | ||
|
|
5a12cad548 | ||
|
|
6232686e22 | ||
|
|
b21b1245ae | ||
|
|
7361d91ea2 | ||
|
|
c05c668148 | ||
|
|
b7dc392838 | ||
|
|
ac46cf0671 | ||
|
|
f0785391bf | ||
|
|
9b78324d77 | ||
|
|
fe7efb2e6a | ||
|
|
2651260a1c | ||
|
|
4470288ba1 | ||
|
|
58d22578e8 | ||
|
|
dfc2e887e1 | ||
|
|
aac2516637 | ||
|
|
c05ead7e8e |
No files matched your search
@@ -0,0 +1,160 @@
|
||||
# CLAUDE.md
|
||||
|
||||
Guidance for Claude when working in this repository (File Browser, `filebrowser/filebrowser`).
|
||||
|
||||
## Repo orientation
|
||||
|
||||
- Go backend (`github.com/filebrowser/filebrowser/v2`, ecosystem `go`) + Vue frontend under `frontend/`.
|
||||
- The project is in **maintenance-only mode** (see `SECURITY.md`). Prefer small, surgical, well-tested changes.
|
||||
- Version scheme: `v2.63.x`. Conventional-commit messages (`fix(scope): …`, `feat: …`, `chore: …`).
|
||||
- Verify with `go build ./...`, `go vet ./...`, `go test ./...`. Reuse existing test harnesses (e.g. `signToken`, `scopedUserStorage`, `handle`, `customFSUser`, `mockUserStore`).
|
||||
|
||||
---
|
||||
|
||||
# Handling security advisories
|
||||
|
||||
Use this playbook when asked to triage, verify, fix, or manage GitHub security advisories.
|
||||
All advisory state lives on GitHub and is driven with the `gh` CLI. States are
|
||||
`triage → draft → published`, plus `closed`.
|
||||
|
||||
## 1. Fetch
|
||||
|
||||
```bash
|
||||
# List by state (also: published, draft, closed)
|
||||
gh api '/repos/filebrowser/filebrowser/security-advisories?state=triage&per_page=100' \
|
||||
--jq '.[] | {ghsa_id, severity, summary, state}'
|
||||
|
||||
# Full report for one advisory (read .summary and .description)
|
||||
gh api /repos/filebrowser/filebrowser/security-advisories/GHSA-xxxx-xxxx-xxxx \
|
||||
--jq '.summary, "---", .description'
|
||||
```
|
||||
|
||||
Always pull the **published** set too — you need it to dedup against.
|
||||
|
||||
## 2. Verify each report — do NOT trust the report text
|
||||
|
||||
Read the actual source **at HEAD** and reach one verdict per advisory:
|
||||
|
||||
- **CONFIRMED** — defect exists at HEAD. Quote the exact `file:line`.
|
||||
- **FIXED** — already patched (find the fix commit).
|
||||
- **FALSE / NOT APPLICABLE** — claim is wrong, or targets a different project.
|
||||
- **NOT EXPLOITABLE** — pattern exists but no code path can reach the precondition.
|
||||
- **DUPLICATE** — of a published advisory, or of another triage advisory.
|
||||
|
||||
Common traps — check each before accepting a report:
|
||||
|
||||
- **"Incomplete fix of a prior advisory."** Read the original fix commit and confirm the *specific*
|
||||
sibling code path is actually still unguarded — a prior fix may already cover a related path.
|
||||
- **Wrong project.** Confirm the referenced files, symbols, and endpoints exist in this repo; reports
|
||||
sometimes describe a fork. If the cited code isn't here, close as not applicable.
|
||||
- **"Legacy / upgraded / imported records are affected."** Trace the field's git history and confirm that
|
||||
some released version could actually produce such a record before believing it
|
||||
(`git log -S'Field' -- path`, `git show <commit>`, `git tag --contains <commit>`).
|
||||
- **Overlapping reports.** Two triage advisories may share one root cause — consolidate and fix once.
|
||||
- **Known, intentionally-unaddressed classes.** Some areas are known and tracked but not fixed (see
|
||||
`SECURITY.md`'s Known Issues); matching reports are duplicates.
|
||||
|
||||
Record, per advisory: verdict, the `file:line` evidence, exploitability preconditions
|
||||
(default config? platform-specific? auth required?), and the disposition.
|
||||
|
||||
## 3. Fix (one commit per advisory)
|
||||
|
||||
- Branch off `master` first; never commit fixes directly to `master`.
|
||||
- **One commit per fix**, each referencing the GHSA in the body (`Refs GHSA-xxxx-xxxx-xxxx`).
|
||||
- When several advisories share a root cause because parallel code paths diverged, **centralize** the logic
|
||||
(e.g. `settings.CreateUserHome` used by signup, proxy, and hook provisioning) so they cannot drift again.
|
||||
- Keep it surgical; match surrounding style.
|
||||
|
||||
## 4. Add a regression test per fix
|
||||
|
||||
- Reuse the existing harnesses; add a focused test asserting the fixed behavior (and that the legitimate
|
||||
path still works). Commit tests alongside the fixes (`test(scope): …`, `Refs GHSA-…`).
|
||||
- Run `go test ./... && go vet ./...` before finishing.
|
||||
|
||||
## 5. Severity — set a CVSS vector, don't hand-assert
|
||||
|
||||
Set a CVSS v3.1 vector; GitHub derives the score **and** severity from it (overriding the plain `severity`
|
||||
field). Encode the real preconditions in the vector so the band is defensible:
|
||||
|
||||
- Requires a specific target configuration/platform (e.g. case-insensitive FS) → **AC:H**.
|
||||
- Unauthenticated vs needs an account → **PR:N / PR:L**.
|
||||
- Keep it consistent with the **predecessor CVE's** rating (an incomplete-fix follow-up should not outrank
|
||||
its parent). Bands: `0.1–3.9` low, `4.0–6.9` medium, `7.0–8.9` high, `9.0–10.0` critical.
|
||||
|
||||
```bash
|
||||
gh api -X PATCH /repos/filebrowser/filebrowser/security-advisories/GHSA-xxxx-xxxx-xxxx \
|
||||
-f cvss_vector_string='CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H' \
|
||||
--jq '{ghsa_id, severity, score: .cvss.score, vector: .cvss.vector_string}'
|
||||
```
|
||||
|
||||
## 6. Clean up the title
|
||||
|
||||
Rewrite reporter titles to the concise, sentence-case, backtick-free style of the published advisories
|
||||
(state the vuln; drop "Incomplete fix of…" prefixes and jargon). The title is the `summary` field:
|
||||
|
||||
```bash
|
||||
gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx \
|
||||
-f summary='Proxy-auth auto-provisioning ignores createUserDir and grants the server root scope'
|
||||
```
|
||||
|
||||
## 7. Rewrite the body into the standard structure
|
||||
|
||||
Reporter reports arrive in whatever shape the reporter used. Before drafting, rewrite the
|
||||
`description` into the sections below — **reusing the reporter's own wording wherever it is
|
||||
accurate**, rather than paraphrasing it. Drop the greeting, the offer to help, and any claim the
|
||||
verification in step 2 disproved. Keep sections in this order and omit the ones that don't apply:
|
||||
|
||||
| Section | Contents |
|
||||
| --- | --- |
|
||||
| `## Summary` | What the defect is, in two or three sentences. Note the version it was reported against and the range it was verified over. |
|
||||
| `## Details` | Root cause, naming `file.go`, the function, and a short quote of the **pre-fix** code. |
|
||||
| `## PoC` | The reporter's reproduction steps and observed result, trimmed to the essentials. |
|
||||
| `## Impact` | Who can exploit it (privilege level, preconditions) and what they get. |
|
||||
| `## Patches` | Fixed version plus a link to the fix commit, and one sentence on what the fix does. Mention it if the reporter re-tested and confirmed. |
|
||||
| `## Workarounds` | Real mitigations, or `None. Upgrade to vX.Y.Z.` |
|
||||
| `## Out of scope` | Anything in the original report deliberately **not** treated as a vulnerability, with the reasoning. Needed whenever the advisory is narrower than the report. |
|
||||
| `## References` | Fix and regression-test commit links. |
|
||||
|
||||
Use `##` headings (matching the published advisories) and keep the body in the maintainer's voice —
|
||||
first person ("I reproduced…") belongs only inside quoted PoC steps.
|
||||
|
||||
Send it as a file so the Markdown survives shell quoting:
|
||||
|
||||
```bash
|
||||
jq -Rs '{description: .}' desc.md \
|
||||
| gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx --input -
|
||||
```
|
||||
|
||||
## 8. Set affected & patched versions
|
||||
|
||||
The package is always `{ecosystem: "go", name: "github.com/filebrowser/filebrowser/v2"}`.
|
||||
|
||||
- `vulnerable_version_range` — `<= <latest released version>` (the newest tag; find it with
|
||||
`git tag --list 'v2.*' --sort=-version:refname | head -1`).
|
||||
- `patched_versions` — the **next** release that will actually ship the fix. It doesn't exist just
|
||||
because the branch does; it still has to be cut. **When unsure which version that will be, ask.**
|
||||
|
||||
Replace the placeholder versions below before sending:
|
||||
|
||||
```bash
|
||||
printf '%s' '{"vulnerabilities":[{"package":{"ecosystem":"go","name":"github.com/filebrowser/filebrowser/v2"},"vulnerable_version_range":"<= <latest>","patched_versions":"<next>","vulnerable_functions":[]}]}' \
|
||||
| gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx --input -
|
||||
```
|
||||
|
||||
## 9. Move state / close, by disposition
|
||||
|
||||
```bash
|
||||
gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx -f state=draft # fixed, awaiting release
|
||||
gh api -X PATCH .../security-advisories/GHSA-xxxx-xxxx-xxxx -f state=closed # duplicate / N-A / not-exploitable
|
||||
```
|
||||
|
||||
- **CONFIRMED & fixed** → metadata done → **draft**. Publish after the patched release ships.
|
||||
- **DUPLICATE / NOT APPLICABLE / NOT EXPLOITABLE** → **closed**.
|
||||
- **DEFERRED** (confirmed but not yet fixed) → leave in **triage** with a note.
|
||||
- The REST API **cannot post advisory comments** — replies to reporters (dup notice, evidence, links to
|
||||
the relevant tracking issue) must be posted manually in the advisory UI. Draft the text for the maintainer.
|
||||
|
||||
## 10. Release & publish
|
||||
|
||||
Push the branch, open a PR, merge, tag/release the `patched_versions` you set, then publish the drafts.
|
||||
Confirm outward-facing/irreversible advisory actions (close, publish) with the maintainer before doing them.
|
||||
@@ -2,6 +2,14 @@ name: Bug Report
|
||||
description: Report a bug in FileBrowser.
|
||||
labels: [bug, 'waiting: triage']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
**File Browser is being archived on 2026-09-01.** Bug reports are still read
|
||||
until then, but fixes are not guaranteed, and no further security fixes will
|
||||
be released. See the
|
||||
[README](https://github.com/filebrowser/filebrowser/blob/master/README.md)
|
||||
for the known unfixed issues and hardening guidance.
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Checklist
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Project sunset
|
||||
url: https://github.com/filebrowser/filebrowser/blob/master/README.md#project-status
|
||||
about: File Browser is archived on 2026-09-01. Please read this before opening an issue.
|
||||
- name: GitHub Discussions
|
||||
url: https://github.com/filebrowser/filebrowser/discussions
|
||||
about: Please ask questions and discuss features here.
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
Before submitting your PR, please indicate which issues are either fixed or closed by this PR. See [GitHub Help: Closing issues using keywords](https://help.github.com/articles/closing-issues-via-commit-messages/).
|
||||
|
||||
- [ ] I am aware the project is currently in **maintenance-only** mode and new feature requests won't be accepted. See [README](https://github.com/filebrowser/community/blob/master/README.md)
|
||||
- [ ] I am aware this project is being **archived on 2026-09-01**, that new features aren't accepted, and that bug fixes are looked at but not guaranteed to be merged. See [README](https://github.com/filebrowser/filebrowser/blob/master/README.md)
|
||||
- [ ] I am aware that translations MUST be made through [Transifex](https://app.transifex.com/file-browser/file-browser/) and that this PR is NOT a translation update
|
||||
- [ ] I am making a PR against the `master` branch.
|
||||
- [ ] I am sure File Browser can be successfully built. See [builds](https://github.com/filebrowser/community/blob/master/builds.md) and [development](https://github.com/filebrowser/community/blob/master/development.md).
|
||||
- [ ] I am sure File Browser can be successfully built. See [CONTRIBUTING.md](https://github.com/filebrowser/filebrowser/blob/master/CONTRIBUTING.md).
|
||||
@@ -2,6 +2,52 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||
|
||||
## [2.63.22](https://github.com/filebrowser/filebrowser/compare/v2.63.21...v2.63.22) (2026-07-27)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* enforce rules on recursive operations and expired proxy tokens ([#6053](https://github.com/filebrowser/filebrowser/issues/6053)) ([72faf6d](https://github.com/filebrowser/filebrowser/commit/72faf6dd3c85628e332d3e567124b86708ce2695))
|
||||
* make the sidebar scrollable when content overflows ([#6031](https://github.com/filebrowser/filebrowser/issues/6031)) ([a789f29](https://github.com/filebrowser/filebrowser/commit/a789f29ceec4734e7471592921d1ce67f1a10a7e))
|
||||
* unblock stalled and frozen uploads ([0b925cb](https://github.com/filebrowser/filebrowser/commit/0b925cbca940fe0b2726827cf66783da05c64f5e)), closes [#6006](https://github.com/filebrowser/filebrowser/issues/6006), references [#5987](https://github.com/filebrowser/filebrowser/issues/5987)
|
||||
* use absolute URLs for the PWA manifest icon sources ([#6032](https://github.com/filebrowser/filebrowser/issues/6032)) ([cfff843](https://github.com/filebrowser/filebrowser/commit/cfff84306af66deedfdc9248300919b3ddd9a7f0))
|
||||
## [2.63.21](https://github.com/filebrowser/filebrowser/compare/v2.63.20...v2.63.21) (2026-07-26)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **http:** canonicalize paths before checking access rules ([#6045](https://github.com/filebrowser/filebrowser/issues/6045)) ([e6d70cf](https://github.com/filebrowser/filebrowser/commit/e6d70cf24c0cd79a1787601dc99104ec7e7ca3ef))
|
||||
|
||||
### Reverts
|
||||
|
||||
* Revert "chore(deps): update all non-major dependencies (#5946)" ([0dd8905](https://github.com/filebrowser/filebrowser/commit/0dd89058867f87a7bc04aa7517d21528a280e27c)), references [#5946](https://github.com/filebrowser/filebrowser/issues/5946)
|
||||
## [2.63.20](https://github.com/filebrowser/filebrowser/compare/v2.63.19...v2.63.20) (2026-07-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use aria-selected ([67e893e](https://github.com/filebrowser/filebrowser/commit/67e893eee7ee411e166d3fcd759a87b6f0971277))
|
||||
* **users:** make the provisioned scope check atomic with the save ([fb6aeba](https://github.com/filebrowser/filebrowser/commit/fb6aeba9eae7b8eb401e0db325973781e1ffd08b))
|
||||
## [2.63.19](https://github.com/filebrowser/filebrowser/compare/v2.63.18...v2.63.19) (2026-07-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* accessibility and security improvements ([#6033](https://github.com/filebrowser/filebrowser/issues/6033)) ([b21b124](https://github.com/filebrowser/filebrowser/commit/b21b1245ae1b57f031b2f5d787f32a17532402c0))
|
||||
* **auth:** isolate auto-provisioned proxy and hook users to their own home ([8ddd3d1](https://github.com/filebrowser/filebrowser/commit/8ddd3d1db9b9f5727d0bf96ea0e7d9a25a8692b4))
|
||||
* **http:** delete abandoned TUS uploads through the scoped filesystem ([9bd79c3](https://github.com/filebrowser/filebrowser/commit/9bd79c3aaeb4a55b0e69cf8976c4a258db2f5e06))
|
||||
* **http:** enforce declared Upload-Length on TUS uploads ([4daddec](https://github.com/filebrowser/filebrowser/commit/4daddec6f200b03a721197d8c0b4b652c994894e))
|
||||
* **http:** enforce download permission on the checksum branch ([6c69b5c](https://github.com/filebrowser/filebrowser/commit/6c69b5cd895e15b29e563200a9a6dfc27b06525e))
|
||||
* **http:** run upload hooks for directories ([#6034](https://github.com/filebrowser/filebrowser/issues/6034)) ([9b78324](https://github.com/filebrowser/filebrowser/commit/9b78324d773c790951cc6a97840c4b55f66b5f3d))
|
||||
* process --FollowExternalSymlinks ([c05c668](https://github.com/filebrowser/filebrowser/commit/c05c66814891c3cccef394162e428444b53394e4))
|
||||
* return error instead of panicking on an unreadable directory during copy ([#6020](https://github.com/filebrowser/filebrowser/issues/6020)) ([ac46cf0](https://github.com/filebrowser/filebrowser/commit/ac46cf06719575477d5125e7472037c204b3702d))
|
||||
* **storage:** reject case-folded home directory collisions ([4b8a8d7](https://github.com/filebrowser/filebrowser/commit/4b8a8d72ce554dde378b5091da74aa930ea18327))
|
||||
* **upload:** handle encoded path conflicts safely ([#6040](https://github.com/filebrowser/filebrowser/issues/6040)) ([7361d91](https://github.com/filebrowser/filebrowser/commit/7361d91ea2e8cc200a0f40ac84adcd02aedc9ed2))
|
||||
## [2.63.18](https://github.com/filebrowser/filebrowser/compare/v2.63.17...v2.63.18) (2026-07-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* avoid recursive conflict checks for copy and move ([#6009](https://github.com/filebrowser/filebrowser/issues/6009)) ([dfc2e88](https://github.com/filebrowser/filebrowser/commit/dfc2e887e1a19d54984a0d7e39a2a63caf73ef19))
|
||||
* deduplicate PT language ([4470288](https://github.com/filebrowser/filebrowser/commit/4470288ba1828a14453a99348fd22c62aa0b9460))
|
||||
* **preview:** keep the EPUB table-of-contents button clear of the header ([#6010](https://github.com/filebrowser/filebrowser/issues/6010)) ([aac2516](https://github.com/filebrowser/filebrowser/commit/aac25166378422135e624e305c410c54a39374fb))
|
||||
|
||||
## [2.63.17](https://github.com/filebrowser/filebrowser/compare/v2.63.16...v2.63.17) (2026-06-27)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Contributing
|
||||
|
||||
> [!WARNING]
|
||||
> File Browser is being archived on **2026-09-01**. New features are not being accepted. Bug-fix pull requests are still looked at until that date, but there is no guarantee they will be merged.
|
||||
>
|
||||
> The instructions below are kept because they remain useful to anyone building the project from source.
|
||||
|
||||
If you're interested in contributing to this project, this is the best place to start. Before contributing to this project, please take a bit of time to read our [Code of Conduct](code-of-conduct.md). Also, note that this project is open-source and licensed under [Apache License 2.0](LICENSE).
|
||||
|
||||
## Project Structure
|
||||
@@ -99,6 +104,8 @@ task release
|
||||
|
||||
## Translations
|
||||
|
||||
Translations are synced from Transifex until 2026-09-01; after that the integration stops and translations submitted there will no longer reach this repository.
|
||||
|
||||
Translations are managed on Transifex, which is an online website where everyone can contribute and translate strings for our project. It automatically syncs with the main language file \(in English\) and,, for you to contribute, you just need to:
|
||||
|
||||
1. Go to our Transifex web page: [app.transifex.com/file-browser/file-browser](https://app.transifex.com/file-browser/file-browser/)
|
||||
|
||||
@@ -1,31 +1,52 @@
|
||||
> [!WARNING]
|
||||
> **File Browser is being archived on 2026-09-01.** On that date this repository becomes read-only. There will be no further releases, and no security fixes, including for the [known unfixed issues](#security) listed below.
|
||||
>
|
||||
> Existing releases and Docker images stay online and will not be withdrawn. All documentation lives in this repository under [`www/docs`](www/docs).
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/filebrowser/filebrowser/master/branding/banner.png" width="550"/>
|
||||
</p>
|
||||
|
||||
[](https://github.com/filebrowser/filebrowser/actions/workflows/ci.yaml)
|
||||
[](https://goreportcard.com/report/github.com/filebrowser/filebrowser/v2)
|
||||
[](https://github.com/filebrowser/filebrowser/releases/latest)
|
||||
|
||||
File Browser provides a file managing interface within a specified directory and it can be used to upload, delete, preview and edit your files. It is a **create-your-own-cloud**-kind of software where you can just install it on your server, direct it to a path and access your files through a nice web interface.
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation on how to install, configure, and contribute to this project is hosted at [filebrowser.org](https://filebrowser.org).
|
||||
Documentation on how to install, configure, and build this project lives in [`www/docs`](www/docs) in this repository.
|
||||
|
||||
## Project Status
|
||||
|
||||
This project is a finished product which fulfills its goal: be a single binary web File Browser which can be run by anyone anywhere. That means that File Browser is currently on **maintenance-only** mode. Therefore, please note the following:
|
||||
This project is a finished product which fulfills its goal: be a single binary web File Browser which can be run by anyone anywhere. It has been in **maintenance-only** mode, and is now being wound down.
|
||||
|
||||
- It can take a while until someone gets back to you. Please be patient.
|
||||
- [Issues](https://github.com/filebrowser/filebrowser/issues) are meant to track bugs. Unrelated issues will be converted into [discussions](https://github.com/filebrowser/filebrowser/discussions).
|
||||
- The priority is triaging issues, addressing security issues and reviewing pull requests meant to solve bugs.
|
||||
- No new features are planned. Pull requests for new features are not guaranteed to be reviewed.
|
||||
- The repository is archived on **2026-09-01** and becomes read-only.
|
||||
- One last planned release ships before that date. It contains no functional changes, only a wind-down notice.
|
||||
- After that date there are no further releases, bug fixes, or security fixes.
|
||||
- Existing releases and Docker images stay online and are not withdrawn.
|
||||
|
||||
Please read [@hacdias' personal reflection](https://hacdias.com/2026/03/11/filebrowser/) on the project status.
|
||||
|
||||
## Security
|
||||
|
||||
No further security fixes will be released. Two known issue classes remain unaddressed and will not be fixed:
|
||||
|
||||
- **Command execution, runner, and hooks** (opt-in, disabled by default, [#5199](https://github.com/filebrowser/filebrowser/issues/5199))
|
||||
- **Session and JWT handling** ([#5216](https://github.com/filebrowser/filebrowser/issues/5216))
|
||||
|
||||
Previously published advisories are listed under [security advisories](https://github.com/filebrowser/filebrowser/security/advisories). Reporting instructions, which apply until 2026-09-01, are in [SECURITY.md](SECURITY.md).
|
||||
|
||||
If you keep running File Browser after the archive date, treat it as unmaintained software:
|
||||
|
||||
- **Do not expose it directly to the internet.** Put it behind a reverse proxy that terminates TLS and performs its own authentication.
|
||||
- **Keep the command runner disabled.** It is off by default, so leave it off. See [#5199](https://github.com/filebrowser/filebrowser/issues/5199) and [`www/docs/command-execution.md`](www/docs/command-execution.md).
|
||||
- **Run it unprivileged, inside a container**, with only the directory you intend to serve mounted into it.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are always welcome. To start contributing to this project, read our [guidelines](CONTRIBUTING.md) first.
|
||||
New features are not being accepted. Bug reports and bug-fix pull requests are still looked at until 2026-09-01, but there is no guarantee that they will be merged.
|
||||
|
||||
[CONTRIBUTING.md](CONTRIBUTING.md) documents how to build and develop the project, which remains useful to anyone forking it.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
+24
-14
@@ -1,26 +1,36 @@
|
||||
# Security Policy
|
||||
|
||||
> [!WARNING]
|
||||
> File Browser is being archived on **2026-09-01**. Security reports are not accepted after that date, and no further security fixes will be released. The known unfixed issues, and hardening guidance for anyone who keeps running File Browser, are listed under [Security](README.md#security) in the README.
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are
|
||||
currently being supported with security updates.
|
||||
| Version | Supported |
|
||||
| ------- | ------------------- |
|
||||
| 2.x | ✅ until 2026-09-01 |
|
||||
| < 2.0 | ❌ |
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 2.x | :white_check_mark: |
|
||||
| < 2.0 | :x: |
|
||||
## Before Reporting
|
||||
|
||||
This project is in maintenance-only mode and is being wound down. To avoid duplicates, first check the [existing advisories](https://github.com/filebrowser/filebrowser/security/advisories) and open issues, and confirm:
|
||||
|
||||
- **It concerns this project, not a fork.** Reports about code, features, or endpoints that don't exist here belong to the relevant fork.
|
||||
- **It isn't an already-known class** that remains unaddressed. Those are listed under [Security](README.md#security) in the README; reports covering them are likely to be closed as duplicates.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Vulnerabilities with critical impact should be reported on the [Security](https://github.com/filebrowser/filebrowser/security) page of this repository, which is a private way of communicating vulnerabilities to maintainers. This project is in maintenance-only mode and it can take a while until someone gets back to you.
|
||||
Until 2026-09-01:
|
||||
|
||||
If it is not a critical vulnerability, please open an issue and we will categorize it as a security issue. By giving visibility, we can get more help from the community at fixing such issues.
|
||||
- **Critical:** report privately via the [Security](https://github.com/filebrowser/filebrowser/security) page.
|
||||
- **Non-critical:** open a public issue so the community can help; we'll label it as a security issue.
|
||||
|
||||
When reporting an issue, where possible, please provide at least:
|
||||
Please include, where possible:
|
||||
|
||||
* The commit version the issue was identified at
|
||||
* A proof of concept (plaintext; no binaries)
|
||||
* Steps to reproduce
|
||||
* Your recommended remediation(s), if any.
|
||||
- The commit the issue was found at
|
||||
- A plaintext proof of concept (no binaries)
|
||||
- Steps to reproduce
|
||||
- Recommended remediation, if any
|
||||
|
||||
The File Browser team is a volunteer-only effort, and may reach back out for clarification.
|
||||
We're a volunteer effort, so responses can take a while, and we may reach out for clarification. A report being accepted does not guarantee a fix will ship before the archive date.
|
||||
|
||||
After 2026-09-01 this repository is read-only and reports can no longer be submitted or acted on.
|
||||
+7
-6
@@ -157,15 +157,16 @@ func (a *HookAuth) SaveUser() (*users.User, error) {
|
||||
}
|
||||
u = a.GetUser(d)
|
||||
|
||||
userHome, err := a.Settings.MakeUserDir(u.Username, u.Scope, a.Server.Root)
|
||||
// A scope explicitly returned by the hook takes precedence over the
|
||||
// automatic per-user home directory derivation.
|
||||
_, explicitScope := a.Fields.Values["user.scope"]
|
||||
derivedScope, err := a.Settings.CreateUserHome(u, a.Server.Root, explicitScope)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("user: failed to mkdir user home dir: [%s]", userHome)
|
||||
return nil, err
|
||||
}
|
||||
u.Scope = userHome
|
||||
log.Printf("user: %s, home dir: [%s].", u.Username, userHome)
|
||||
log.Printf("user: %s, home dir: [%s].", u.Username, u.Scope)
|
||||
|
||||
err = a.Users.Save(u)
|
||||
if err != nil {
|
||||
if err := a.Users.SaveProvisioned(u, derivedScope); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if p := !users.CheckPwd(a.Cred.Password, u.Password); len(a.Fields.Values) > 1 || p {
|
||||
|
||||
@@ -5,6 +5,9 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// writeHookScript writes a POSIX shell script to a temp file and returns its
|
||||
@@ -86,3 +89,68 @@ fi
|
||||
t.Fatalf("expected action %q, got %q", "auth", action)
|
||||
}
|
||||
}
|
||||
|
||||
// newHookAuth builds a HookAuth for a freshly provisioned user with the given
|
||||
// parsed hook fields (hook.action=auth is added automatically).
|
||||
func newHookAuth(store *mockUserStore, s *settings.Settings, srv *settings.Server, username string, fields map[string]string) *HookAuth {
|
||||
fields["hook.action"] = "auth"
|
||||
return &HookAuth{
|
||||
Users: store,
|
||||
Settings: s,
|
||||
Server: srv,
|
||||
Cred: hookCred{Username: username, Password: "a-strong-password"},
|
||||
Fields: hookFields{Values: fields},
|
||||
}
|
||||
}
|
||||
|
||||
// With CreateUserDir enabled and no explicit scope from the hook, a provisioned
|
||||
// hook user must receive its own home directory rather than the server root.
|
||||
func TestHookSaveUserCreateUserDirIsolatesScope(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
store := &mockUserStore{users: make(map[string]*users.User)}
|
||||
srv := &settings.Server{Root: t.TempDir()}
|
||||
s := &settings.Settings{
|
||||
Key: []byte("key"),
|
||||
CreateUserDir: true,
|
||||
UserHomeBasePath: "/users",
|
||||
Defaults: settings.UserDefaults{
|
||||
Scope: ".",
|
||||
Perm: users.Permissions{Create: true},
|
||||
},
|
||||
}
|
||||
|
||||
u, err := newHookAuth(store, s, srv, "alice", map[string]string{}).SaveUser()
|
||||
if err != nil {
|
||||
t.Fatalf("SaveUser error: %v", err)
|
||||
}
|
||||
if u.Scope != "/users/alice" {
|
||||
t.Errorf("hook user without explicit scope: expected /users/alice, got %q", u.Scope)
|
||||
}
|
||||
}
|
||||
|
||||
// A scope explicitly returned by the hook takes precedence over the automatic
|
||||
// per-user home directory derivation.
|
||||
func TestHookSaveUserRespectsExplicitScope(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
store := &mockUserStore{users: make(map[string]*users.User)}
|
||||
srv := &settings.Server{Root: t.TempDir()}
|
||||
s := &settings.Settings{
|
||||
Key: []byte("key"),
|
||||
CreateUserDir: true,
|
||||
UserHomeBasePath: "/users",
|
||||
Defaults: settings.UserDefaults{
|
||||
Scope: ".",
|
||||
Perm: users.Permissions{Create: true},
|
||||
},
|
||||
}
|
||||
|
||||
u, err := newHookAuth(store, s, srv, "teamlead", map[string]string{"user.scope": "/shared/team"}).SaveUser()
|
||||
if err != nil {
|
||||
t.Fatalf("SaveUser error: %v", err)
|
||||
}
|
||||
if u.Scope != "/shared/team" {
|
||||
t.Errorf("explicit hook scope should win, got %q", u.Scope)
|
||||
}
|
||||
}
|
||||
+3
-6
@@ -50,15 +50,12 @@ func (a ProxyAuth) createUser(usr users.Store, setting *settings.Settings, srv *
|
||||
user.Perm.Execute = false
|
||||
user.Commands = []string{}
|
||||
|
||||
var userHome string
|
||||
userHome, err = setting.MakeUserDir(user.Username, user.Scope, srv.Root)
|
||||
if err != nil {
|
||||
var derivedScope bool
|
||||
if derivedScope, err = setting.CreateUserHome(user, srv.Root, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user.Scope = userHome
|
||||
|
||||
err = usr.Save(user)
|
||||
if err != nil {
|
||||
if err = usr.SaveProvisioned(user, derivedScope); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
+63
-1
@@ -2,6 +2,7 @@ package auth
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
fberrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
@@ -22,13 +23,31 @@ func (m *mockUserStore) Get(_ string, _ bool, id interface{}) (*users.User, erro
|
||||
return nil, fberrors.ErrNotExist
|
||||
}
|
||||
|
||||
func (m *mockUserStore) GetByScope(_ string) (*users.User, error) { return nil, fberrors.ErrNotExist }
|
||||
func (m *mockUserStore) GetByScope(scope string) (*users.User, error) {
|
||||
for _, u := range m.users {
|
||||
if strings.EqualFold(u.Scope, scope) {
|
||||
return u, nil
|
||||
}
|
||||
}
|
||||
return nil, fberrors.ErrNotExist
|
||||
}
|
||||
|
||||
func (m *mockUserStore) Gets(_ string, _ bool) ([]*users.User, error) { return nil, nil }
|
||||
func (m *mockUserStore) Update(_ *users.User, _ ...string) error { return nil }
|
||||
func (m *mockUserStore) Save(user *users.User) error {
|
||||
m.users[user.Username] = user
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockUserStore) SaveProvisioned(user *users.User, derivedScope bool) error {
|
||||
if derivedScope {
|
||||
if _, err := m.GetByScope(user.Scope); err == nil {
|
||||
return fberrors.ErrExist
|
||||
}
|
||||
}
|
||||
return m.Save(user)
|
||||
}
|
||||
|
||||
func (m *mockUserStore) Delete(_ interface{}) error { return nil }
|
||||
func (m *mockUserStore) LastUpdate(_ uint) int64 { return 0 }
|
||||
|
||||
@@ -78,3 +97,46 @@ func TestProxyAuthCreateUserRestrictsDefaults(t *testing.T) {
|
||||
t.Error("auto-provisioned proxy user should retain Create permission from defaults")
|
||||
}
|
||||
}
|
||||
|
||||
// With CreateUserDir enabled, two distinct proxy-authenticated users must each
|
||||
// receive their own home directory instead of both inheriting the server root.
|
||||
func TestProxyAuthCreateUserDirIsolatesScope(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
store := &mockUserStore{users: make(map[string]*users.User)}
|
||||
srv := &settings.Server{Root: t.TempDir()}
|
||||
s := &settings.Settings{
|
||||
Key: []byte("key"),
|
||||
AuthMethod: MethodProxyAuth,
|
||||
CreateUserDir: true,
|
||||
UserHomeBasePath: "/users",
|
||||
Defaults: settings.UserDefaults{
|
||||
Scope: ".",
|
||||
Perm: users.Permissions{Create: true},
|
||||
},
|
||||
}
|
||||
|
||||
auth := ProxyAuth{Header: "X-Remote-User"}
|
||||
provision := func(name string) *users.User {
|
||||
req, _ := http.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req.Header.Set("X-Remote-User", name)
|
||||
u, err := auth.Auth(req, store, s, srv)
|
||||
if err != nil {
|
||||
t.Fatalf("Auth(%q) error: %v", name, err)
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
alice := provision("alice")
|
||||
bob := provision("bob")
|
||||
|
||||
if alice.Scope == "/" || bob.Scope == "/" {
|
||||
t.Fatalf("provisioned users inherited the server root: alice=%q bob=%q", alice.Scope, bob.Scope)
|
||||
}
|
||||
if alice.Scope == bob.Scope {
|
||||
t.Fatalf("distinct users must get distinct scopes, both got %q", alice.Scope)
|
||||
}
|
||||
if alice.Scope != "/users/alice" {
|
||||
t.Errorf("expected /users/alice, got %q", alice.Scope)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@ import (
|
||||
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/auth"
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
)
|
||||
|
||||
// TestEnvCollisions ensures that there are no collisions in the produced environment
|
||||
@@ -33,3 +37,25 @@ func testEnvCollisions(t *testing.T, cmd *cobra.Command) {
|
||||
t.Errorf("Found duplicate environment variable keys for command %q: %v", cmd.Name(), duplicates)
|
||||
}
|
||||
}
|
||||
|
||||
// TestGetSettingsFollowExternalSymlinks ensures that the followExternalSymlinks
|
||||
// flag is persisted to the server config when set via "config set".
|
||||
func TestGetSettingsFollowExternalSymlinks(t *testing.T) {
|
||||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||
addConfigFlags(flags)
|
||||
|
||||
if err := flags.Parse([]string{"--followExternalSymlinks"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
set := &settings.Settings{AuthMethod: auth.MethodJSONAuth}
|
||||
ser := &settings.Server{}
|
||||
|
||||
if _, err := getSettings(flags, set, ser, &auth.JSONAuth{}, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !ser.FollowExternalSymlinks {
|
||||
t.Error("expected FollowExternalSymlinks to be persisted as true")
|
||||
}
|
||||
}
|
||||
@@ -314,6 +314,8 @@ func getSettings(flags *pflag.FlagSet, set *settings.Settings, ser *settings.Ser
|
||||
case "disableImageResolutionCalc":
|
||||
ser.ImageResolutionCal, err = flags.GetBool(flag.Name)
|
||||
ser.ImageResolutionCal = !ser.ImageResolutionCal
|
||||
case "followExternalSymlinks":
|
||||
ser.FollowExternalSymlinks, err = flags.GetBool(flag.Name)
|
||||
|
||||
// Settings flags from [addConfigFlags]
|
||||
case "signup":
|
||||
|
||||
@@ -192,6 +192,11 @@ user created with the credentials from options "username" and "password".`,
|
||||
}
|
||||
setupLog(server.Log)
|
||||
|
||||
log.Println("NOTICE: File Browser is being wound down.")
|
||||
log.Println("NOTICE: The project is archived on 2026-09-01, after which there will be no")
|
||||
log.Println("NOTICE: further releases and no security fixes. Known unfixed issues are at")
|
||||
log.Println("NOTICE: https://github.com/filebrowser/filebrowser/security/advisories")
|
||||
|
||||
root, err := filepath.Abs(server.Root)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
// CaseInsensitive reports whether the filesystem backing root treats file names
|
||||
// case-insensitively, as NTFS, APFS, HFS+, exFAT and CIFS do. It creates a
|
||||
// probe file and looks it up under a different case, mirroring how git detects
|
||||
// core.ignoreCase.
|
||||
//
|
||||
// It probes rather than inferring from runtime.GOOS because neither direction
|
||||
// holds: macOS can be formatted case-sensitively, and a Linux host commonly
|
||||
// serves a case-insensitive mount. When the root cannot be written to, it falls
|
||||
// back to the host's usual default rather than assuming case-sensitivity, since
|
||||
// a read-only root is still exposed to the disclosure this guards against.
|
||||
func CaseInsensitive(fs afero.Fs, root string) bool {
|
||||
probe, err := afero.TempFile(fs, root, "fb-case-probe-")
|
||||
if err != nil {
|
||||
return runtime.GOOS == "windows" || runtime.GOOS == "darwin"
|
||||
}
|
||||
|
||||
name := probe.Name()
|
||||
probe.Close()
|
||||
defer fs.Remove(name) //nolint:errcheck
|
||||
|
||||
dir, base := filepath.Split(name)
|
||||
_, err = fs.Stat(filepath.Join(dir, strings.ToUpper(base)))
|
||||
return err == nil
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
// MemMapFs keys its entries by exact name, so it is case-sensitive.
|
||||
func TestCaseInsensitiveReportsCaseSensitiveFs(t *testing.T) {
|
||||
fs := afero.NewMemMapFs()
|
||||
if err := fs.MkdirAll("/root", 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if CaseInsensitive(fs, "/root") {
|
||||
t.Error("CaseInsensitive() = true for a case-sensitive filesystem; want false")
|
||||
}
|
||||
assertNoProbeLeft(t, fs, "/root")
|
||||
}
|
||||
|
||||
// Whatever the verdict, the probe file must not be left behind in the user's
|
||||
// data directory.
|
||||
func TestCaseInsensitiveRemovesProbe(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
fs := afero.NewOsFs()
|
||||
|
||||
t.Logf("CaseInsensitive(%s) = %v", root, CaseInsensitive(fs, root))
|
||||
assertNoProbeLeft(t, fs, root)
|
||||
}
|
||||
|
||||
func assertNoProbeLeft(t *testing.T, fs afero.Fs, root string) {
|
||||
t.Helper()
|
||||
entries, err := afero.ReadDir(fs, root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, e := range entries {
|
||||
if strings.HasPrefix(e.Name(), "fb-case-probe-") {
|
||||
t.Errorf("probe file left behind: %s", e.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package fileutils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -9,6 +10,54 @@ import (
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
// failingOpenFs wraps an afero.Fs and makes Open fail for one specific path,
|
||||
// while every other operation (including Stat) is delegated unchanged. It
|
||||
// simulates a directory that can be stat-ed but not opened/read — for example
|
||||
// an unreadable sub-directory, or one whose permissions changed or that was
|
||||
// removed after its parent was listed (a TOCTOU race) — encountered during a
|
||||
// recursive copy.
|
||||
type failingOpenFs struct {
|
||||
afero.Fs
|
||||
failOpen string
|
||||
}
|
||||
|
||||
func (f *failingOpenFs) Open(name string) (afero.File, error) {
|
||||
if path.Clean(name) == path.Clean(f.failOpen) {
|
||||
return nil, os.ErrPermission
|
||||
}
|
||||
return f.Fs.Open(name)
|
||||
}
|
||||
|
||||
// CopyDir is documented to keep going when it hits an error and to report the
|
||||
// error afterwards. A sub-directory that cannot be opened must therefore yield
|
||||
// an error (and leave the other, readable entries copied) rather than
|
||||
// panicking on a nil directory handle.
|
||||
func TestCopyDirUnreadableSubdirReturnsError(t *testing.T) {
|
||||
mem := afero.NewMemMapFs()
|
||||
if err := mem.MkdirAll("/srcdir/sub", 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := afero.WriteFile(mem, "/srcdir/ok.txt", []byte("readable"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
afs := &failingOpenFs{Fs: mem, failOpen: "/srcdir/sub"}
|
||||
|
||||
err := Copy(afs, "/srcdir", "/dstdir", 0o644, 0o755)
|
||||
if err == nil {
|
||||
t.Fatal("expected an error when a sub-directory cannot be opened")
|
||||
}
|
||||
|
||||
// The readable sibling must still have been copied (continue-on-error).
|
||||
data, readErr := afero.ReadFile(afs, "/dstdir/ok.txt")
|
||||
if readErr != nil {
|
||||
t.Fatalf("readable sibling was not copied: %v", readErr)
|
||||
}
|
||||
if string(data) != "readable" {
|
||||
t.Fatalf("unexpected copied content: %q", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
// Copying an in-scope directory that contains a symlink whose target escapes
|
||||
// the user's scope must not dereference that symlink into the destination.
|
||||
// Otherwise a scoped user could exfiltrate out-of-scope file content via the
|
||||
|
||||
+6
-1
@@ -23,7 +23,12 @@ func CopyDir(afs afero.Fs, source, dest string, fileMode, dirMode fs.FileMode) e
|
||||
return err
|
||||
}
|
||||
|
||||
dir, _ := afs.Open(source)
|
||||
dir, err := afs.Open(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dir.Close()
|
||||
|
||||
obs, err := dir.Readdir(-1)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Generated
+21
-21
@@ -28,7 +28,7 @@ importers:
|
||||
version: 1.11.20
|
||||
dompurify:
|
||||
specifier: ^3.2.6
|
||||
version: 3.4.4
|
||||
version: 3.4.12
|
||||
epubjs:
|
||||
specifier: ^0.3.93
|
||||
version: 0.3.93
|
||||
@@ -131,7 +131,7 @@ importers:
|
||||
version: 0.9.1(typescript@5.9.3)(vue@3.5.34(typescript@5.9.3))
|
||||
autoprefixer:
|
||||
specifier: ^10.4.21
|
||||
version: 10.5.0(postcss@8.5.14)
|
||||
version: 10.5.0(postcss@8.5.18)
|
||||
eslint:
|
||||
specifier: ^10.0.0
|
||||
version: 10.4.0
|
||||
@@ -146,7 +146,7 @@ importers:
|
||||
version: 10.9.1(@typescript-eslint/parser@8.56.0(eslint@10.4.0)(typescript@5.9.3))(eslint@10.4.0)(vue-eslint-parser@10.4.0(eslint@10.4.0))
|
||||
postcss:
|
||||
specifier: ^8.5.6
|
||||
version: 8.5.14
|
||||
version: 8.5.18
|
||||
prettier:
|
||||
specifier: ^3.6.2
|
||||
version: 3.8.3
|
||||
@@ -1990,8 +1990,8 @@ packages:
|
||||
dom-walk@0.1.2:
|
||||
resolution: {integrity: sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==}
|
||||
|
||||
dompurify@3.4.4:
|
||||
resolution: {integrity: sha512-r8K7KGKEcztXfA/nfabSYB2hg9tDphORJTdf8xprN/luSLGmNhOBN8dm1/SYjqLLet6YUFEXOcrdTuwryp/Bew==}
|
||||
dompurify@3.4.12:
|
||||
resolution: {integrity: sha512-zQvGet8Z2sWbQhCmfFz/T5QWH2oBmjnqK3qvOjaqaNLrLEF912WamU+ohnTp0TCep/MFVHpdJuCZEdFOdTnEFg==}
|
||||
|
||||
electron-to-chromium@1.5.340:
|
||||
resolution: {integrity: sha512-908qahOGocRMinT2nM3ajCEM99H4iPdv84eagPP3FfZy/1ZGeOy2CZYzjhms81ckOPCXPlW7LkY4XpxD8r1DrA==}
|
||||
@@ -2538,8 +2538,8 @@ packages:
|
||||
engines: {node: '>=8', npm: '>=5'}
|
||||
hasBin: true
|
||||
|
||||
nanoid@3.3.12:
|
||||
resolution: {integrity: sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==}
|
||||
nanoid@3.3.16:
|
||||
resolution: {integrity: sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==}
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
@@ -2639,8 +2639,8 @@ packages:
|
||||
postcss-value-parser@4.2.0:
|
||||
resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==}
|
||||
|
||||
postcss@8.5.14:
|
||||
resolution: {integrity: sha512-SoSL4+OSEtR99LHFZQiJLkT59C5B1amGO1NzTwj7TT1qCUgUO6hxOvzkOYxD+vMrXBM3XJIKzokoERdqQq/Zmg==}
|
||||
postcss@8.5.18:
|
||||
resolution: {integrity: sha512-xdB1oSLHbz1vRWgCDalrCqEFTWzFlhqFC5tIHLMOSUIjhm3XXQ1qrFy8S/ESr1JYRRXqM3c1QFiMZUJdUTqyMQ==}
|
||||
engines: {node: ^10 || ^12 || >=14}
|
||||
|
||||
prelude-ls@1.2.1:
|
||||
@@ -2824,8 +2824,8 @@ packages:
|
||||
systemjs@6.15.1:
|
||||
resolution: {integrity: sha512-Nk8c4lXvMB98MtbmjX7JwJRgJOL8fluecYCfCeYBznwmpOs8Bf15hLM6z4z71EDAhQVrQrI+wt1aLWSXZq+hXA==}
|
||||
|
||||
tabbable@6.4.0:
|
||||
resolution: {integrity: sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg==}
|
||||
tabbable@6.5.0:
|
||||
resolution: {integrity: sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==}
|
||||
|
||||
tar-mini@0.2.0:
|
||||
resolution: {integrity: sha512-+qfUHz700DWnRutdUsxRRVZ38G1Qr27OetwaMYTdg8hcPxf46U0S1Zf76dQMWRBmusOt2ZCK5kbIaiLkoGO7WQ==}
|
||||
@@ -4644,7 +4644,7 @@ snapshots:
|
||||
'@vue/shared': 3.5.34
|
||||
estree-walker: 2.0.2
|
||||
magic-string: 0.30.21
|
||||
postcss: 8.5.14
|
||||
postcss: 8.5.18
|
||||
source-map-js: 1.2.1
|
||||
|
||||
'@vue/compiler-ssr@3.5.34':
|
||||
@@ -4808,13 +4808,13 @@ snapshots:
|
||||
'@babel/parser': 7.29.3
|
||||
ast-kit: 2.2.0
|
||||
|
||||
autoprefixer@10.5.0(postcss@8.5.14):
|
||||
autoprefixer@10.5.0(postcss@8.5.18):
|
||||
dependencies:
|
||||
browserslist: 4.28.2
|
||||
caniuse-lite: 1.0.30001788
|
||||
fraction.js: 5.3.4
|
||||
picocolors: 1.1.1
|
||||
postcss: 8.5.14
|
||||
postcss: 8.5.18
|
||||
postcss-value-parser: 4.2.0
|
||||
|
||||
babel-plugin-polyfill-corejs2@0.4.17(@babel/core@7.29.0):
|
||||
@@ -4946,7 +4946,7 @@ snapshots:
|
||||
|
||||
dom-walk@0.1.2: {}
|
||||
|
||||
dompurify@3.4.4:
|
||||
dompurify@3.4.12:
|
||||
optionalDependencies:
|
||||
'@types/trusted-types': 2.0.7
|
||||
|
||||
@@ -5231,7 +5231,7 @@ snapshots:
|
||||
|
||||
focus-trap@8.0.0:
|
||||
dependencies:
|
||||
tabbable: 6.4.0
|
||||
tabbable: 6.5.0
|
||||
optional: true
|
||||
|
||||
fraction.js@5.3.4: {}
|
||||
@@ -5517,7 +5517,7 @@ snapshots:
|
||||
'@babel/runtime': 7.28.6
|
||||
global: 4.4.0
|
||||
|
||||
nanoid@3.3.12: {}
|
||||
nanoid@3.3.16: {}
|
||||
|
||||
natural-compare@1.4.0: {}
|
||||
|
||||
@@ -5604,9 +5604,9 @@ snapshots:
|
||||
|
||||
postcss-value-parser@4.2.0: {}
|
||||
|
||||
postcss@8.5.14:
|
||||
postcss@8.5.18:
|
||||
dependencies:
|
||||
nanoid: 3.3.12
|
||||
nanoid: 3.3.16
|
||||
picocolors: 1.1.1
|
||||
source-map-js: 1.2.1
|
||||
|
||||
@@ -5802,7 +5802,7 @@ snapshots:
|
||||
|
||||
systemjs@6.15.1: {}
|
||||
|
||||
tabbable@6.4.0:
|
||||
tabbable@6.5.0:
|
||||
optional: true
|
||||
|
||||
tar-mini@0.2.0: {}
|
||||
@@ -5963,7 +5963,7 @@ snapshots:
|
||||
dependencies:
|
||||
lightningcss: 1.32.0
|
||||
picomatch: 4.0.4
|
||||
postcss: 8.5.14
|
||||
postcss: 8.5.18
|
||||
rolldown: 1.0.1
|
||||
tinyglobby: 0.2.16
|
||||
optionalDependencies:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, user-scalable=no"
|
||||
content="width=device-width, initial-scale=1"
|
||||
/>
|
||||
|
||||
[{[ if .ReCaptcha -]}]
|
||||
@@ -55,12 +55,16 @@
|
||||
short_name: window.FileBrowser.Name || "File Browser",
|
||||
icons: [
|
||||
{
|
||||
src: window.__prependStaticUrl("/img/icons/android-chrome-192x192.png"),
|
||||
src:
|
||||
window.location.origin +
|
||||
window.__prependStaticUrl("/img/icons/android-chrome-192x192.png"),
|
||||
sizes: "192x192",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: window.__prependStaticUrl("/img/icons/android-chrome-512x512.png"),
|
||||
src:
|
||||
window.location.origin +
|
||||
window.__prependStaticUrl("/img/icons/android-chrome-512x512.png"),
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1 class="sr-only">{{ name }}</h1>
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
</template>
|
||||
@@ -9,6 +10,7 @@ import { ref, onMounted, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { setHtmlLocale } from "./i18n";
|
||||
import { getMediaPreference, getTheme, setTheme } from "./utils/theme";
|
||||
import { name } from "./utils/constants";
|
||||
|
||||
const { locale } = useI18n();
|
||||
|
||||
@@ -31,3 +33,17 @@ watch(locale, (newValue) => {
|
||||
newValue && setHtmlLocale(newValue);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -57,6 +57,9 @@ const container = ref<HTMLDivElement | null>(null);
|
||||
onMounted(() => {
|
||||
if (!decodeUTIF() && imgex.value !== null) {
|
||||
imgex.value.src = props.src;
|
||||
imgex.value.alt = decodeURIComponent(
|
||||
props.src.split("/").pop() || "preview"
|
||||
);
|
||||
}
|
||||
|
||||
props.classList.forEach((className) =>
|
||||
@@ -88,6 +91,9 @@ watch(
|
||||
() => {
|
||||
if (!decodeUTIF() && imgex.value !== null) {
|
||||
imgex.value.src = props.src;
|
||||
imgex.value.alt = decodeURIComponent(
|
||||
props.src.split("/").pop() || "preview"
|
||||
);
|
||||
}
|
||||
|
||||
scale.value = 1;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<img
|
||||
v-if="!readOnly && type === 'image' && isThumbsEnabled"
|
||||
v-lazy="thumbnailUrl"
|
||||
:alt="name"
|
||||
/>
|
||||
<i v-else class="material-icons"></i>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<header>
|
||||
<img v-if="showLogo" :src="logoURL" />
|
||||
<img v-if="showLogo" :src="logoURL" alt="File Browser" />
|
||||
<Action
|
||||
v-if="showMenu"
|
||||
class="menu-button"
|
||||
|
||||
@@ -38,6 +38,7 @@ import { useRoute } from "vue-router";
|
||||
import { useLayoutStore } from "@/stores/layout";
|
||||
|
||||
import * as upload from "@/utils/upload";
|
||||
import buttons from "@/utils/buttons";
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
@@ -66,9 +67,13 @@ const uploadInput = async (event: Event) => {
|
||||
|
||||
const path = route.path.endsWith("/") ? route.path : route.path + "/";
|
||||
|
||||
// Checking the destination hits the server, so show it is working rather
|
||||
// than leaving the action looking inert until the upload starts.
|
||||
buttons.loading("upload");
|
||||
const conflict = await upload.checkConflict(uploadFiles, path);
|
||||
|
||||
if (conflict.length > 0) {
|
||||
buttons.done("upload");
|
||||
layoutStore.showHover({
|
||||
prompt: "resolve-conflict",
|
||||
props: {
|
||||
|
||||
@@ -71,7 +71,9 @@ const event = {
|
||||
describe("copy and move conflict prompts", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(checkConflict).mockResolvedValue(conflict);
|
||||
vi.mocked(checkConflict).mockResolvedValue(
|
||||
conflict as ConflictingResource[]
|
||||
);
|
||||
});
|
||||
|
||||
it("waits for copy conflict detection before calling the copy API", async () => {
|
||||
|
||||
@@ -56,6 +56,8 @@ nav {
|
||||
position: fixed;
|
||||
top: 4em;
|
||||
left: 0;
|
||||
height: calc(100vh - 4em);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
html[dir="rtl"] nav {
|
||||
|
||||
@@ -29,6 +29,13 @@
|
||||
|
||||
.epub-reader .tocButton {
|
||||
color: var(--text);
|
||||
/*
|
||||
* vue-reader positions the TOC toggle at top: 10px, which lands under the
|
||||
* fixed 4em header bar (see .header) — so clicks hit the header's Close
|
||||
* button instead of opening the table of contents. Push it just below the
|
||||
* header, tracking the header's height so it stays clear if that changes.
|
||||
*/
|
||||
top: calc(4em + 10px);
|
||||
}
|
||||
|
||||
.epub-reader .tocButton.tocButtonExpanded {
|
||||
|
||||
@@ -113,8 +113,9 @@
|
||||
top: 0;
|
||||
z-index: 99999;
|
||||
background: var(--surfaceSecondary);
|
||||
height: 100%;
|
||||
height: 100vh;
|
||||
width: 16em;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 0 5px var(--borderPrimary);
|
||||
transition: 0.1s ease left;
|
||||
left: -17em;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
"rename": "Umbenennen",
|
||||
"replace": "Ersetzen",
|
||||
"reportIssue": "Problem melden",
|
||||
"resumeTransfer": "Resume previous transfer",
|
||||
"resumeTransferTooltip": "Skip all conflicting files, except the ones that are smaller on the server as we suppose that their transfert has been interrupted.",
|
||||
"resumeTransfer": "Vorherige Übertragung fortsetzen",
|
||||
"resumeTransferTooltip": "Alle Dateien mit Konflikten überspringen, außer denen, die auf dem Server kleiner sind, da wir davon ausgehen, dass deren Übertragung unterbrochen wurde.",
|
||||
"save": "Speichern",
|
||||
"schedule": "Planen",
|
||||
"search": "Suchen",
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "Freigabeverwaltung",
|
||||
"shareDeleted": "Freigabe gelöscht!",
|
||||
"singleClick": "Einfacher Klick zum Öffnen von Dateien und Verzeichnissen",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "Systemstandard",
|
||||
"dark": "Dunkel",
|
||||
@@ -283,7 +286,7 @@
|
||||
"currentPassword": "Dein aktuelles Passwort"
|
||||
},
|
||||
"sidebar": {
|
||||
"diskUsed": "{used} of {total} used",
|
||||
"diskUsed": "{used} von {total} belegt",
|
||||
"help": "Hilfe",
|
||||
"hugoNew": "Hugo Neu",
|
||||
"login": "Anmelden",
|
||||
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "Share Management",
|
||||
"shareDeleted": "Share deleted!",
|
||||
"singleClick": "Use single clicks to open files and directories",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "System default",
|
||||
"dark": "Dark",
|
||||
|
||||
+28
-25
@@ -120,12 +120,12 @@
|
||||
"passwordsDontMatch": "Les mots de passe ne concordent pas",
|
||||
"signup": "S'inscrire",
|
||||
"submit": "Se connecter",
|
||||
"username": "Utilisateur",
|
||||
"usernameTaken": "Le nom d'utilisateur est déjà pris",
|
||||
"username": "Identifiant",
|
||||
"usernameTaken": "L'identifiant est déjà pris",
|
||||
"wrongCredentials": "Identifiants incorrects !",
|
||||
"passwordTooShort": "Le mot de passe doit contenir au moins {min} caractères",
|
||||
"logout_reasons": {
|
||||
"inactivity": "Vous avez été déconnecté(e) en raison d'une inactivité prolongée."
|
||||
"inactivity": "Vous avez été déconnecté'e en raison d'une inactivité prolongée."
|
||||
}
|
||||
},
|
||||
"permanent": "Permanent",
|
||||
@@ -194,12 +194,12 @@
|
||||
"settings": {
|
||||
"aceEditorTheme": "Éditeur de Thème Ace",
|
||||
"admin": "Admin",
|
||||
"administrator": "Administrateur",
|
||||
"administrator": "Administrateur'ice",
|
||||
"allowCommands": "Exécuter des commandes",
|
||||
"allowEdit": "Éditer, renommer et supprimer des fichiers ou des dossiers",
|
||||
"allowNew": "Créer de nouveaux fichiers et dossiers",
|
||||
"allowPublish": "Publier de nouveaux posts et pages",
|
||||
"allowSignup": "Autoriser les utilisateurs à s'inscrire",
|
||||
"allowSignup": "Autoriser les utilisateur'ices à s'inscrire",
|
||||
"hideLoginButton": "Cacher le bouton d’identification sur les pages publiques",
|
||||
"avoidChanges": "(Laisser vide pour conserver l'actuel)",
|
||||
"branding": "Image de marque",
|
||||
@@ -209,34 +209,34 @@
|
||||
"commandRunner": "Exécuteur de commandes",
|
||||
"commandRunnerHelp": "Ici, vous pouvez définir les commandes qui seront exécutées lors des événements nommés précédemments. Vous devez en écrire une par ligne. Les variables d'environnement {0} et {1} seront disponibles, {0} étant relatif à {1}. Pour plus d'informations sur cette fonctionnalité et les variables d'environnement disponibles, veuillez lire la {2}.",
|
||||
"commandsUpdated": "Commandes mises à jour !",
|
||||
"createUserDir": "Créer automatiquement un dossier pour l'utilisateur",
|
||||
"createUserDir": "Créer automatiquement un dossier pour l'utilisateur'ice",
|
||||
"minimumPasswordLength": "Taille minimale du mot de passe",
|
||||
"tusUploads": "Uploads segmentés",
|
||||
"tusUploadsHelp": "File Browser prend en charge les uploads segmentés afin de permettre une gestion efficace, fiable et reprenable sur des réseaux instables.",
|
||||
"tusUploadsChunkSize": "Taille maximale autorisée par segment (les uploads directs seront utilisés pour les fichiers plus petits). Vous pouvez entrer un entier en octets ou une chaîne telle que 10MB, 1GB, etc.",
|
||||
"tusUploadsRetryCount": "Nombre de tentatives en cas d'échec d'un segment.",
|
||||
"userHomeBasePath": "Chemin de base pour les dossiers personnels des utilisateurs",
|
||||
"userHomeBasePath": "Chemin de base pour les dossiers personnels des utilisateur'ices",
|
||||
"userScopeGenerationPlaceholder": "Le périmètre sera généré automatiquement",
|
||||
"createUserHomeDirectory": "Créer le dossier personnel de l'utilisateur",
|
||||
"createUserHomeDirectory": "Créer le dossier personnel de l'utilisateur'ice",
|
||||
"customStylesheet": "Feuille de style personnalisée",
|
||||
"defaultUserDescription": "Paramètres par défaut pour les nouveaux utilisateurs.",
|
||||
"defaultUserDescription": "Paramètres par défaut pour les nouveaux utilisateur'ices.",
|
||||
"disableExternalLinks": "Désactiver les liens externes (sauf la documentation)",
|
||||
"disableUsedDiskPercentage": "Désactiver le graphique de pourcentage d'utilisation du disque",
|
||||
"documentation": "documentation",
|
||||
"examples": "Exemples",
|
||||
"executeOnShell": "Exécuter dans le shell",
|
||||
"executeOnShellDescription": "Par défaut, File Browser exécute les commandes en appelant directement leurs binaires. Si vous voulez les exécuter sur un shell à la place (comme Bash ou PowerShell), vous pouvez le définir ici avec les arguments et les drapeaux requis. S'il est défini, la commande que vous exécutez sera ajoutée en tant qu'argument. Cela s'applique à la fois aux commandes utilisateur et aux crochets d'événements.",
|
||||
"globalRules": "Il s'agit d'un ensemble global de règles d'autorisation et d'interdiction. Elles s'appliquent à tous les utilisateurs. Vous pouvez définir des règles spécifiques sur les paramètres de chaque utilisateur pour remplacer celles-ci.",
|
||||
"executeOnShellDescription": "Par défaut, File Browser exécute les commandes en appelant directement leurs binaires. Si vous voulez les exécuter sur un shell à la place (comme Bash ou PowerShell), vous pouvez le définir ici avec les arguments et les drapeaux requis. S'il est défini, la commande que vous exécutez sera ajoutée en tant qu'argument. Cela s'applique à la fois aux commandes utilisateur'ice et aux crochets d'événements.",
|
||||
"globalRules": "Il s'agit d'un ensemble global de règles d'autorisation et d'interdiction. Elles s'appliquent à tous les utilisateur'ices. Vous pouvez définir des règles spécifiques sur les paramètres de chaque utilisateur'ice pour remplacer celles-ci.",
|
||||
"globalSettings": "Paramètres globaux",
|
||||
"hideDotfiles": "Cacher les fichiers de configuration commançant par un point",
|
||||
"insertPath": "Insérer le chemin",
|
||||
"insertRegex": "Insérer une expression régulière",
|
||||
"instanceName": "Nom de l'instance",
|
||||
"language": "Langue",
|
||||
"lockPassword": "Empêcher l'utilisateur de changer son mot de passe",
|
||||
"lockPassword": "Empêcher l'utilisateur'ice de changer son mot de passe",
|
||||
"newPassword": "Votre nouveau mot de passe",
|
||||
"newPasswordConfirm": "Confirmation du nouveau mot de passe",
|
||||
"newUser": "Nouvel utilisateur",
|
||||
"newUser": "Nouvel'le utilisateur'ice",
|
||||
"password": "Mot de passe",
|
||||
"passwordUpdated": "Mot de passe mis à jour !",
|
||||
"path": "Chemin",
|
||||
@@ -250,36 +250,39 @@
|
||||
"share": "Partager des fichiers (autorisation de téléchargement requise)"
|
||||
},
|
||||
"permissions": "Permissions",
|
||||
"permissionsHelp": "Vous pouvez définir l'utilisateur comme étant un administrateur ou encore choisir les permissions individuellement. Si vous sélectionnez \"Administrateur\", toutes les autres options seront automatiquement activées. La gestion des utilisateurs est un privilège que seul l'administrateur possède.\n",
|
||||
"permissionsHelp": "Vous pouvez définir l'utilisateur'ice comme étant un'e administrateur'ice ou encore choisir les permissions individuellement. Si vous sélectionnez \"Administrateur'ice\", toutes les autres options seront automatiquement activées. La gestion des utilisateur'ices est un privilège que seul l'administrateur'ice possède.\n",
|
||||
"profileSettings": "Paramètres du profil",
|
||||
"redirectAfterCopyMove": "Rediriger vers la destination après une copie/déplacement",
|
||||
"ruleExample1": "Bloque l'accès à tous les fichiers commençant par un point (comme par exemple .git, .gitignore) dans tous les dossiers.\n",
|
||||
"ruleExample2": "Bloque l'accès au fichier nommé \"Caddyfile\" à la racine du dossier utilisateur",
|
||||
"ruleExample2": "Bloque l'accès au fichier nommé \"Caddyfile\" à la racine du dossier utilisateur'ice",
|
||||
"rules": "Règles",
|
||||
"rulesHelp": "Vous pouvez définir ici un ensemble de règles pour cet utilisateur. Les fichiers bloqués ne seront pas affichés et ne seront pas accessibles par l'utilisateur. Les expressions régulières sont supportées et les chemins d'accès sont relatifs par rapport au dossier de l'utilisateur.\n",
|
||||
"scope": "Portée du dossier utilisateur",
|
||||
"rulesHelp": "Vous pouvez définir ici un ensemble de règles pour cet'te utilisateur'ice. Les fichiers bloqués ne seront pas affichés et ne seront pas accessibles par l'utilisateur'ice. Les expressions régulières sont supportées et les chemins d'accès sont relatifs par rapport au dossier de l'utilisateur'ice.\n",
|
||||
"scope": "Portée du dossier utilisateur'ice",
|
||||
"setDateFormat": "Définir le format de la date",
|
||||
"settingsUpdated": "Les paramètres ont été mis à jour !",
|
||||
"shareDuration": "Durée du partage",
|
||||
"shareManagement": "Gestion des partages",
|
||||
"shareDeleted": "Partage supprimé !",
|
||||
"singleClick": "Utiliser un simple clic pour ouvrir les fichiers et les dossiers",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "Par défaut du système",
|
||||
"dark": "Sombre",
|
||||
"light": "Clair",
|
||||
"title": "Thème"
|
||||
},
|
||||
"user": "Utilisateur",
|
||||
"user": "Utilisateur'ice",
|
||||
"userCommands": "Commandes",
|
||||
"userCommandsHelp": "Une liste séparée par des espaces des commandes permises pour l'utilisateur. Exemple :\n",
|
||||
"userCreated": "Utilisateur créé !",
|
||||
"userDefaults": "Paramètres par défaut de l'utilisateur",
|
||||
"userDeleted": "Utilisateur supprimé !",
|
||||
"userManagement": "Gestion des utilisateurs",
|
||||
"userUpdated": "Utilisateur mis à jour !",
|
||||
"username": "Nom d'utilisateur",
|
||||
"users": "Utilisateurs",
|
||||
"userCreated": "Utilisateur'ice créé !",
|
||||
"userDefaults": "Paramètres par défaut de l'utilisateur'ice",
|
||||
"userDeleted": "Utilisateur'ice supprimé !",
|
||||
"userManagement": "Gestion des utilisateur'ices",
|
||||
"userUpdated": "Utilisateur'ice mis à jour !",
|
||||
"username": "Nom d'utilisateur'ice",
|
||||
"users": "Utilisateur'ices",
|
||||
"currentPassword": "Mot de Passe Actuel"
|
||||
},
|
||||
"sidebar": {
|
||||
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "Upravljanje Dijeljenjem",
|
||||
"shareDeleted": "Podjela izbrisana!",
|
||||
"singleClick": "Koristi jednostruke klikove za otvaranje datoteka i mapa",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "Zadano - Sustav",
|
||||
"dark": "Tamno",
|
||||
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "공유 내역 관리",
|
||||
"shareDeleted": "공유 삭제됨!",
|
||||
"singleClick": "단일 클릭으로 파일 및 디렉터리 열기",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "시스템 기본값",
|
||||
"dark": "어두운 테마",
|
||||
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "Beheer van gedeelde mappen en bestanden",
|
||||
"shareDeleted": "Delen opheffen!",
|
||||
"singleClick": "Bestanden en mappen met een enkele klik openen",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "Systeem standaard",
|
||||
"dark": "Donker",
|
||||
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "Zarządzanie udostępnianiem",
|
||||
"shareDeleted": "Udostępnienie usunięte!",
|
||||
"singleClick": "Używaj pojedynczych kliknięć, aby otwierać pliki i foldery",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "Domyślny systemowy",
|
||||
"dark": "Ciemny",
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
"newPasswordConfirm": "Confirmar a sua palavra-passe",
|
||||
"newUser": "Novo Utilizador",
|
||||
"password": "Palavra-passe",
|
||||
"passwordUpdated": "Palavras-passe não coincidem!",
|
||||
"passwordUpdated": "Palavra-passe atualizada!",
|
||||
"path": "Caminho",
|
||||
"perm": {
|
||||
"create": "Criar ficheiros e pastas",
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "Gestão de Partilhas",
|
||||
"shareDeleted": "Partilha eliminada!",
|
||||
"singleClick": "Utilizar cliques únicos para abrir ficheiros e pastas",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "Predefinição do sistema",
|
||||
"dark": "Escuro",
|
||||
|
||||
@@ -1,309 +0,0 @@
|
||||
{
|
||||
"buttons": {
|
||||
"cancel": "Cancelar",
|
||||
"clear": "Limpar",
|
||||
"close": "Fechar",
|
||||
"continue": "Continuar",
|
||||
"copy": "Copiar",
|
||||
"copyFile": "Copiar ficheiro",
|
||||
"copyToClipboard": "Copiar",
|
||||
"copyDownloadLinkToClipboard": "Copy download link to clipboard",
|
||||
"create": "Criar",
|
||||
"delete": "Eliminar",
|
||||
"download": "Descarregar",
|
||||
"file": "File",
|
||||
"folder": "Folder",
|
||||
"fullScreen": "Toggle full screen",
|
||||
"hideDotfiles": "Hide dotfiles",
|
||||
"info": "Info",
|
||||
"more": "Mais",
|
||||
"move": "Mover",
|
||||
"moveFile": "Mover ficheiro",
|
||||
"new": "Novo",
|
||||
"next": "Próximo",
|
||||
"ok": "OK",
|
||||
"permalink": "Obter link permanente",
|
||||
"previous": "Anterior",
|
||||
"preview": "Preview",
|
||||
"publish": "Publicar",
|
||||
"rename": "Alterar nome",
|
||||
"replace": "Substituir",
|
||||
"reportIssue": "Reportar erro",
|
||||
"resumeTransfer": "Resume previous transfer",
|
||||
"resumeTransferTooltip": "Skip all conflicting files, except the ones that are smaller on the server as we suppose that their transfert has been interrupted.",
|
||||
"save": "Guardar",
|
||||
"schedule": "Agendar",
|
||||
"search": "Pesquisar",
|
||||
"select": "Selecionar",
|
||||
"selectMultiple": "Selecionar vários",
|
||||
"share": "Partilhar",
|
||||
"shell": "Alternar shell",
|
||||
"submit": "Submit",
|
||||
"switchView": "Alterar vista",
|
||||
"toggleSidebar": "Alternar barra lateral",
|
||||
"update": "Atualizar",
|
||||
"upload": "Enviar",
|
||||
"openFile": "Open file",
|
||||
"openDirect": "View raw",
|
||||
"discardChanges": "Discard",
|
||||
"stopSearch": "Stop searching",
|
||||
"saveChanges": "Save changes",
|
||||
"editAsText": "Edit as Text",
|
||||
"increaseFontSize": "Increase font size",
|
||||
"decreaseFontSize": "Decrease font size",
|
||||
"overrideAll": "Replace all files in destination folder",
|
||||
"skipAll": "Skip all conflicting files",
|
||||
"renameAll": "Rename all files (create a copy)",
|
||||
"singleDecision": "Decide for each conflicting file"
|
||||
},
|
||||
"download": {
|
||||
"downloadFile": "Descarregar ficheiro",
|
||||
"downloadFolder": "Descarregar pasta",
|
||||
"downloadSelected": "Download Selected"
|
||||
},
|
||||
"upload": {
|
||||
"abortUpload": "Are you sure you wish to abort?"
|
||||
},
|
||||
"errors": {
|
||||
"forbidden": "Não tem permissões para aceder a isto",
|
||||
"internal": "Algo correu bastante mal.",
|
||||
"notFound": "Esta localização não é alcançável.",
|
||||
"connection": "The server can't be reached."
|
||||
},
|
||||
"files": {
|
||||
"body": "Corpo",
|
||||
"closePreview": "Fechar pré-visualização",
|
||||
"files": "Ficheiros",
|
||||
"folders": "Pastas",
|
||||
"home": "Início",
|
||||
"lastModified": "Última alteração",
|
||||
"loading": "A carregar...",
|
||||
"lonely": "Sinto-me sozinho...",
|
||||
"metadata": "Metadados",
|
||||
"multipleSelectionEnabled": "Seleção múltipla ativada",
|
||||
"name": "Nome",
|
||||
"size": "Tamanho",
|
||||
"sortByLastModified": "Ordenar pela última alteração",
|
||||
"sortByName": "Ordenar pelo nome",
|
||||
"sortBySize": "Ordenar pelo tamanho",
|
||||
"noPreview": "Preview is not available for this file.",
|
||||
"csvTooLarge": "CSV file is too large for preview (>5MB). Please download to view.",
|
||||
"csvLoadFailed": "Failed to load CSV file.",
|
||||
"showingRows": "Showing {count} row(s)",
|
||||
"columnSeparator": "Column Separator",
|
||||
"csvSeparators": {
|
||||
"comma": "Comma (,)",
|
||||
"semicolon": "Semicolon (;)",
|
||||
"both": "Both (,) and (;)"
|
||||
},
|
||||
"fileEncoding": "File Encoding"
|
||||
},
|
||||
"help": {
|
||||
"click": "selecionar pasta ou ficheiro",
|
||||
"ctrl": {
|
||||
"click": "selecionar várias pastas e ficheiros",
|
||||
"f": "pesquisar",
|
||||
"s": "guardar um ficheiro ou descarrega a pasta em que está a navegar"
|
||||
},
|
||||
"del": "eliminar os ficheiros selecionados",
|
||||
"doubleClick": "abrir pasta ou ficheiro",
|
||||
"esc": "limpar seleção e/ou fechar menu",
|
||||
"f1": "esta informação",
|
||||
"f2": "alterar nome do ficheiro",
|
||||
"help": "Ajuda"
|
||||
},
|
||||
"login": {
|
||||
"createAnAccount": "Criar uma conta",
|
||||
"loginInstead": "Já tenho uma conta",
|
||||
"password": "Palavra-passe",
|
||||
"passwordConfirm": "Confirmação da palavra-passe",
|
||||
"passwordsDontMatch": "As palavras-passe não coincidem",
|
||||
"signup": "Registar",
|
||||
"submit": "Entrar na conta",
|
||||
"username": "Nome de utilizador",
|
||||
"usernameTaken": "O nome de utilizador já está registado",
|
||||
"wrongCredentials": "Dados errados",
|
||||
"passwordTooShort": "Password must be at least {min} characters",
|
||||
"logout_reasons": {
|
||||
"inactivity": "You have been logged out due to inactivity."
|
||||
}
|
||||
},
|
||||
"permanent": "Permanente",
|
||||
"prompts": {
|
||||
"copy": "Copiar",
|
||||
"copyMessage": "Escolha um lugar para onde copiar os ficheiros:",
|
||||
"currentlyNavigating": "A navegar em:",
|
||||
"deleteMessageMultiple": "Quer eliminar {count} ficheiro(s)?",
|
||||
"deleteMessageSingle": "Quer eliminar esta pasta/ficheiro?",
|
||||
"deleteMessageShare": "Are you sure you wish to delete this share({path})?",
|
||||
"deleteUser": "Are you sure you want to delete this user?",
|
||||
"deleteTitle": "Eliminar ficheiros",
|
||||
"displayName": "Nome:",
|
||||
"download": "Descarregar ficheiros",
|
||||
"downloadMessage": "Escolha o formato do ficheiro que quer descarregar.",
|
||||
"error": "Algo correu mal",
|
||||
"fileInfo": "Informação do ficheiro",
|
||||
"filesSelected": "{count} ficheiros selecionados.",
|
||||
"lastModified": "Última alteração",
|
||||
"move": "Mover",
|
||||
"moveMessage": "Escolha uma nova casa para os seus ficheiros/pastas:",
|
||||
"newArchetype": "Criar um novo post baseado num \"archetype\". O seu ficheiro será criado na pasta \"content\".",
|
||||
"newDir": "Nova pasta",
|
||||
"newDirMessage": "Escreva o nome da nova pasta.",
|
||||
"newFile": "Novo ficheiro",
|
||||
"newFileMessage": "Escreva o nome do novo ficheiro.",
|
||||
"numberDirs": "Número de pastas",
|
||||
"numberFiles": "Número de ficheiros",
|
||||
"rename": "Alterar nome",
|
||||
"renameMessage": "Insira um novo nome para",
|
||||
"replace": "Substituir",
|
||||
"replaceMessage": "Já existe um ficheiro com nome igual a um dos que está a tentar enviar. Quer substituí-lo?\n",
|
||||
"schedule": "Agendar",
|
||||
"scheduleMessage": "Escolha uma data para publicar este post.",
|
||||
"show": "Mostrar",
|
||||
"size": "Tamanho",
|
||||
"upload": "Upload",
|
||||
"uploadFiles": "Uploading {files} files...",
|
||||
"uploadMessage": "Select an option to upload.",
|
||||
"optionalPassword": "Optional password",
|
||||
"resolution": "Resolution",
|
||||
"discardEditorChanges": "Are you sure you wish to discard the changes you've made?",
|
||||
"replaceOrSkip": "Replace or skip files",
|
||||
"resolveConflict": "Which files do you want to keep?",
|
||||
"singleConflictResolve": "If you select both versions, a number will be added to the name of the copied file.",
|
||||
"fastConflictResolve": "The destination folder there are {count} files with same name.",
|
||||
"uploadingFiles": "Uploading files",
|
||||
"filesInOrigin": "Files in origin",
|
||||
"filesInDest": "Files in destination",
|
||||
"override": "Overwrite",
|
||||
"skip": "Skip",
|
||||
"forbiddenError": "Forbidden Error",
|
||||
"currentPassword": "Your password",
|
||||
"currentPasswordMessage": "Enter your password to validate this action."
|
||||
},
|
||||
"search": {
|
||||
"images": "Imagens",
|
||||
"music": "Música",
|
||||
"pdf": "PDF",
|
||||
"pressToSearch": "Tecla Enter para pesquisar...",
|
||||
"search": "Pesquisar...",
|
||||
"typeToSearch": "Escrever para pesquisar...",
|
||||
"types": "Tipos",
|
||||
"video": "Vídeos"
|
||||
},
|
||||
"settings": {
|
||||
"aceEditorTheme": "Ace editor theme",
|
||||
"admin": "Admin",
|
||||
"administrator": "Administrador",
|
||||
"allowCommands": "Executar comandos",
|
||||
"allowEdit": "Editar, renomear e eliminar ficheiros ou pastas",
|
||||
"allowNew": "Criar novos ficheiros e pastas",
|
||||
"allowPublish": "Publicar novas páginas e conteúdos",
|
||||
"allowSignup": "Permitir que os utilizadores criem contas",
|
||||
"hideLoginButton": "Hide the login button from public pages",
|
||||
"avoidChanges": "(deixe em branco para manter)",
|
||||
"branding": "Marca",
|
||||
"brandingDirectoryPath": "Caminho da pasta de marca",
|
||||
"brandingHelp": "Pode personalizar a aparência do seu Navegador de Ficheiros, alterar o nome, substituindo o logótipo, adicionando estilos personalizados e mesmo desativando links externos para o GitHub.\nPara mais informações sobre marca personalizada, por favor veja {0}.",
|
||||
"changePassword": "Alterar palavra-passe",
|
||||
"commandRunner": "Execução de comandos",
|
||||
"commandRunnerHelp": "Aqui pode definir comandos que são executados nos eventos nomeados. Tem de escrever um por linha. As variáveis de ambiente {0} e {1} estarão disponíveis, sendo {0} relativo a {1}. Para mais informações sobre esta funcionalidade e as variáveis de ambiente, veja {2}.",
|
||||
"commandsUpdated": "Comandos atualizados!",
|
||||
"createUserDir": "Criar automaticamente a pasta de início ao adicionar um novo utilizador",
|
||||
"minimumPasswordLength": "Minimum password length",
|
||||
"tusUploads": "Chunked Uploads",
|
||||
"tusUploadsHelp": "File Browser supports chunked file uploads, allowing for the creation of efficient, reliable, resumable and chunked file uploads even on unreliable networks.",
|
||||
"tusUploadsChunkSize": "Indicates to maximum size of a request (direct uploads will be used for smaller uploads). You may input a plain integer denoting byte size input or a string like 10MB, 1GB etc.",
|
||||
"tusUploadsRetryCount": "Number of retries to perform if a chunk fails to upload.",
|
||||
"userHomeBasePath": "Base path for user home directories",
|
||||
"userScopeGenerationPlaceholder": "The scope will be auto generated",
|
||||
"createUserHomeDirectory": "Create user home directory",
|
||||
"customStylesheet": "Folha de estilos personalizada",
|
||||
"defaultUserDescription": "Estas são as configurações padrão para novos utilizadores.",
|
||||
"disableExternalLinks": "Desativar links externos (exceto documentação)",
|
||||
"disableUsedDiskPercentage": "Disable used disk percentage graph",
|
||||
"documentation": "documentação",
|
||||
"examples": "Exemplos",
|
||||
"executeOnShell": "Executar na shell",
|
||||
"executeOnShellDescription": "Por padrão, o Navegador de Ficheiros executa os comandos chamando os seus binários diretamente. Se em vez disso, quiser executá-los numa shell (como Bash ou PowerShell), pode definir isso aqui com os argumentos e bandeiras necessários. Se definido, o comando que executa será anexado como um argumento. Isto aplica-se tanto a comandos do utilizador como a hooks de eventos.",
|
||||
"globalRules": "Isto é um conjunto global de regras de permissão e negação. Elas aplicam-se a todos os utilizadores. Pode especificar regras específicas para cada configuração do utilizador para sobreporem-se a estas.",
|
||||
"globalSettings": "Configurações globais",
|
||||
"hideDotfiles": "Hide dotfiles",
|
||||
"insertPath": "Inserir o caminho",
|
||||
"insertRegex": "Inserir expressão regular",
|
||||
"instanceName": "Nome da instância",
|
||||
"language": "Linguagem",
|
||||
"lockPassword": "Não permitir que o utilizador altere a palavra-passe",
|
||||
"newPassword": "Nova palavra-passe",
|
||||
"newPasswordConfirm": "Confirme a nova palavra-passe",
|
||||
"newUser": "Novo utilizador",
|
||||
"password": "Palavra-passe",
|
||||
"passwordUpdated": "Palavra-passe atualizada!",
|
||||
"path": "Path",
|
||||
"perm": {
|
||||
"create": "Criar ficheiros e pastas",
|
||||
"delete": "Eliminar ficheiros e pastas",
|
||||
"download": "Descarregar",
|
||||
"execute": "Executar comandos",
|
||||
"modify": "Editar ficheiros",
|
||||
"rename": "Alterar o nome ou mover ficheiros e pastas",
|
||||
"share": "Share files (require download permission)"
|
||||
},
|
||||
"permissions": "Permissões",
|
||||
"permissionsHelp": "Pode definir o utilizador como administrador ou escolher as permissões manualmente. Se selecionar a opção \"Administrador\", todas as outras opções serão automaticamente selecionadas. A gestão dos utilizadores é um privilégio restringido aos administradores.\n",
|
||||
"profileSettings": "Configurações do utilizador",
|
||||
"redirectAfterCopyMove": "Redirect to destination after copy/move",
|
||||
"ruleExample1": "previne o acesso a qualquer \"dotfile\" (como .git, .gitignore) em qualquer pasta\n",
|
||||
"ruleExample2": "bloqueia o acesso ao ficheiro chamado Caddyfile na raiz.",
|
||||
"rules": "Regras",
|
||||
"rulesHelp": "Aqui pode definir um conjunto de regras para permitir ou bloquear o acesso do utilizador a determinados ficheiros ou pastas. Os ficheiros bloqueados não irão aparecer durante a navegação. Suportamos expressões regulares e os caminhos dos ficheiros devem ser relativos à base do utilizador.\n",
|
||||
"scope": "Base",
|
||||
"setDateFormat": "Set exact date format",
|
||||
"settingsUpdated": "Configurações atualizadas!",
|
||||
"shareDuration": "Share Duration",
|
||||
"shareManagement": "Share Management",
|
||||
"shareDeleted": "Share deleted!",
|
||||
"singleClick": "Use single clicks to open files and directories",
|
||||
"themes": {
|
||||
"default": "System default",
|
||||
"dark": "Dark",
|
||||
"light": "Light",
|
||||
"title": "Theme"
|
||||
},
|
||||
"user": "Utilizador",
|
||||
"userCommands": "Comandos",
|
||||
"userCommandsHelp": "Uma lista, separada com espaços, de comandos disponíveis para este utilizados. Exemplo:",
|
||||
"userCreated": "Utilizador criado!",
|
||||
"userDefaults": "Configurações padrão do utilizador",
|
||||
"userDeleted": "Utilizador eliminado!",
|
||||
"userManagement": "Gestão de utilizadores",
|
||||
"userUpdated": "Utilizador atualizado!",
|
||||
"username": "Nome de utilizador",
|
||||
"users": "Utilizadores",
|
||||
"currentPassword": "Your Current Password"
|
||||
},
|
||||
"sidebar": {
|
||||
"diskUsed": "{used} of {total} used",
|
||||
"help": "Ajuda",
|
||||
"hugoNew": "Hugo New",
|
||||
"login": "Entrar",
|
||||
"logout": "Sair",
|
||||
"myFiles": "Meus ficheiros",
|
||||
"newFile": "Novo ficheiro",
|
||||
"newFolder": "Nova pasta",
|
||||
"preview": "Pré-visualizar",
|
||||
"settings": "Configurações",
|
||||
"signup": "Registar",
|
||||
"siteSettings": "Configurações do site"
|
||||
},
|
||||
"success": {
|
||||
"linkCopied": "Link copiado!"
|
||||
},
|
||||
"time": {
|
||||
"days": "Dias",
|
||||
"hours": "Horas",
|
||||
"minutes": "Minutos",
|
||||
"seconds": "Segundos",
|
||||
"unit": "Unidades de tempo"
|
||||
}
|
||||
}
|
||||
@@ -264,6 +264,9 @@
|
||||
"shareManagement": "分享管理",
|
||||
"shareDeleted": "分享已删除!",
|
||||
"singleClick": "单击打开文件/文件夹",
|
||||
"sunsetBody": "This project is being wound down. It is archived on 2026-09-01, after which there will be no further releases, bug fixes, or security fixes. Existing releases and Docker images stay online. Do not expose this instance directly to the internet without authentication in front of it.",
|
||||
"sunsetLink": "Read the project status, known unfixed security issues, and hardening guidance",
|
||||
"sunsetTitle": "File Browser is being archived",
|
||||
"themes": {
|
||||
"default": "系统默认",
|
||||
"dark": "深色",
|
||||
|
||||
@@ -180,7 +180,7 @@ const router = createRouter({
|
||||
routes,
|
||||
});
|
||||
|
||||
router.beforeResolve(async (to, from, next) => {
|
||||
router.beforeResolve(async (to, from) => {
|
||||
const title = i18n.global.t(titles[to.name as keyof typeof titles]);
|
||||
document.title = title + " - " + name;
|
||||
|
||||
@@ -196,29 +196,25 @@ router.beforeResolve(async (to, from, next) => {
|
||||
}
|
||||
|
||||
if (to.path.endsWith("/login") && authStore.isLoggedIn) {
|
||||
next({ path: "/files/" });
|
||||
return;
|
||||
return { path: "/files/" };
|
||||
}
|
||||
|
||||
if (to.matched.some((record) => record.meta.requiresAuth)) {
|
||||
if (!authStore.isLoggedIn) {
|
||||
next({
|
||||
return {
|
||||
path: "/login",
|
||||
query: { redirect: to.fullPath },
|
||||
});
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
if (to.matched.some((record) => record.meta.requiresAdmin)) {
|
||||
if (authStore.user === null || !authStore.user.perm.admin) {
|
||||
next({ path: "/403" });
|
||||
return;
|
||||
return { path: "/403" };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
return;
|
||||
});
|
||||
|
||||
export { router, router as default };
|
||||
@@ -103,15 +103,21 @@ export const useUploadStore = defineStore("upload", () => {
|
||||
}
|
||||
|
||||
if (isActiveUploadsOnLimit() && hasPendingUploads()) {
|
||||
if (!hasActiveUploads()) {
|
||||
// Update the state in a fixed time interval
|
||||
if (progressInterval === null) {
|
||||
// Update the state in a fixed time interval. Guard on the handle, not
|
||||
// on the active count: this runs again every time the queue drains to
|
||||
// zero with work still pending, and reassigning would leak the timer.
|
||||
progressInterval = window.setInterval(syncState, 1000);
|
||||
}
|
||||
|
||||
const upload = nextUpload();
|
||||
let succeeded = true;
|
||||
|
||||
if (upload.type === "dir") {
|
||||
await api.post(upload.path).catch($showError);
|
||||
await api.post(upload.path).catch((err) => {
|
||||
succeeded = false;
|
||||
$showError(err);
|
||||
});
|
||||
} else {
|
||||
const onUpload = (event: ProgressEvent) => {
|
||||
upload.rawProgress.sentBytes = event.loaded;
|
||||
@@ -119,10 +125,13 @@ export const useUploadStore = defineStore("upload", () => {
|
||||
|
||||
await api
|
||||
.post(upload.path, upload.file!, upload.overwrite, onUpload)
|
||||
.catch((err) => err.message !== "Upload aborted" && $showError(err));
|
||||
.catch((err) => {
|
||||
succeeded = false;
|
||||
if (err.message !== "Upload aborted") $showError(err);
|
||||
});
|
||||
}
|
||||
|
||||
finishUpload(upload);
|
||||
finishUpload(upload, succeeded);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -135,9 +144,18 @@ export const useUploadStore = defineStore("upload", () => {
|
||||
return upload;
|
||||
};
|
||||
|
||||
const finishUpload = (upload: Upload) => {
|
||||
sentBytes.value += upload.totalBytes - upload.sentBytes;
|
||||
upload.sentBytes = upload.totalBytes;
|
||||
const finishUpload = (upload: Upload, succeeded: boolean) => {
|
||||
if (succeeded) {
|
||||
sentBytes.value += upload.totalBytes - upload.sentBytes;
|
||||
upload.sentBytes = upload.totalBytes;
|
||||
} else {
|
||||
// Credit only what actually reached the server and drop the rest from the
|
||||
// total. Counting a failed upload as fully sent makes the bar report 100%
|
||||
// while nothing was written, which reads as success.
|
||||
sentBytes.value += upload.rawProgress.sentBytes - upload.sentBytes;
|
||||
totalBytes.value -= upload.totalBytes - upload.rawProgress.sentBytes;
|
||||
upload.sentBytes = upload.rawProgress.sentBytes;
|
||||
}
|
||||
upload.file = null;
|
||||
|
||||
activeUploads.value.delete(upload);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { files as api } from "@/api";
|
||||
|
||||
vi.mock("@/api", () => ({
|
||||
files: {
|
||||
fetch: vi.fn(),
|
||||
fetchAll: vi.fn(),
|
||||
},
|
||||
}));
|
||||
@@ -19,8 +20,26 @@ vi.mock("@/stores/layout", () => ({ useLayoutStore: vi.fn() }));
|
||||
vi.mock("@/stores/upload", () => ({ useUploadStore: vi.fn() }));
|
||||
vi.mock("@/utils/url", () => ({ default: {} }));
|
||||
|
||||
// A move/copy/drag item carries `name` (raw) and `to` (URL-encoded) but no
|
||||
// `fullPath` — mirroring what Move.vue / Copy.vue / ListingItem.vue build.
|
||||
type ServerEntry = {
|
||||
path: string;
|
||||
name: string;
|
||||
size: number;
|
||||
modified: string;
|
||||
isDir: boolean;
|
||||
};
|
||||
|
||||
// The destination's direct listing, used for copy/move and for flat uploads.
|
||||
function mockListing(entries: ServerEntry[]) {
|
||||
vi.mocked(api.fetch).mockResolvedValue({ items: entries } as Resource);
|
||||
}
|
||||
|
||||
// The recursive walk of the destination, used only for nested (folder) uploads.
|
||||
function mockRecursiveListing(entries: ServerEntry[]) {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue(entries);
|
||||
}
|
||||
|
||||
// A move/copy/drag item carries name (raw) and to (URL-encoded) but no
|
||||
// fullPath - mirroring what Move.vue / Copy.vue / ListingItem.vue build.
|
||||
function moveItem(name: string, dest: string, size = 12) {
|
||||
return {
|
||||
from: `/files/source/${encodeURIComponent(name)}`,
|
||||
@@ -39,7 +58,7 @@ describe("checkConflict", () => {
|
||||
});
|
||||
|
||||
it("detects a conflict for a plain filename", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockListing([
|
||||
{
|
||||
path: "/target/file.txt",
|
||||
name: "file.txt",
|
||||
@@ -58,6 +77,43 @@ describe("checkConflict", () => {
|
||||
expect(conflicts[0].name).toBe("/target/file.txt");
|
||||
});
|
||||
|
||||
// Regression for #6006: pressing Upload awaited a full server-side recursive
|
||||
// walk of the destination before a single byte was sent, so the UI sat there
|
||||
// doing nothing on a large destination. A flat upload can only collide with a
|
||||
// direct child, which the plain listing already covers.
|
||||
it("does not walk the destination tree for a flat upload", async () => {
|
||||
mockListing([]);
|
||||
|
||||
await checkConflict(
|
||||
[{ name: "file.txt", size: 12, isDir: false }],
|
||||
"/files/target/"
|
||||
);
|
||||
|
||||
expect(api.fetch).toHaveBeenCalledWith("/files/target/");
|
||||
expect(api.fetchAll).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// ...but a folder upload lands entries below the destination, so it still
|
||||
// needs the recursive listing to see them.
|
||||
it("walks the destination tree for a nested upload", async () => {
|
||||
mockRecursiveListing([]);
|
||||
|
||||
await checkConflict(
|
||||
[
|
||||
{
|
||||
name: "file.txt",
|
||||
size: 12,
|
||||
isDir: false,
|
||||
fullPath: "folder/file.txt",
|
||||
},
|
||||
],
|
||||
"/files/target/"
|
||||
);
|
||||
|
||||
expect(api.fetchAll).toHaveBeenCalledWith("/files/target/");
|
||||
expect(api.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// Regression for #5957: names with encodable characters (spaces, "#",
|
||||
// non-ASCII) were keyed by the URL-encoded `to` value and never matched the
|
||||
// server's raw path, so the conflict modal was skipped and the backend
|
||||
@@ -65,7 +121,7 @@ describe("checkConflict", () => {
|
||||
it.each(["my file.txt", "résumé.pdf", "a#b.txt"])(
|
||||
"detects a conflict for %s (encodable characters)",
|
||||
async (name) => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockListing([
|
||||
{
|
||||
path: `/target/${name}`,
|
||||
name,
|
||||
@@ -86,7 +142,7 @@ describe("checkConflict", () => {
|
||||
);
|
||||
|
||||
it("reports no conflict when the destination has no matching name", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockListing([
|
||||
{
|
||||
path: "/target/other.txt",
|
||||
name: "other.txt",
|
||||
@@ -105,7 +161,7 @@ describe("checkConflict", () => {
|
||||
});
|
||||
|
||||
it("detects nested conflicts for folder uploads via fullPath", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockRecursiveListing([
|
||||
{
|
||||
path: "/target/folder",
|
||||
name: "folder",
|
||||
@@ -142,7 +198,7 @@ describe("checkConflict", () => {
|
||||
// fullPath) and no directory entries. Conflict detection must still find a
|
||||
// nested file even though its parent folder is not in the upload list.
|
||||
it("detects nested conflicts when no directory entries are present", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockRecursiveListing([
|
||||
{
|
||||
path: "/target/folder/deep/file.txt",
|
||||
name: "file.txt",
|
||||
@@ -167,10 +223,17 @@ describe("checkConflict", () => {
|
||||
expect(conflicts[0].name).toBe("/target/folder/deep/file.txt");
|
||||
});
|
||||
|
||||
// Copy/move stats the whole destination, so a same-named directory is a
|
||||
// conflict in its own right (regression for the directory case of #5957).
|
||||
it("reports a directory conflict for copy/move (includeDirectories)", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
// Copy/move only needs the target directory's direct children. A recursive
|
||||
// walk can make the UI look frozen on large destinations (regression #6005).
|
||||
it("checks only the direct destination listing for copy/move", async () => {
|
||||
mockListing([
|
||||
{
|
||||
path: "/target/file.txt",
|
||||
name: "file.txt",
|
||||
size: 10,
|
||||
modified: "2026-06-04T00:00:00Z",
|
||||
isDir: false,
|
||||
},
|
||||
{
|
||||
path: "/target/folder",
|
||||
name: "folder",
|
||||
@@ -180,18 +243,26 @@ describe("checkConflict", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
const items = [{ ...moveItem("folder", "/files/target/", 0), isDir: true }];
|
||||
const items = [
|
||||
moveItem("file.txt", "/files/target/"),
|
||||
{ ...moveItem("folder", "/files/target/", 0), isDir: true },
|
||||
];
|
||||
|
||||
const conflicts = await checkConflict(items, "/files/target/", true);
|
||||
|
||||
expect(conflicts).toHaveLength(1);
|
||||
expect(conflicts[0].name).toBe("/target/folder");
|
||||
expect(api.fetch).toHaveBeenCalledWith("/files/target/");
|
||||
expect(api.fetchAll).not.toHaveBeenCalled();
|
||||
expect(conflicts).toHaveLength(2);
|
||||
expect(conflicts.map((conflict) => conflict.name)).toEqual([
|
||||
"/target/file.txt",
|
||||
"/target/folder",
|
||||
]);
|
||||
});
|
||||
|
||||
// Uploads merge into an existing folder, so the directory itself must not be
|
||||
// reported — only the files inside it can conflict.
|
||||
// reported - only the files inside it can conflict.
|
||||
it("ignores a directory conflict for uploads (default)", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockListing([
|
||||
{
|
||||
path: "/target/folder",
|
||||
name: "folder",
|
||||
@@ -210,8 +281,8 @@ describe("checkConflict", () => {
|
||||
expect(conflicts).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("returns no conflicts when the recursive listing fails", async () => {
|
||||
vi.mocked(api.fetchAll).mockRejectedValue(new Error("404"));
|
||||
it("returns no conflicts when the destination listing fails", async () => {
|
||||
vi.mocked(api.fetch).mockRejectedValue(new Error("404"));
|
||||
|
||||
const conflicts = await checkConflict(
|
||||
[moveItem("file.txt", "/files/target/")],
|
||||
@@ -222,11 +293,11 @@ describe("checkConflict", () => {
|
||||
});
|
||||
|
||||
// Regression for #5980: a FileBrowser server running on Windows returns
|
||||
// backslash-separated paths from the recursive listing. Without normalizing
|
||||
// them, the prefix strip and key lookup never match, so the conflict modal is
|
||||
// skipped and the backend returns a bare 409.
|
||||
// backslash-separated paths, Without normalizing them, the prefix strip and
|
||||
// key lookup never match, so the conflict modal is skipped and the backend
|
||||
// returns a bare 409.
|
||||
it("detects a conflict for backslash-separated server paths (Windows)", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockListing([
|
||||
{
|
||||
path: "\\target\\file.txt",
|
||||
name: "file.txt",
|
||||
@@ -245,7 +316,7 @@ describe("checkConflict", () => {
|
||||
});
|
||||
|
||||
it("detects nested conflicts for backslash-separated server paths (Windows)", async () => {
|
||||
vi.mocked(api.fetchAll).mockResolvedValue([
|
||||
mockRecursiveListing([
|
||||
{
|
||||
path: "\\target\\folder\\nested file.txt",
|
||||
name: "nested file.txt",
|
||||
@@ -268,4 +339,109 @@ describe("checkConflict", () => {
|
||||
|
||||
expect(conflicts).toHaveLength(1);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["forward slashes", "/target/My SubDir/file.txt"],
|
||||
["Windows backslashes", "\\target\\My SubDir\\file.txt"],
|
||||
])(
|
||||
"detects conflicts below an encoded destination path with %s",
|
||||
async (_label, serverPath) => {
|
||||
mockListing([
|
||||
{
|
||||
path: serverPath,
|
||||
name: "file.txt",
|
||||
size: 10,
|
||||
modified: "2026-06-04T00:00:00Z",
|
||||
isDir: false,
|
||||
},
|
||||
]);
|
||||
|
||||
const conflicts = await checkConflict(
|
||||
[moveItem("file.txt", "/files/target/My%20SubDir/")],
|
||||
"/files/target/My%20SubDir/"
|
||||
);
|
||||
|
||||
expect(conflicts).toHaveLength(1);
|
||||
expect(conflicts[0].name).toBe("/target/My SubDir/file.txt");
|
||||
}
|
||||
);
|
||||
|
||||
it("detects nested folder-upload conflicts below an encoded destination path", async () => {
|
||||
mockRecursiveListing([
|
||||
{
|
||||
path: "\\target\\My SubDir\\folder\\nested file.txt",
|
||||
name: "nested file.txt",
|
||||
size: 10,
|
||||
modified: "2026-06-04T00:00:00Z",
|
||||
isDir: false,
|
||||
},
|
||||
]);
|
||||
|
||||
const conflicts = await checkConflict(
|
||||
[
|
||||
{
|
||||
name: "nested file.txt",
|
||||
size: 12,
|
||||
isDir: false,
|
||||
fullPath: "folder/nested file.txt",
|
||||
},
|
||||
],
|
||||
"/files/target/My%20SubDir/"
|
||||
);
|
||||
|
||||
expect(conflicts).toHaveLength(1);
|
||||
expect(conflicts[0].name).toBe("/target/My SubDir/folder/nested file.txt");
|
||||
});
|
||||
|
||||
it("leaves malformed destination path segments unchanged", async () => {
|
||||
mockListing([
|
||||
{
|
||||
path: "/target/bad%ZZ/file.txt",
|
||||
name: "file.txt",
|
||||
size: 10,
|
||||
modified: "2026-06-04T00:00:00Z",
|
||||
isDir: false,
|
||||
},
|
||||
]);
|
||||
|
||||
const conflicts = await checkConflict(
|
||||
[moveItem("file.txt", "/files/target/bad%ZZ/")],
|
||||
"/files/target/bad%ZZ/"
|
||||
);
|
||||
|
||||
expect(conflicts).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("does not match files outside the decoded destination path", async () => {
|
||||
mockRecursiveListing([
|
||||
{
|
||||
path: "/target/My SubDir/other.txt",
|
||||
name: "other.txt",
|
||||
size: 10,
|
||||
modified: "2026-06-04T00:00:00Z",
|
||||
isDir: false,
|
||||
},
|
||||
{
|
||||
path: "/target/My Other SubDir/folder/file.txt",
|
||||
name: "file.txt",
|
||||
size: 10,
|
||||
modified: "2026-06-04T00:00:00Z",
|
||||
isDir: false,
|
||||
},
|
||||
]);
|
||||
|
||||
const conflicts = await checkConflict(
|
||||
[
|
||||
{
|
||||
name: "file.txt",
|
||||
size: 12,
|
||||
isDir: false,
|
||||
fullPath: "folder/file.txt",
|
||||
},
|
||||
],
|
||||
"/files/target/My%20SubDir/"
|
||||
);
|
||||
|
||||
expect(conflicts).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -21,20 +21,85 @@ function conflictKey(item: UploadEntry): string {
|
||||
return (item.fullPath || item.name).replace(/^\/+/, "");
|
||||
}
|
||||
|
||||
type ServerConflictEntry = {
|
||||
path: string;
|
||||
name: string;
|
||||
size: number;
|
||||
modified: string;
|
||||
};
|
||||
|
||||
async function fetchConflictEntries(
|
||||
basePath: string,
|
||||
recursive: boolean
|
||||
): Promise<ServerConflictEntry[]> {
|
||||
if (recursive) {
|
||||
return await api.fetchAll(basePath);
|
||||
}
|
||||
|
||||
const destination = await api.fetch(basePath);
|
||||
return destination.items ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether any entry lands below the destination rather than directly in it.
|
||||
* Only then does conflict detection need the whole destination tree.
|
||||
*/
|
||||
function hasNestedEntries(files: UploadList): boolean {
|
||||
return files.some((file) => conflictKey(file).includes("/"));
|
||||
}
|
||||
|
||||
function conflictPath(entry: ServerConflictEntry): string {
|
||||
return entry.path.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
function decodePath(path: string): string {
|
||||
return path
|
||||
.split("/")
|
||||
.map((segment) => {
|
||||
try {
|
||||
return decodeURIComponent(segment);
|
||||
} catch {
|
||||
return segment;
|
||||
}
|
||||
})
|
||||
.join("/");
|
||||
}
|
||||
|
||||
function buildConflictMap(
|
||||
serverEntries: ServerConflictEntry[],
|
||||
basePath: string,
|
||||
includeDirectories: boolean
|
||||
): Map<string, ServerConflictEntry> {
|
||||
const serverMap = new Map<string, ServerConflictEntry>();
|
||||
const normBase = decodePath(removePrefix(basePath)).replace(/\/+$/, "");
|
||||
for (const entry of serverEntries) {
|
||||
// A Windows server may return OS-native backslash separators; normalize to
|
||||
// forward slashes so the prefix strip and key lookup line up.
|
||||
const path = conflictPath(entry);
|
||||
const key = includeDirectories
|
||||
? entry.name
|
||||
: path.startsWith(normBase)
|
||||
? path.slice(normBase.length)
|
||||
: path;
|
||||
serverMap.set(key.replace(/^\/+/, ""), entry);
|
||||
}
|
||||
|
||||
return serverMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the entries from `files` that already exist under `basePath` on the
|
||||
* server, so the caller can prompt the user to overwrite/rename/skip.
|
||||
*
|
||||
* The whole destination tree is fetched once and indexed by path relative to
|
||||
* the destination, then every entry is looked up directly — no need to mirror
|
||||
* the upload's folder structure.
|
||||
*
|
||||
* Directory handling differs by action, hence `includeDirectories`:
|
||||
* - Upload (false): an existing folder is silently merged, so only the
|
||||
* individual files inside it can conflict.
|
||||
* - Copy/move (true): the server stats the destination and rejects it whole if
|
||||
* a same-named entry exists, so the directory itself is a conflict. The list
|
||||
* only holds the top-level items being moved, so each is reported once.
|
||||
* - Upload (false): existing folders are silently merged, so only files count.
|
||||
* - Copy/move (true): these move flat top-level selections, so a same-named
|
||||
* direct child is the only preflight conflict the backend will reject.
|
||||
*
|
||||
* The destination tree is only walked recursively when an entry actually lands
|
||||
* below the destination (a folder upload). Walking it for a flat upload made
|
||||
* pressing Upload wait on a full server-side walk of the whole subtree before
|
||||
* a single byte was sent, which reads as a frozen UI on a large destination.
|
||||
*
|
||||
* @param files - flat upload list to check
|
||||
* @param basePath - server destination path (e.g. "/files/uploads/")
|
||||
@@ -47,27 +112,21 @@ export async function checkConflict(
|
||||
): Promise<ConflictingResource[]> {
|
||||
if (files.length === 0) return [];
|
||||
|
||||
let serverEntries: RecursiveEntry[];
|
||||
const recursive = !includeDirectories && hasNestedEntries(files);
|
||||
|
||||
let serverEntries: ServerConflictEntry[];
|
||||
try {
|
||||
// Single API call: fetch the entire server tree under basePath.
|
||||
serverEntries = await api.fetchAll(basePath);
|
||||
serverEntries = await fetchConflictEntries(basePath, recursive);
|
||||
} catch {
|
||||
// The destination doesn't exist yet, so nothing can conflict.
|
||||
return [];
|
||||
}
|
||||
|
||||
// The server returns paths absolute within the user's scope
|
||||
// (e.g. "/uploads/sub/file.txt"). Strip the basePath prefix so the keys line
|
||||
// up with each entry's conflictKey, which is relative to the destination.
|
||||
const normBase = removePrefix(basePath).replace(/\/+$/, "");
|
||||
const serverMap = new Map<string, RecursiveEntry>();
|
||||
for (const entry of serverEntries) {
|
||||
// A Windows server may return OS-native backslash separators; normalize to
|
||||
// forward slashes so the prefix strip and key lookup line up.
|
||||
const path = entry.path.replace(/\\/g, "/");
|
||||
const rel = path.startsWith(normBase) ? path.slice(normBase.length) : path;
|
||||
serverMap.set(rel.replace(/^\/+/, ""), entry);
|
||||
}
|
||||
const serverMap = buildConflictMap(
|
||||
serverEntries,
|
||||
basePath,
|
||||
includeDirectories
|
||||
);
|
||||
|
||||
const conflicts: ConflictingResource[] = [];
|
||||
files.forEach((file, index) => {
|
||||
@@ -78,7 +137,7 @@ export async function checkConflict(
|
||||
|
||||
conflicts.push({
|
||||
index,
|
||||
name: server.path,
|
||||
name: conflictPath(server),
|
||||
origin: { lastModified: file.file?.lastModified, size: file.size },
|
||||
dest: { lastModified: server.modified, size: server.size },
|
||||
checked: ["origin"],
|
||||
|
||||
@@ -34,6 +34,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" v-if="user?.perm.admin">
|
||||
<div class="card-title">
|
||||
<h2>{{ t("settings.sunsetTitle") }}</h2>
|
||||
</div>
|
||||
|
||||
<div class="card-content">
|
||||
<p>{{ t("settings.sunsetBody") }}</p>
|
||||
<p>
|
||||
<a
|
||||
href="https://github.com/filebrowser/filebrowser#security"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{{ t("settings.sunsetLink") }}</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading">
|
||||
<h2 class="message delayed">
|
||||
<div class="spinner">
|
||||
|
||||
@@ -162,7 +162,11 @@
|
||||
"
|
||||
style="height: 12em; padding: 0; margin: 0"
|
||||
>
|
||||
<img style="height: 12em" :src="raw" />
|
||||
<img
|
||||
style="height: 12em"
|
||||
:src="raw"
|
||||
:alt="req.items[fileStore.selected[0]].name"
|
||||
/>
|
||||
</a>
|
||||
<div
|
||||
v-else-if="
|
||||
|
||||
@@ -348,6 +348,7 @@ import { useLayoutStore } from "@/stores/layout";
|
||||
import { users, files as api } from "@/api";
|
||||
import { enableExec } from "@/utils/constants";
|
||||
import * as upload from "@/utils/upload";
|
||||
import buttons from "@/utils/buttons";
|
||||
import css from "@/utils/css";
|
||||
import { throttle } from "lodash-es";
|
||||
import { Base64 } from "js-base64";
|
||||
@@ -821,11 +822,15 @@ const drop = async (event: DragEvent) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Checking the destination hits the server, so show it is working rather
|
||||
// than leaving the action looking inert until the upload starts.
|
||||
buttons.loading("upload");
|
||||
const conflict = await upload.checkConflict(files, path);
|
||||
|
||||
const preselect = removePrefix(path) + (files[0].fullPath || files[0].name);
|
||||
|
||||
if (conflict.length > 0) {
|
||||
buttons.done("upload");
|
||||
layoutStore.showHover({
|
||||
prompt: "resolve-conflict",
|
||||
props: {
|
||||
@@ -846,7 +851,7 @@ const drop = async (event: DragEvent) => {
|
||||
}
|
||||
}
|
||||
if (files.length > 0) {
|
||||
upload.handleFiles(files, path, true);
|
||||
upload.handleFiles(files, path);
|
||||
fileStore.preselect = preselect;
|
||||
}
|
||||
},
|
||||
@@ -879,9 +884,14 @@ const uploadInput = async (event: Event) => {
|
||||
}
|
||||
|
||||
const path = route.path.endsWith("/") ? route.path : route.path + "/";
|
||||
|
||||
// Checking the destination hits the server, so show it is working rather
|
||||
// than leaving the action looking inert until the upload starts.
|
||||
buttons.loading("upload");
|
||||
const conflict = await upload.checkConflict(uploadFiles, path);
|
||||
|
||||
if (conflict.length > 0) {
|
||||
buttons.done("upload");
|
||||
layoutStore.showHover({
|
||||
prompt: "resolve-conflict",
|
||||
props: {
|
||||
@@ -902,7 +912,7 @@ const uploadInput = async (event: Event) => {
|
||||
}
|
||||
}
|
||||
if (uploadFiles.length > 0) {
|
||||
upload.handleFiles(uploadFiles, path, true);
|
||||
upload.handleFiles(uploadFiles, path);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import FileListing from "@/views/files/FileListing.vue";
|
||||
import UploadPrompt from "@/components/prompts/Upload.vue";
|
||||
|
||||
const harness = vi.hoisted(() => ({
|
||||
checkConflict: vi.fn(),
|
||||
scanFiles: vi.fn(),
|
||||
handleFiles: vi.fn(),
|
||||
queueUpload: vi.fn(),
|
||||
showHover: vi.fn(),
|
||||
closeHovers: vi.fn(),
|
||||
fileStore: {
|
||||
req: { items: [] },
|
||||
selected: [] as number[],
|
||||
selectedCount: 0,
|
||||
multiple: false,
|
||||
preselect: "",
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("@/stores/auth", () => ({
|
||||
useAuthStore: () => ({ user: null }),
|
||||
}));
|
||||
vi.mock("@/stores/clipboard", () => ({
|
||||
useClipboardStore: () => ({ items: [], $patch: vi.fn() }),
|
||||
}));
|
||||
vi.mock("@/stores/file", () => ({
|
||||
useFileStore: () => harness.fileStore,
|
||||
}));
|
||||
vi.mock("@/stores/layout", () => ({
|
||||
useLayoutStore: () => ({
|
||||
currentPrompt: null,
|
||||
showHover: harness.showHover,
|
||||
closeHovers: harness.closeHovers,
|
||||
}),
|
||||
}));
|
||||
vi.mock("@/stores/upload", () => ({
|
||||
useUploadStore: () => ({ upload: harness.queueUpload }),
|
||||
}));
|
||||
vi.mock("@/api", () => ({
|
||||
users: {},
|
||||
files: {},
|
||||
}));
|
||||
vi.mock("@/utils/constants", () => ({ enableExec: false }));
|
||||
vi.mock("@/utils/auth", () => ({}));
|
||||
vi.mock("@/router", () => ({ default: {} }));
|
||||
vi.mock("@/i18n", () => ({ default: {} }));
|
||||
vi.mock("@/utils/upload", () => ({
|
||||
checkConflict: harness.checkConflict,
|
||||
scanFiles: harness.scanFiles,
|
||||
handleFiles: harness.handleFiles,
|
||||
}));
|
||||
vi.mock("@/utils/css", () => ({ default: vi.fn() }));
|
||||
// Reaches document.querySelector, which the node test environment lacks.
|
||||
vi.mock("@/utils/buttons", () => ({
|
||||
default: { loading: vi.fn(), done: vi.fn(), success: vi.fn() },
|
||||
}));
|
||||
vi.mock("@/components/header/HeaderBar.vue", () => ({ default: {} }));
|
||||
vi.mock("@/components/header/Action.vue", () => ({ default: {} }));
|
||||
vi.mock("@/components/Search.vue", () => ({ default: {} }));
|
||||
vi.mock("@/components/files/ListingItem.vue", () => ({ default: {} }));
|
||||
vi.mock("@/components/ContextMenu.vue", () => ({ default: {} }));
|
||||
vi.mock("vue-router", () => ({
|
||||
useRoute: () => ({ path: "/files/target/" }),
|
||||
onBeforeRouteUpdate: vi.fn(),
|
||||
}));
|
||||
vi.mock("vue-i18n", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("vue-i18n")>()),
|
||||
useI18n: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
vi.mock("pinia", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("pinia")>()),
|
||||
storeToRefs: () => ({ req: { value: harness.fileStore.req } }),
|
||||
}));
|
||||
vi.mock("vue", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("vue")>()),
|
||||
inject: () => vi.fn(),
|
||||
watch: vi.fn(),
|
||||
onMounted: vi.fn(),
|
||||
onBeforeUnmount: vi.fn(),
|
||||
useSSRContext: () => ({ modules: new Set<string>() }),
|
||||
}));
|
||||
|
||||
const file = (name: string): UploadEntry => ({
|
||||
file: { name, size: 12, type: "text/plain" } as File,
|
||||
name,
|
||||
size: 12,
|
||||
isDir: false,
|
||||
});
|
||||
|
||||
const conflict = (
|
||||
index: number,
|
||||
checked: Array<"origin" | "dest">
|
||||
): ConflictingResource => ({
|
||||
index,
|
||||
name: `/target/file-${index}.txt`,
|
||||
origin: { size: 12 },
|
||||
dest: { size: 10 },
|
||||
checked,
|
||||
isSmallerOnServer: true,
|
||||
});
|
||||
|
||||
function setup(component: any) {
|
||||
return component.setup({}, { expose: vi.fn() });
|
||||
}
|
||||
|
||||
function confirmPrompt(result: ConflictingResource[]) {
|
||||
const prompt = harness.showHover.mock.calls[0][0];
|
||||
prompt.confirm({ preventDefault: vi.fn() }, result);
|
||||
}
|
||||
|
||||
async function runActualHandleFiles() {
|
||||
const [files, path, overwrite] = harness.handleFiles.mock.calls[0];
|
||||
const actual =
|
||||
await vi.importActual<typeof import("@/utils/upload")>("@/utils/upload");
|
||||
actual.handleFiles(files, path, overwrite);
|
||||
}
|
||||
|
||||
function uploadFlags() {
|
||||
return harness.queueUpload.mock.calls.map((call) => call[3]);
|
||||
}
|
||||
|
||||
describe("upload conflict resolution", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
harness.fileStore.preselect = "";
|
||||
vi.stubGlobal("window", {
|
||||
innerWidth: 1024,
|
||||
innerHeight: 768,
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
});
|
||||
vi.stubGlobal("document", {
|
||||
getElementsByClassName: () => [],
|
||||
});
|
||||
});
|
||||
|
||||
it("authorizes an explicit drag/drop Replace choice", async () => {
|
||||
const upload = file("file-0.txt");
|
||||
harness.scanFiles.mockResolvedValue([upload]);
|
||||
harness.checkConflict.mockResolvedValue([conflict(0, ["origin"])]);
|
||||
const bindings = setup(FileListing);
|
||||
|
||||
await bindings.drop({
|
||||
preventDefault: vi.fn(),
|
||||
dataTransfer: { files: [upload.file], items: [] },
|
||||
target: {
|
||||
classList: { contains: () => false },
|
||||
parentElement: null,
|
||||
},
|
||||
});
|
||||
confirmPrompt([conflict(0, ["origin"])]);
|
||||
await runActualHandleFiles();
|
||||
|
||||
expect(uploadFlags()).toEqual([true]);
|
||||
});
|
||||
|
||||
it("keeps the forbidden both-selected upload overwrite-safe", async () => {
|
||||
const upload = file("file-0.txt");
|
||||
harness.scanFiles.mockResolvedValue([upload]);
|
||||
harness.checkConflict.mockResolvedValue([conflict(0, ["origin"])]);
|
||||
const bindings = setup(FileListing);
|
||||
|
||||
await bindings.drop({
|
||||
preventDefault: vi.fn(),
|
||||
dataTransfer: { files: [upload.file], items: [] },
|
||||
target: {
|
||||
classList: { contains: () => false },
|
||||
parentElement: null,
|
||||
},
|
||||
});
|
||||
confirmPrompt([conflict(0, ["origin", "dest"])]);
|
||||
await runActualHandleFiles();
|
||||
|
||||
expect(uploadFlags()).toEqual([false]);
|
||||
});
|
||||
|
||||
it("applies Replace only to the selected file in a mixed batch", async () => {
|
||||
const conflicting = file("file-0.txt");
|
||||
const nonconflicting = file("new-file.txt");
|
||||
harness.checkConflict.mockResolvedValue([conflict(0, ["origin"])]);
|
||||
const bindings = setup(FileListing);
|
||||
|
||||
await bindings.uploadInput({
|
||||
currentTarget: { files: [conflicting.file, nonconflicting.file] },
|
||||
});
|
||||
confirmPrompt([conflict(0, ["origin"])]);
|
||||
await runActualHandleFiles();
|
||||
|
||||
expect(uploadFlags()).toEqual([true, false]);
|
||||
});
|
||||
|
||||
it("keeps a nonconflicting sibling protected after Skip", async () => {
|
||||
const conflicting = file("file-0.txt");
|
||||
const nonconflicting = file("late-file.txt");
|
||||
harness.checkConflict.mockResolvedValue([conflict(0, ["origin"])]);
|
||||
const bindings = setup(FileListing);
|
||||
|
||||
await bindings.uploadInput({
|
||||
currentTarget: { files: [conflicting.file, nonconflicting.file] },
|
||||
});
|
||||
confirmPrompt([conflict(0, ["dest"])]);
|
||||
await runActualHandleFiles();
|
||||
|
||||
expect(harness.queueUpload).toHaveBeenCalledTimes(1);
|
||||
expect(harness.queueUpload).toHaveBeenCalledWith(
|
||||
"/files/target/late-file.txt",
|
||||
"late-file.txt",
|
||||
nonconflicting.file,
|
||||
false,
|
||||
"text"
|
||||
);
|
||||
});
|
||||
|
||||
it("matches the Upload prompt per-file overwrite semantics", async () => {
|
||||
const conflicting = file("file-0.txt");
|
||||
const nonconflicting = file("new-file.txt");
|
||||
harness.checkConflict.mockResolvedValue([conflict(0, ["origin"])]);
|
||||
const bindings = setup(UploadPrompt);
|
||||
|
||||
await bindings.uploadInput({
|
||||
currentTarget: { files: [conflicting.file, nonconflicting.file] },
|
||||
});
|
||||
confirmPrompt([conflict(0, ["origin"])]);
|
||||
await runActualHandleFiles();
|
||||
|
||||
expect(uploadFlags()).toEqual([true, false]);
|
||||
});
|
||||
});
|
||||
@@ -262,6 +262,7 @@ const error = ref<StatusError | null>(null);
|
||||
const originalSettings = ref<ISettings | null>(null);
|
||||
const settings = ref<ISettings | null>(null);
|
||||
const debounceTimeout = ref<number | null>(null);
|
||||
const pendingChunkSize = ref<string | null>(null);
|
||||
|
||||
const commandObject = ref<{
|
||||
[key: string]: string[] | string;
|
||||
@@ -289,13 +290,30 @@ const formattedChunkSize = computed({
|
||||
clearTimeout(debounceTimeout.value);
|
||||
}
|
||||
|
||||
pendingChunkSize.value = value;
|
||||
|
||||
// Set a new timeout to apply the format after a short delay
|
||||
debounceTimeout.value = window.setTimeout(() => {
|
||||
if (settings.value) settings.value.tus.chunkSize = parseBytes(value);
|
||||
}, 1500);
|
||||
debounceTimeout.value = window.setTimeout(applyChunkSize, 1500);
|
||||
},
|
||||
});
|
||||
|
||||
// applyChunkSize commits what the user typed. Saving must flush it first:
|
||||
// otherwise submitting within the debounce window persists the previous value,
|
||||
// and the setting appears to refuse the change.
|
||||
const applyChunkSize = () => {
|
||||
if (debounceTimeout.value) {
|
||||
clearTimeout(debounceTimeout.value);
|
||||
debounceTimeout.value = null;
|
||||
}
|
||||
|
||||
if (pendingChunkSize.value === null) return;
|
||||
|
||||
if (settings.value) {
|
||||
settings.value.tus.chunkSize = parseBytes(pendingChunkSize.value);
|
||||
}
|
||||
pendingChunkSize.value = null;
|
||||
};
|
||||
|
||||
// Define funcs
|
||||
const capitalize = (name: string, where: string | RegExp = "_") => {
|
||||
if (where === "caps") where = /(?=[A-Z])/;
|
||||
@@ -311,6 +329,7 @@ const capitalize = (name: string, where: string | RegExp = "_") => {
|
||||
|
||||
const save = async () => {
|
||||
if (settings.value === null) return false;
|
||||
applyChunkSize();
|
||||
const newSettings: ISettings = {
|
||||
...settings.value,
|
||||
shell:
|
||||
@@ -362,8 +381,12 @@ const parseBytes = (input: string) => {
|
||||
const matches = input.match(regex);
|
||||
if (matches) {
|
||||
const size = parseFloat(matches[1].concat(matches[2] || ""));
|
||||
let unit: keyof SettingsUnit =
|
||||
matches[3].toUpperCase() as keyof SettingsUnit;
|
||||
// The unit is optional: a bare number is already a count of bytes. Reading
|
||||
// it unguarded throws, and the throw happens inside the debounce callback,
|
||||
// so the setting is silently never updated.
|
||||
let unit: keyof SettingsUnit = (
|
||||
matches[3] ?? "B"
|
||||
).toUpperCase() as keyof SettingsUnit;
|
||||
if (!unit.endsWith("B")) {
|
||||
unit += "B";
|
||||
}
|
||||
|
||||
@@ -4,42 +4,42 @@ go 1.25.0
|
||||
|
||||
require (
|
||||
github.com/asdine/storm/v3 v3.2.1
|
||||
github.com/asticode/go-astisub v0.40.0
|
||||
github.com/asticode/go-astisub v0.42.0
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/dsoprea/go-exif/v3 v3.0.1
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/jellydator/ttlcache/v3 v3.4.0
|
||||
github.com/jellydator/ttlcache/v3 v3.4.1
|
||||
github.com/maruel/natural v1.3.0
|
||||
github.com/marusama/semaphore/v2 v2.5.0
|
||||
github.com/mholt/archives v0.1.5
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/redis/go-redis/v9 v9.20.1
|
||||
github.com/redis/go-redis/v9 v9.21.0
|
||||
github.com/samber/lo v1.53.0
|
||||
github.com/shirou/gopsutil/v4 v4.26.5
|
||||
github.com/shirou/gopsutil/v4 v4.26.6
|
||||
github.com/spf13/afero v1.15.0
|
||||
github.com/spf13/cobra v1.10.2
|
||||
github.com/spf13/pflag v1.0.10
|
||||
github.com/spf13/viper v1.21.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce
|
||||
go.etcd.io/bbolt v1.4.3
|
||||
golang.org/x/crypto v0.53.0
|
||||
golang.org/x/image v0.42.0
|
||||
golang.org/x/text v0.38.0
|
||||
go.etcd.io/bbolt v1.5.0
|
||||
golang.org/x/crypto v0.54.0
|
||||
golang.org/x/image v0.44.0
|
||||
golang.org/x/text v0.40.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/STARRY-S/zip v0.2.3 // indirect
|
||||
github.com/andybalholm/brotli v1.2.1 // indirect
|
||||
github.com/andybalholm/brotli v1.2.2 // indirect
|
||||
github.com/asticode/go-astikit v0.59.0 // indirect
|
||||
github.com/asticode/go-astits v1.15.0 // indirect
|
||||
github.com/bodgit/plumbing v1.3.0 // indirect
|
||||
github.com/bodgit/sevenzip v1.6.4 // indirect
|
||||
github.com/bodgit/sevenzip v1.6.5 // indirect
|
||||
github.com/bodgit/windows v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
|
||||
@@ -47,21 +47,21 @@ require (
|
||||
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
|
||||
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 // indirect
|
||||
github.com/ebitengine/purego v0.10.1 // indirect
|
||||
github.com/ebitengine/purego v0.10.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.10.1 // indirect
|
||||
github.com/go-errors/errors v1.5.1 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
||||
github.com/golang/geo v0.0.0-20260612074446-f1a45663b0f3 // indirect
|
||||
github.com/golang/geo v0.0.0-20260713102120-857a528af641 // indirect
|
||||
github.com/golang/snappy v1.0.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/klauspost/compress v1.18.6 // indirect
|
||||
github.com/klauspost/compress v1.19.1 // indirect
|
||||
github.com/klauspost/pgzip v1.2.6 // indirect
|
||||
github.com/mikelolasagasti/xz v1.0.1 // indirect
|
||||
github.com/minio/minlz v1.1.1 // indirect
|
||||
github.com/nwaples/rardecode/v2 v2.2.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
|
||||
github.com/minio/minlz v1.2.0 // indirect
|
||||
github.com/nwaples/rardecode/v2 v2.2.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.4.3 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.27 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||
@@ -71,14 +71,14 @@ require (
|
||||
github.com/spf13/cast v1.10.0 // indirect
|
||||
github.com/stangelandcl/ppmd v0.1.1 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/ulikunitz/xz v0.5.15 // indirect
|
||||
github.com/ulikunitz/xz v0.5.16 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
go4.org v0.0.0-20260112195520-a5071408f32f // indirect
|
||||
golang.org/x/net v0.56.0 // indirect
|
||||
golang.org/x/sync v0.21.0 // indirect
|
||||
golang.org/x/sys v0.46.0 // indirect
|
||||
golang.org/x/net v0.57.0 // indirect
|
||||
golang.org/x/sync v0.22.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
@@ -4,23 +4,23 @@ github.com/STARRY-S/zip v0.2.3 h1:luE4dMvRPDOWQdeDdUxUoZkzUIpTccdKdhHHsQJ1fm4=
|
||||
github.com/STARRY-S/zip v0.2.3/go.mod h1:lqJ9JdeRipyOQJrYSOtpNAiaesFO6zVDsE8GIGFaoSk=
|
||||
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863 h1:BRrxwOZBolJN4gIwvZMJY1tzqBvQgpaZiQRuIDD40jM=
|
||||
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
|
||||
github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eTWro=
|
||||
github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
|
||||
github.com/andybalholm/brotli v1.2.2 h1:HzTuoo2ErYQqf5qvcJInB8uvqSVxRttzkFexPWtnceM=
|
||||
github.com/andybalholm/brotli v1.2.2/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
|
||||
github.com/asdine/storm/v3 v3.2.1 h1:I5AqhkPK6nBZ/qJXySdI7ot5BlXSZ7qvDY1zAn5ZJac=
|
||||
github.com/asdine/storm/v3 v3.2.1/go.mod h1:LEpXwGt4pIqrE/XcTvCnZHT5MgZCV6Ub9q7yQzOFWr0=
|
||||
github.com/asticode/go-astikit v0.20.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
|
||||
github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
|
||||
github.com/asticode/go-astikit v0.59.0 h1:tjbwDym+MTSxqkAhJoHRZmHMXK6Jv4vGx+97FptKH6k=
|
||||
github.com/asticode/go-astikit v0.59.0/go.mod h1:fV43j20UZYfXzP9oBn33udkvCvDvCDhzjVqoLFuuYZE=
|
||||
github.com/asticode/go-astisub v0.40.0 h1:Z8tAXHngjkh/4L9zqt49ru9UdpDTqBIe+80xexKM3/I=
|
||||
github.com/asticode/go-astisub v0.40.0/go.mod h1:WTkuSzFB+Bp7wezuSf2Oxulj5A8zu2zLRVFf6bIFQK8=
|
||||
github.com/asticode/go-astisub v0.42.0 h1:IJuJJTQwCSFeY9bx1kTzdCwkIeG27wj4CAh6nHc+pvY=
|
||||
github.com/asticode/go-astisub v0.42.0/go.mod h1:WTkuSzFB+Bp7wezuSf2Oxulj5A8zu2zLRVFf6bIFQK8=
|
||||
github.com/asticode/go-astits v1.8.0/go.mod h1:DkOWmBNQpnr9mv24KfZjq4JawCFX1FCqjLVGvO0DygQ=
|
||||
github.com/asticode/go-astits v1.15.0 h1:yRyCiUc8Jj4F7clt2GDxHghMpWuFL5rkaLuGUd2/0J4=
|
||||
github.com/asticode/go-astits v1.15.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
|
||||
github.com/bodgit/plumbing v1.3.0 h1:pf9Itz1JOQgn7vEOE7v7nlEfBykYqvUYioC61TwWCFU=
|
||||
github.com/bodgit/plumbing v1.3.0/go.mod h1:JOTb4XiRu5xfnmdnDJo6GmSbSbtSyufrsyZFByMtKEs=
|
||||
github.com/bodgit/sevenzip v1.6.4 h1:iHiVJfxbrB6RF4X+snI2MpVgNBKmVfGaTqZGNlMQIU0=
|
||||
github.com/bodgit/sevenzip v1.6.4/go.mod h1:ZtNi5KNgHXeXg1G7WiF0IWSuFE2eG6lt/cTGlvuirO0=
|
||||
github.com/bodgit/sevenzip v1.6.5 h1:7H7BxgmeX0j6UX42lH+KXQ92WgMQJ49DoocFdfHbCng=
|
||||
github.com/bodgit/sevenzip v1.6.5/go.mod h1:GhuB6Lq1xCpP1sps+horjZ8lgiKPJcy2zUX3prla9wc=
|
||||
github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4=
|
||||
github.com/bodgit/windows v1.0.1/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
@@ -58,8 +58,8 @@ github.com/dsoprea/go-utility/v2 v2.0.0-20221003142440-7a1927d49d9d/go.mod h1:LV
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003160719-7bc88537c05e/go.mod h1:VZ7cB0pTjm1ADBWhJUOHESu4ZYy9JN+ZPqjfiW09EPU=
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 h1:DilThiXje0z+3UQ5YjYiSRRzVdtamFpvBQXKwMglWqw=
|
||||
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349/go.mod h1:4GC5sXji84i/p+irqghpPFZBF8tRN/Q7+700G0/DLe8=
|
||||
github.com/ebitengine/purego v0.10.1 h1:dewVBCBT2GaMu1SrNTYxQhgQBethzfhiwvZiLGP/qyY=
|
||||
github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/ebitengine/purego v0.10.2 h1:W809HbnvzAxgdm+aOvlSekrM16wGCdT/e76+9tS7gzE=
|
||||
github.com/ebitengine/purego v0.10.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
@@ -82,8 +82,8 @@ github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArs
|
||||
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
|
||||
github.com/golang/geo v0.0.0-20200319012246-673a6f80352d/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
|
||||
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
|
||||
github.com/golang/geo v0.0.0-20260612074446-f1a45663b0f3 h1:UlucSQUu9SZdDRlMWv5N/T3Rig9gv615vWvHFKrXHWA=
|
||||
github.com/golang/geo v0.0.0-20260612074446-f1a45663b0f3/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8=
|
||||
github.com/golang/geo v0.0.0-20260713102120-857a528af641 h1:cpoobkgVGCE6bC5kJkOfwfM6hAtZuvoBjnCLECxG4AU=
|
||||
github.com/golang/geo v0.0.0-20260713102120-857a528af641/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -101,13 +101,13 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jellydator/ttlcache/v3 v3.4.0 h1:YS4P125qQS0tNhtL6aeYkheEaB/m8HCqdMMP4mnWdTY=
|
||||
github.com/jellydator/ttlcache/v3 v3.4.0/go.mod h1:Hw9EgjymziQD3yGsQdf1FqFdpp7YjFMd4Srg5EJlgD4=
|
||||
github.com/jellydator/ttlcache/v3 v3.4.1 h1:bOdXmXiycyK6E6Qjyuj5vl+/vU3SCOoDs8a86NbHjAQ=
|
||||
github.com/jellydator/ttlcache/v3 v3.4.1/go.mod h1:j7LO12PNghFg5+0v9budMAT4rDK4JY969jb9vOdOBBk=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
|
||||
github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
||||
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/cpuid v1.2.0 h1:NMpwD2G9JSFOE1/TJjGSo5zG7Yb2bTe7eq1jH+irmeE=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
@@ -130,14 +130,14 @@ github.com/mholt/archives v0.1.5 h1:Fh2hl1j7VEhc6DZs2DLMgiBNChUux154a1G+2esNvzQ=
|
||||
github.com/mholt/archives v0.1.5/go.mod h1:3TPMmBLPsgszL+1As5zECTuKwKvIfj6YcwWPpeTAXF4=
|
||||
github.com/mikelolasagasti/xz v1.0.1 h1:Q2F2jX0RYJUG3+WsM+FJknv+6eVjsjXNDV0KJXZzkD0=
|
||||
github.com/mikelolasagasti/xz v1.0.1/go.mod h1:muAirjiOUxPRXwm9HdDtB3uoRPrGnL85XHtokL9Hcgc=
|
||||
github.com/minio/minlz v1.1.1 h1:OGmft1V6AnI/Wme332U6bhG54nxEan+VFgkD7lat4KM=
|
||||
github.com/minio/minlz v1.1.1/go.mod h1:qT0aEB35q79LLornSzeDH75LBf3aH1MV+jB5w9Wasec=
|
||||
github.com/minio/minlz v1.2.0 h1:6IOBuiHg04QxvbFfgFLT/9sMaO/UhL7S+ApW1mK8q5A=
|
||||
github.com/minio/minlz v1.2.0/go.mod h1:Ls9H7nlkASeCcdl5thjVD5Eraj6z+zGa7xtq57jIKD4=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/nwaples/rardecode/v2 v2.2.3 h1:qaVuy3ChZDbAQZshPLjHeNJKF3Cru8uo9jmgveKIy2A=
|
||||
github.com/nwaples/rardecode/v2 v2.2.3/go.mod h1:7uz379lSxPe6j9nvzxUZ+n7mnJNgjsRNb6IbvGVHRmw=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7olPtrEc=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/nwaples/rardecode/v2 v2.2.5 h1:L5doqgGfQwI7qADJMqnkrSB86rpPsqQDrHeO0HWa5JY=
|
||||
github.com/nwaples/rardecode/v2 v2.2.5/go.mod h1:7uz379lSxPe6j9nvzxUZ+n7mnJNgjsRNb6IbvGVHRmw=
|
||||
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
|
||||
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pierrec/lz4/v4 v4.1.27 h1:+PhzhWDrjRj89TH2sw43nE3+4+W8lSxIuQadEHZyjUk=
|
||||
github.com/pierrec/lz4/v4 v4.1.27/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=
|
||||
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
|
||||
@@ -146,8 +146,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/redis/go-redis/v9 v9.20.1 h1:sfCU6A8P3dXbKyWes02uxA2baehGux9dZHfEKtsTB1w=
|
||||
github.com/redis/go-redis/v9 v9.20.1/go.mod h1:v/M13XI1PVCDcm01VtPFOADfZtHf8YW3baQf57KlIkA=
|
||||
github.com/redis/go-redis/v9 v9.21.0 h1:FPBE4hhbAke+TLmcY3WkpbDffJEomdqPn3HYiqAtL9E=
|
||||
github.com/redis/go-redis/v9 v9.21.0/go.mod h1:v/M13XI1PVCDcm01VtPFOADfZtHf8YW3baQf57KlIkA=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
@@ -156,8 +156,8 @@ github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88ee
|
||||
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
|
||||
github.com/samber/lo v1.53.0 h1:t975lj2py4kJPQ6haz1QMgtId2gtmfktACxIXArw3HM=
|
||||
github.com/samber/lo v1.53.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||
github.com/shirou/gopsutil/v4 v4.26.5 h1:RPcBXkpz7kOj9PqGFQOlBPZHsyaPvPVQc098y9RmCNM=
|
||||
github.com/shirou/gopsutil/v4 v4.26.5/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=
|
||||
github.com/shirou/gopsutil/v4 v4.26.6 h1:Mzr/npDtQC/xpeEuQKHZt8Zo9CmPvhTj8nkR8w5TLDs=
|
||||
github.com/shirou/gopsutil/v4 v4.26.6/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=
|
||||
github.com/sorairolake/lzip-go v0.3.8 h1:j5Q2313INdTA80ureWYRhX+1K78mUXfMoPZCw/ivWik=
|
||||
github.com/sorairolake/lzip-go v0.3.8/go.mod h1:JcBqGMV0frlxwrsE9sMWXDjqn3EeVf0/54YPsw66qkU=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
@@ -190,8 +190,8 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW
|
||||
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9Hv8eCYJYvIGUTN2/KLq1pT6CjEc=
|
||||
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4=
|
||||
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY=
|
||||
github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/ulikunitz/xz v0.5.16 h1:ld6NyySjx5lowVKwJvMRLnW5nxKX/xnpSiFYZ/Lxur0=
|
||||
github.com/ulikunitz/xz v0.5.16/go.mod h1:H9Rt/W6/Qj27PGauhQc6nfCDy7vHpzsOThBSaYDoEhw=
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
||||
@@ -201,8 +201,8 @@ github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQ
|
||||
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
||||
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
||||
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||
go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo=
|
||||
go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E=
|
||||
go.etcd.io/bbolt v1.5.0 h1:S7GAl7Fxv12yohbwFfIbQCGDWbQbtDGPET4P/bD4lxU=
|
||||
go.etcd.io/bbolt v1.5.0/go.mod h1:mkltfYE5aUHQxUct9N9V+Kp7aSjFqjgrhcXIS70Lrdk=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
@@ -213,11 +213,11 @@ go4.org v0.0.0-20260112195520-a5071408f32f h1:ziUVAjmTPwQMBmYR1tbdRFJPtTcQUI12fH
|
||||
go4.org v0.0.0-20260112195520-a5071408f32f/go.mod h1:ZRJnO5ZI4zAwMFp+dS1+V6J6MSyAowhRqAE+DPa1Xp0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
|
||||
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
|
||||
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
|
||||
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.42.0 h1:1gSs6ehNWXLbkHBIPcWztk3D/6aIA/8hauiAYtlodVY=
|
||||
golang.org/x/image v0.42.0/go.mod h1:rrpelvGFt+kLPAjPM4HeWPgrl0FtafueU//e5N0qk/Q=
|
||||
golang.org/x/image v0.44.0 h1:+tDekMZED9+LrtB3G5xzRggpVh9CARjZqROla3R3R+I=
|
||||
golang.org/x/image v0.44.0/go.mod h1:V8K3KE9KKKE+pLpQDOeN18w9oacNSvy1tDOirTu4xtY=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20191105084925-a882066a44e0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -227,10 +227,10 @@ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
|
||||
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
|
||||
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
||||
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -242,14 +242,14 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
||||
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
||||
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
|
||||
|
||||
+39
-26
@@ -66,7 +66,7 @@ func (e extractor) ExtractToken(r *http.Request) (string, error) {
|
||||
return "", request.ErrNoTokenInRequest
|
||||
}
|
||||
|
||||
func renewableErr(err error, d *data) bool {
|
||||
func renewableErr(err error, r *http.Request, d *data, tk *authToken) bool {
|
||||
if d.settings.AuthMethod != fbAuth.MethodProxyAuth || err == nil {
|
||||
return false
|
||||
}
|
||||
@@ -79,7 +79,38 @@ func renewableErr(err error, d *data) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
// The expiration is only waived because the trusted proxy, not the token,
|
||||
// decides when the session ends. Require the proxy to still assert the same
|
||||
// identity on this request, otherwise a token that leaked before it expired
|
||||
// would authenticate on its own forever.
|
||||
return proxyAsserts(r, d, tk.User.ID)
|
||||
}
|
||||
|
||||
// proxyAsserts reports whether the proxy-auth header on r identifies the user
|
||||
// the token was issued for. The username is resolved through the user store, so
|
||||
// that it is matched exactly as a regular proxy login would match it.
|
||||
func proxyAsserts(r *http.Request, d *data, id uint) bool {
|
||||
auther, err := d.store.Auth.Get(fbAuth.MethodProxyAuth)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
proxy, ok := auther.(*fbAuth.ProxyAuth)
|
||||
if !ok || proxy.Header == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
username := r.Header.Get(proxy.Header)
|
||||
if username == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
user, err := d.store.Users.Get(d.server.Root, d.server.FollowExternalSymlinks, username)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return user.ID == id
|
||||
}
|
||||
|
||||
func withUser(fn handleFunc) handleFunc {
|
||||
@@ -91,7 +122,7 @@ func withUser(fn handleFunc) handleFunc {
|
||||
var tk authToken
|
||||
p := jwt.NewParser(jwt.WithValidMethods([]string{jwt.SigningMethodHS256.Alg()}), jwt.WithExpirationRequired())
|
||||
token, err := request.ParseFromRequest(r, &extractor{}, keyFunc, request.WithClaims(&tk), request.WithParser(p))
|
||||
if (err != nil || !token.Valid) && !renewableErr(err, d) {
|
||||
if (err != nil || !token.Valid) && !renewableErr(err, r, d, &tk) {
|
||||
return http.StatusUnauthorized, nil
|
||||
}
|
||||
|
||||
@@ -106,6 +137,8 @@ func withUser(fn handleFunc) handleFunc {
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
canonicalizeRequestPath(r)
|
||||
return fn(w, r, d)
|
||||
}
|
||||
}
|
||||
@@ -191,35 +224,15 @@ var signupHandler = func(w http.ResponseWriter, r *http.Request, d *data) (int,
|
||||
}
|
||||
|
||||
user.Password = pwd
|
||||
if d.settings.CreateUserDir {
|
||||
user.Scope = ""
|
||||
}
|
||||
|
||||
userHome, err := d.settings.MakeUserDir(user.Username, user.Scope, d.server.Root)
|
||||
derivedScope, err := d.settings.CreateUserHome(user, d.server.Root, false)
|
||||
if err != nil {
|
||||
log.Printf("create user: failed to mkdir user home dir: [%s]", userHome)
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
user.Scope = userHome
|
||||
|
||||
// When home directories are created from the username, distinct usernames
|
||||
// can normalize to the same scope (cleanUsername is many-to-one), which would
|
||||
// silently hand the new user another user's home directory. Reject the signup
|
||||
// if the derived scope is already taken. When CreateUserDir is off, all
|
||||
// signups intentionally share the configured default scope, so this check
|
||||
// does not apply.
|
||||
if d.settings.CreateUserDir {
|
||||
switch _, err := d.store.Users.GetByScope(user.Scope); {
|
||||
case err == nil:
|
||||
return http.StatusConflict, fberrors.ErrExist
|
||||
case !errors.Is(err, fberrors.ErrNotExist):
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
}
|
||||
log.Printf("new user: %s, home dir: [%s].", user.Username, user.Scope)
|
||||
|
||||
log.Printf("new user: %s, home dir: [%s].", user.Username, userHome)
|
||||
|
||||
err = d.store.Users.Save(user)
|
||||
err = d.store.Users.SaveProvisioned(user, derivedScope)
|
||||
if errors.Is(err, fberrors.ErrExist) {
|
||||
return http.StatusConflict, err
|
||||
} else if err != nil {
|
||||
|
||||
@@ -6,11 +6,15 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/asdine/storm/v3"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
|
||||
fbAuth "github.com/filebrowser/filebrowser/v2/auth"
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/storage/bolt"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// Regression for the username-normalization home-directory collision
|
||||
@@ -69,3 +73,79 @@ func TestSignupRejectsCollidingNormalizedScope(t *testing.T) {
|
||||
t.Fatalf("scope owner = %q, want teamone-x", owner.Username)
|
||||
}
|
||||
}
|
||||
|
||||
// Regression for GHSA-v3jv-rmh2-635j: under proxy auth with a non-default
|
||||
// logout page the JWT expiration is waived, because the proxy owns the session
|
||||
// lifetime. That exception used to apply to every route on the strength of the
|
||||
// token alone, so a token stolen before it expired kept working — and could be
|
||||
// renewed — indefinitely. The proxy must still assert the same identity.
|
||||
func TestExpiredTokenNeedsProxyAssertion(t *testing.T) {
|
||||
const proxyHeader = "X-Fb-User"
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Download: true}
|
||||
st := scopedUserStorage(t, t.TempDir(), perm, key)
|
||||
|
||||
if err := st.Settings.Save(&settings.Settings{
|
||||
Key: key,
|
||||
AuthMethod: fbAuth.MethodProxyAuth,
|
||||
LogoutPage: "/logged-out",
|
||||
}); err != nil {
|
||||
t.Fatalf("failed to save settings: %v", err)
|
||||
}
|
||||
if err := st.Auth.Save(&fbAuth.ProxyAuth{Header: proxyHeader}); err != nil {
|
||||
t.Fatalf("failed to save auther: %v", err)
|
||||
}
|
||||
|
||||
expired := &authToken{
|
||||
User: userInfo{ID: 1, Username: "u", Perm: perm},
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
IssuedAt: jwt.NewNumericDate(time.Now().Add(-2 * time.Hour)),
|
||||
ExpiresAt: jwt.NewNumericDate(time.Now().Add(-time.Hour)),
|
||||
},
|
||||
}
|
||||
expiredToken, err := jwt.NewWithClaims(jwt.SigningMethodHS256, expired).SignedString(key)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to sign token: %v", err)
|
||||
}
|
||||
|
||||
protected := withUser(func(w http.ResponseWriter, _ *http.Request, _ *data) (int, error) {
|
||||
_, writeErr := w.Write([]byte("protected"))
|
||||
return 0, writeErr
|
||||
})
|
||||
|
||||
get := func(token, proxyUser string) *httptest.ResponseRecorder {
|
||||
req, _ := http.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req.Header.Set("X-Auth", token)
|
||||
if proxyUser != "" {
|
||||
req.Header.Set(proxyHeader, proxyUser)
|
||||
}
|
||||
rec := httptest.NewRecorder()
|
||||
handle(protected, "", st, &settings.Server{}).ServeHTTP(rec, req)
|
||||
return rec
|
||||
}
|
||||
|
||||
t.Run("expired token alone is rejected", func(t *testing.T) {
|
||||
if rec := get(expiredToken, ""); rec.Code != http.StatusUnauthorized {
|
||||
t.Errorf("VULNERABLE: expired token without the proxy header = %d, body=%q; want 401", rec.Code, rec.Body.String())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("expired token for another identity is rejected", func(t *testing.T) {
|
||||
if rec := get(expiredToken, "someone-else"); rec.Code != http.StatusUnauthorized {
|
||||
t.Errorf("VULNERABLE: expired token with a foreign proxy identity = %d; want 401", rec.Code)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("expired token the proxy still asserts is accepted", func(t *testing.T) {
|
||||
if rec := get(expiredToken, "u"); rec.Code != http.StatusOK {
|
||||
t.Errorf("expired token asserted by the proxy = %d, body=%q; want 200", rec.Code, rec.Body.String())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("valid token needs no assertion", func(t *testing.T) {
|
||||
if rec := get(signToken(t, perm, key), ""); rec.Code != http.StatusOK {
|
||||
t.Errorf("valid token = %d, body=%q; want 200", rec.Code, rec.Body.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
+39
-18
@@ -35,6 +35,44 @@ type data struct {
|
||||
|
||||
// Check implements rules.Checker.
|
||||
func (d *data) Check(path string) bool {
|
||||
if d.user.HideDotfiles && rules.MatchHidden(d.rulePath(path)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return d.CheckRules(path)
|
||||
}
|
||||
|
||||
// CheckRules reports whether the global and user rules allow path. Unlike
|
||||
// Check, it ignores HideDotfiles: hiding dotfiles is a display preference, so
|
||||
// it must not stop a user from operating on a tree that contains one.
|
||||
func (d *data) CheckRules(path string) bool {
|
||||
path = d.rulePath(path)
|
||||
|
||||
allow := true
|
||||
for _, rule := range d.settings.Rules {
|
||||
if rule.Matches(path, d.server.CaseInsensitiveFs) {
|
||||
allow = rule.Allow
|
||||
}
|
||||
}
|
||||
|
||||
for _, rule := range d.user.Rules {
|
||||
if rule.Matches(path, d.server.CaseInsensitiveFs) {
|
||||
allow = rule.Allow
|
||||
}
|
||||
}
|
||||
|
||||
return allow
|
||||
}
|
||||
|
||||
// rulePath canonicalizes path into the form the rules are written in.
|
||||
func (d *data) rulePath(path string) string {
|
||||
// Rules are written as "/"-separated virtual paths, but callers hand us
|
||||
// paths built by the OS as well as ones taken from the request: afero.Walk
|
||||
// and filepath.Join use "\" on Windows, where the filesystem also treats it
|
||||
// as a separator. Canonicalize first so the authorization decision does not
|
||||
// depend on which separator the caller happened to use.
|
||||
path = slashClean(path)
|
||||
|
||||
// When the filesystem has been rebased (e.g. a public share rooted at a
|
||||
// subdirectory), the incoming path is relative to that root. Resolve it
|
||||
// back to the user's original scope before matching rules, otherwise rules
|
||||
@@ -43,24 +81,7 @@ func (d *data) Check(path string) bool {
|
||||
path = gopath.Join(d.checkerPrefix, path)
|
||||
}
|
||||
|
||||
if d.user.HideDotfiles && rules.MatchHidden(path) {
|
||||
return false
|
||||
}
|
||||
|
||||
allow := true
|
||||
for _, rule := range d.settings.Rules {
|
||||
if rule.Matches(path) {
|
||||
allow = rule.Allow
|
||||
}
|
||||
}
|
||||
|
||||
for _, rule := range d.user.Rules {
|
||||
if rule.Matches(path) {
|
||||
allow = rule.Allow
|
||||
}
|
||||
}
|
||||
|
||||
return allow
|
||||
return path
|
||||
}
|
||||
|
||||
func handle(fn handleFunc, prefix string, store *storage.Storage, server *settings.Server) http.Handler {
|
||||
|
||||
@@ -5,7 +5,9 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/afero"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/files"
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/storage"
|
||||
)
|
||||
@@ -25,6 +27,7 @@ func NewHandler(
|
||||
assetsFs fs.FS,
|
||||
) (http.Handler, error) {
|
||||
server.Clean()
|
||||
server.CaseInsensitiveFs = files.CaseInsensitive(afero.NewOsFs(), server.Root)
|
||||
|
||||
r := mux.NewRouter()
|
||||
r.Use(func(next http.Handler) http.Handler {
|
||||
|
||||
+4
-2
@@ -47,8 +47,10 @@ func previewHandler(imgSvc ImgService, fileCache FileCache, enableThumbnails, re
|
||||
}
|
||||
|
||||
file, err := files.NewFileInfo(&files.FileOptions{
|
||||
Fs: d.user.Fs,
|
||||
Path: "/" + vars["path"],
|
||||
Fs: d.user.Fs,
|
||||
// Preview reads its path from mux.Vars, not r.URL.Path, so it does
|
||||
// not get the canonicalization withUser applies.
|
||||
Path: slashClean(vars["path"]),
|
||||
Modify: d.user.Perm.Modify,
|
||||
Expand: true,
|
||||
ReadHeader: d.server.TypeDetectionByHeader,
|
||||
|
||||
+7
-4
@@ -52,14 +52,15 @@ var withHashFile = func(fn handleFunc) handleFunc {
|
||||
return errToStatus(err), err
|
||||
}
|
||||
|
||||
// share base path
|
||||
basePath := link.Path
|
||||
// share base path. Canonicalized because it roots both the rebased
|
||||
// filesystem and checkerPrefix below, and a stored path that is not
|
||||
// "/"-separated would make the two disagree on Windows.
|
||||
basePath := slashClean(link.Path)
|
||||
|
||||
// file relative path
|
||||
filePath := ""
|
||||
|
||||
if file.IsDir {
|
||||
basePath = filepath.Clean(link.Path)
|
||||
filePath = ifPath
|
||||
}
|
||||
|
||||
@@ -109,7 +110,9 @@ func ifPathWithName(r *http.Request) (id, filePath string) {
|
||||
case 1:
|
||||
return r.URL.Path, "/"
|
||||
default:
|
||||
return pathElements[0], path.Join("/", path.Join(pathElements[1:]...))
|
||||
// Public share routes do not pass through withUser, so canonicalize the
|
||||
// share-relative path here instead.
|
||||
return pathElements[0], slashClean(path.Join(pathElements[1:]...))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,6 @@ import (
|
||||
"github.com/mholt/archives"
|
||||
)
|
||||
|
||||
func slashClean(name string) string {
|
||||
if name == "" || name[0] != '/' {
|
||||
name = "/" + name
|
||||
}
|
||||
return gopath.Clean(name)
|
||||
}
|
||||
|
||||
func parseQueryFiles(r *http.Request, f *files.FileInfo, _ *users.User) ([]string, error) {
|
||||
var fileSlice []string
|
||||
names := strings.Split(r.URL.Query().Get("files"), ",")
|
||||
|
||||
+66
-3
@@ -67,6 +67,10 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
|
||||
}
|
||||
|
||||
if checksum := r.URL.Query().Get("checksum"); checksum != "" {
|
||||
if !d.user.Perm.Download {
|
||||
return http.StatusAccepted, nil
|
||||
}
|
||||
|
||||
err := file.Checksum(checksum)
|
||||
if errors.Is(err, fberrors.ErrInvalidOption) {
|
||||
return http.StatusBadRequest, nil
|
||||
@@ -99,6 +103,10 @@ func resourceDeleteHandler(fileCache FileCache) handleFunc {
|
||||
return errToStatus(err), err
|
||||
}
|
||||
|
||||
if err = checkDescendants(d, r.URL.Path, ""); err != nil {
|
||||
return errToStatus(err), err
|
||||
}
|
||||
|
||||
err = d.store.Share.DeleteWithPathPrefix(file.Path, d.user.ID)
|
||||
if err != nil {
|
||||
log.Printf("WARNING: Error(s) occurred while deleting associated shares with file: %s", err)
|
||||
@@ -130,7 +138,9 @@ func resourcePostHandler(fileCache FileCache) handleFunc {
|
||||
|
||||
// Directories creation on POST.
|
||||
if strings.HasSuffix(r.URL.Path, "/") {
|
||||
err := d.user.Fs.MkdirAll(r.URL.Path, d.settings.DirMode)
|
||||
err := d.RunHook(func() error {
|
||||
return d.user.Fs.MkdirAll(r.URL.Path, d.settings.DirMode)
|
||||
}, "upload", r.URL.Path, "", d.user)
|
||||
return errToStatus(err), err
|
||||
}
|
||||
|
||||
@@ -215,8 +225,8 @@ func resourcePatchHandler(fileCache FileCache) handleFunc {
|
||||
dst := r.URL.Query().Get("destination")
|
||||
action := r.URL.Query().Get("action")
|
||||
dst, err := url.QueryUnescape(dst)
|
||||
dst = path.Clean("/" + dst)
|
||||
src = path.Clean("/" + src)
|
||||
dst = slashClean(dst)
|
||||
src = slashClean(src)
|
||||
if !d.Check(src) || !d.Check(dst) {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
@@ -253,6 +263,10 @@ func resourcePatchHandler(fileCache FileCache) handleFunc {
|
||||
}
|
||||
}
|
||||
|
||||
if err = checkDescendants(d, src, dst); err != nil {
|
||||
return errToStatus(err), err
|
||||
}
|
||||
|
||||
err = d.RunHook(func() error {
|
||||
return patchAction(r.Context(), action, src, dst, d, fileCache)
|
||||
}, action, src, dst, d.user)
|
||||
@@ -261,6 +275,42 @@ func resourcePatchHandler(fileCache FileCache) handleFunc {
|
||||
})
|
||||
}
|
||||
|
||||
// checkDescendants reports an error if the rules deny any path inside the src
|
||||
// tree or, when dst is not empty, the location that tree would land on. The
|
||||
// handlers only authorize the root of the operation, but copy, rename and
|
||||
// delete then recurse through the whole subtree, so a rule denying a descendant
|
||||
// of an allowed directory would be bypassed by operating on the parent instead.
|
||||
func checkDescendants(d *data, src, dst string) error {
|
||||
if len(d.settings.Rules) == 0 && len(d.user.Rules) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return afero.Walk(d.user.Fs, src, func(fPath string, _ os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !d.CheckRules(fPath) {
|
||||
return fberrors.ErrPermissionDenied
|
||||
}
|
||||
|
||||
if dst == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
rel, err := filepath.Rel(src, fPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !d.CheckRules(filepath.Join(dst, rel)) {
|
||||
return fberrors.ErrPermissionDenied
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func checkParent(src, dst string) error {
|
||||
rel, err := filepath.Rel(src, dst)
|
||||
if err != nil {
|
||||
@@ -406,6 +456,13 @@ var resourceGetRecursiveHandler = withUser(func(w http.ResponseWriter, r *http.R
|
||||
entries := make([]RecursiveEntry, 0)
|
||||
|
||||
err = afero.Walk(d.user.Fs, rootPath, func(fPath string, info os.FileInfo, err error) error {
|
||||
// Walking a large tree is expensive, and every entry is stat'ed through
|
||||
// the scoped filesystem. Stop as soon as nobody is waiting for the
|
||||
// answer instead of finishing the walk for a client that has gone.
|
||||
if ctxErr := r.Context().Err(); ctxErr != nil {
|
||||
return ctxErr
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil // skip entries we cannot read
|
||||
}
|
||||
@@ -436,6 +493,12 @@ var resourceGetRecursiveHandler = withUser(func(w http.ResponseWriter, r *http.R
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
// Once the request is done there is nobody left to answer, whatever the
|
||||
// walk reported. Asking for a status here only produces a second header
|
||||
// write on a connection that is already gone.
|
||||
if r.Context().Err() != nil {
|
||||
return 0, err
|
||||
}
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// The ?checksum= branch reads the whole file to compute a digest, so it must be
|
||||
// gated behind Perm.Download like the other read paths. A user without download
|
||||
// permission must not obtain a digest of a file they cannot download.
|
||||
func TestResourceChecksumRequiresDownloadPermission(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
userScope := filepath.Join(root, "user")
|
||||
if err := os.MkdirAll(userScope, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(userScope, "secret.txt"), []byte("classified"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
key := []byte("test-signing-key")
|
||||
|
||||
get := func(t *testing.T, perm users.Permissions) *httptest.ResponseRecorder {
|
||||
st := scopedUserStorage(t, userScope, perm, key)
|
||||
req, _ := http.NewRequest(http.MethodGet, "/secret.txt?checksum=sha256", http.NoBody)
|
||||
req.Header.Set("X-Auth", signToken(t, perm, key))
|
||||
rec := httptest.NewRecorder()
|
||||
handle(resourceGetHandler, "", st, &settings.Server{}).ServeHTTP(rec, req)
|
||||
return rec
|
||||
}
|
||||
|
||||
t.Run("denied without download permission", func(t *testing.T) {
|
||||
rec := get(t, users.Permissions{})
|
||||
if rec.Code != http.StatusAccepted {
|
||||
t.Fatalf("expected 202, got %d body=%q", rec.Code, rec.Body.String())
|
||||
}
|
||||
if strings.Contains(strings.ToLower(rec.Body.String()), "checksum") {
|
||||
t.Fatalf("digest leaked without download permission: %q", rec.Body.String())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("allowed with download permission", func(t *testing.T) {
|
||||
rec := get(t, users.Permissions{Download: true})
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("expected 200, got %d body=%q", rec.Code, rec.Body.String())
|
||||
}
|
||||
if !strings.Contains(rec.Body.String(), "checksums") {
|
||||
t.Fatalf("expected a checksum in the response, got %q", rec.Body.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
func recursiveTestHandler(t *testing.T, userScope string) (http.Handler, string) {
|
||||
t.Helper()
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Create: true, Modify: true, Download: true}
|
||||
st := scopedUserStorage(t, userScope, perm, key)
|
||||
|
||||
return handle(resourceGetRecursiveHandler, "/api/resources/recursive", st, &settings.Server{}), signToken(t, perm, key)
|
||||
}
|
||||
|
||||
func TestResourceRecursiveListsTree(t *testing.T) {
|
||||
userScope := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(userScope, "target", "nested"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(userScope, "target", "nested", "file.txt"), []byte("hi"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
handler, token := recursiveTestHandler(t, userScope)
|
||||
|
||||
req, _ := http.NewRequest(http.MethodGet, "/api/resources/recursive/target", http.NoBody)
|
||||
req.Header.Set("X-Auth", token)
|
||||
rec := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d body = %q", rec.Code, rec.Body.String())
|
||||
}
|
||||
|
||||
var entries []RecursiveEntry
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &entries); err != nil {
|
||||
t.Fatalf("decode response: %v", err)
|
||||
}
|
||||
if len(entries) != 2 {
|
||||
t.Fatalf("got %d entries, want 2: %+v", len(entries), entries)
|
||||
}
|
||||
}
|
||||
|
||||
// Walking the tree stats every entry through the scoped filesystem, which is
|
||||
// expensive on a large destination. When the client has already hung up there
|
||||
// is nothing to answer, so the walk must stop instead of running to completion
|
||||
// and then reporting a write failure as a 500.
|
||||
func TestResourceRecursiveStopsWhenClientDisconnects(t *testing.T) {
|
||||
userScope := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(userScope, "target"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(userScope, "target", "file.txt"), []byte("hi"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
handler, token := recursiveTestHandler(t, userScope)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "/api/resources/recursive/target", http.NoBody)
|
||||
req.Header.Set("X-Auth", token)
|
||||
rec := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rec, req)
|
||||
|
||||
if body := rec.Body.String(); body != "" {
|
||||
t.Fatalf("wrote a response for a disconnected client: %q", body)
|
||||
}
|
||||
}
|
||||
@@ -222,3 +222,38 @@ func TestResourcePostCleanupDoesNotDeleteThroughSymlink(t *testing.T) {
|
||||
t.Fatalf("VULNERABLE: out-of-scope victim.txt deleted by cleanup RemoveAll (status=%d): %v", rec.Code, statErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResourcePostRunsUploadHooksForDirectories(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
userScope := filepath.Join(root, "user")
|
||||
if err := os.MkdirAll(userScope, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Create: true}
|
||||
st := scopedUserStorage(t, userScope, perm, key)
|
||||
if err := st.Settings.Save(&settings.Settings{
|
||||
Key: key,
|
||||
Commands: map[string][]string{
|
||||
"after_upload": {"filebrowser-hook-command-that-does-not-exist"},
|
||||
},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
req, _ := http.NewRequest(http.MethodPost, "/created/", http.NoBody)
|
||||
req.Header.Set("X-Auth", signToken(t, perm, key))
|
||||
rec := httptest.NewRecorder()
|
||||
handle(resourcePostHandler(diskcache.NewNoOp()), "", st, &settings.Server{EnableExec: true}).ServeHTTP(rec, req)
|
||||
|
||||
// A missing after_upload command makes the request fail only if the hook ran.
|
||||
// It avoids a platform-specific helper executable while still exercising the
|
||||
// same path the web UI uses for directory uploads.
|
||||
if rec.Code != http.StatusInternalServerError {
|
||||
t.Fatalf("expected directory upload hook failure to return 500, got %d body=%q", rec.Code, rec.Body.String())
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(userScope, "created")); err != nil {
|
||||
t.Fatalf("expected directory to be created before its after hook, got %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/diskcache"
|
||||
"github.com/filebrowser/filebrowser/v2/rules"
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/storage"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// denyRuleStorage builds a scoped storage whose global settings deny denyPath.
|
||||
func denyRuleStorage(t *testing.T, userScope, denyPath string, perm users.Permissions, key []byte) *storage.Storage {
|
||||
t.Helper()
|
||||
st := scopedUserStorage(t, userScope, perm, key)
|
||||
if err := st.Settings.Save(&settings.Settings{
|
||||
Key: key,
|
||||
Rules: []rules.Rule{{Path: denyPath, Allow: false}},
|
||||
}); err != nil {
|
||||
t.Fatalf("failed to save settings: %v", err)
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
// Regression for GHSA-fgm5-pw99-w2p7: on a case-insensitive filesystem
|
||||
// /Secret.txt and /secret.TXT name the same file, so a deny rule for one must
|
||||
// cover the other. The rule check runs before any filesystem access, so the 403
|
||||
// is asserted on every platform; the flag is what does the work, which the
|
||||
// case-sensitive half of the test pins down.
|
||||
func TestRuleDeniesCaseVariantWhenFsIsCaseInsensitive(t *testing.T) {
|
||||
userScope := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(userScope, "Secret.txt"), []byte("SECRET"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Download: true}
|
||||
st := denyRuleStorage(t, userScope, "/Secret.txt", perm, key)
|
||||
signed := signToken(t, perm, key)
|
||||
|
||||
get := func(path string, caseInsensitive bool) *httptest.ResponseRecorder {
|
||||
req, _ := http.NewRequest(http.MethodGet, path, http.NoBody)
|
||||
req.Header.Set("X-Auth", signed)
|
||||
rec := httptest.NewRecorder()
|
||||
handle(rawHandler, "", st, &settings.Server{CaseInsensitiveFs: caseInsensitive}).ServeHTTP(rec, req)
|
||||
return rec
|
||||
}
|
||||
|
||||
t.Run("canonical path is denied either way", func(t *testing.T) {
|
||||
for _, caseInsensitive := range []bool{false, true} {
|
||||
if rec := get("/Secret.txt", caseInsensitive); rec.Code != http.StatusForbidden {
|
||||
t.Errorf("GET /Secret.txt (caseInsensitive=%v) = %d; want 403", caseInsensitive, rec.Code)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("case variant is denied on a case-insensitive filesystem", func(t *testing.T) {
|
||||
if rec := get("/secret.TXT", true); rec.Code != http.StatusForbidden {
|
||||
t.Errorf("VULNERABLE: GET /secret.TXT = %d, body=%q; want 403", rec.Code, rec.Body.String())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("case variant is a distinct path on a case-sensitive filesystem", func(t *testing.T) {
|
||||
if rec := get("/secret.TXT", false); rec.Code == http.StatusForbidden {
|
||||
t.Error("GET /secret.TXT = 403 with folding off; the rule must not widen on a case-sensitive filesystem")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Regression for GHSA-fgm5-pw99-w2p7: a path is canonicalized before it is
|
||||
// matched against the rules, so a traversal sequence cannot reach a denied file
|
||||
// by spelling its way there. gorilla/mux cleans forward-slash traversal before
|
||||
// routing, so this is defense in depth on POSIX; on Windows the equivalent
|
||||
// backslash form reaches the handler intact, which cleanSeparators covers.
|
||||
func TestRuleDeniesTraversalToDeniedPath(t *testing.T) {
|
||||
userScope := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(userScope, "allow"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(userScope, "Secret.txt"), []byte("SECRET"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Download: true}
|
||||
st := denyRuleStorage(t, userScope, "/Secret.txt", perm, key)
|
||||
|
||||
req, _ := http.NewRequest(http.MethodGet, "/allow/../Secret.txt", http.NoBody)
|
||||
req.Header.Set("X-Auth", signToken(t, perm, key))
|
||||
rec := httptest.NewRecorder()
|
||||
handle(rawHandler, "", st, &settings.Server{}).ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusForbidden {
|
||||
t.Fatalf("VULNERABLE: GET /allow/../Secret.txt = %d, body=%q; want 403", rec.Code, rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
// Canonicalizing the request path must not drop a trailing separator: POST
|
||||
// distinguishes "/dir/" (create a directory) from "/dir" (write a file), and
|
||||
// PUT rejects the directory form outright.
|
||||
func TestCanonicalizeRequestPathKeepsTrailingSlash(t *testing.T) {
|
||||
userScope := t.TempDir()
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Create: true, Modify: true}
|
||||
st := scopedUserStorage(t, userScope, perm, key)
|
||||
signed := signToken(t, perm, key)
|
||||
|
||||
t.Run("post creates a directory", func(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodPost, "/newdir/", http.NoBody)
|
||||
req.Header.Set("X-Auth", signed)
|
||||
rec := httptest.NewRecorder()
|
||||
handle(resourcePostHandler(diskcache.NewNoOp()), "", st, &settings.Server{}).ServeHTTP(rec, req)
|
||||
|
||||
info, err := os.Stat(filepath.Join(userScope, "newdir"))
|
||||
if err != nil {
|
||||
t.Fatalf("POST /newdir/ = %d, body=%q; directory not created: %v", rec.Code, rec.Body.String(), err)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
t.Error("POST /newdir/ created a file, not a directory")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("put rejects a directory path", func(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodPut, "/newdir/", http.NoBody)
|
||||
req.Header.Set("X-Auth", signed)
|
||||
rec := httptest.NewRecorder()
|
||||
handle(resourcePutHandler, "", st, &settings.Server{}).ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusMethodNotAllowed {
|
||||
t.Errorf("PUT /newdir/ = %d; want 405", rec.Code)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/diskcache"
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/storage"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// Regression for GHSA-77x8-73f4-5485: copy, rename and delete authorize only
|
||||
// the root of the operation and then recurse through the whole subtree, so a
|
||||
// rule denying /src/secret used to be bypassed by copying, moving or deleting
|
||||
// the allowed parent /src.
|
||||
func TestRecursiveOperationsEnforceDescendantRules(t *testing.T) {
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Create: true, Modify: true, Rename: true, Delete: true, Download: true}
|
||||
|
||||
// scope builds a user scope holding an allowed parent with a denied child,
|
||||
// plus an entirely allowed tree to prove legitimate operations still run.
|
||||
scope := func(t *testing.T) (userScope string, st *storage.Storage) {
|
||||
t.Helper()
|
||||
userScope = t.TempDir()
|
||||
for _, dir := range []string{filepath.Join("src", "secret"), "clean"} {
|
||||
if err := os.MkdirAll(filepath.Join(userScope, dir), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
files := map[string]string{
|
||||
filepath.Join("src", "public.txt"): "public",
|
||||
filepath.Join("src", "secret", "marker.txt"): "SECRET",
|
||||
filepath.Join("clean", "file.txt"): "clean",
|
||||
}
|
||||
for name, content := range files {
|
||||
if err := os.WriteFile(filepath.Join(userScope, name), []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
return userScope, denyRuleStorage(t, userScope, "/src/secret", perm, key)
|
||||
}
|
||||
|
||||
do := func(t *testing.T, st *storage.Storage, handler handleFunc, method, target string) *httptest.ResponseRecorder {
|
||||
t.Helper()
|
||||
req, _ := http.NewRequest(method, target, http.NoBody)
|
||||
req.Header.Set("X-Auth", signToken(t, perm, key))
|
||||
rec := httptest.NewRecorder()
|
||||
handle(handler, "", st, &settings.Server{}).ServeHTTP(rec, req)
|
||||
return rec
|
||||
}
|
||||
|
||||
exists := func(t *testing.T, path string) bool {
|
||||
t.Helper()
|
||||
_, err := os.Stat(path)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
t.Run("denied descendant is not directly readable", func(t *testing.T) {
|
||||
_, st := scope(t)
|
||||
if rec := do(t, st, rawHandler, http.MethodGet, "/src/secret/marker.txt"); rec.Code != http.StatusForbidden {
|
||||
t.Fatalf("GET /src/secret/marker.txt = %d; want 403", rec.Code)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("copying the parent does not expose it", func(t *testing.T) {
|
||||
userScope, st := scope(t)
|
||||
rec := do(t, st, resourcePatchHandler(diskcache.NewNoOp()), http.MethodPatch, "/src?action=copy&destination=/dst")
|
||||
|
||||
if leaked := filepath.Join(userScope, "dst", "secret", "marker.txt"); exists(t, leaked) {
|
||||
t.Fatalf("VULNERABLE: denied descendant copied to %s (status %d)", leaked, rec.Code)
|
||||
}
|
||||
if rec.Code != http.StatusForbidden {
|
||||
t.Errorf("PATCH /src?action=copy = %d; want 403", rec.Code)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("renaming the parent does not expose it", func(t *testing.T) {
|
||||
userScope, st := scope(t)
|
||||
rec := do(t, st, resourcePatchHandler(diskcache.NewNoOp()), http.MethodPatch, "/src?action=rename&destination=/moved")
|
||||
|
||||
if leaked := filepath.Join(userScope, "moved", "secret", "marker.txt"); exists(t, leaked) {
|
||||
t.Fatalf("VULNERABLE: denied descendant moved to %s (status %d)", leaked, rec.Code)
|
||||
}
|
||||
if !exists(t, filepath.Join(userScope, "src", "secret", "marker.txt")) {
|
||||
t.Error("denied descendant no longer at its original path")
|
||||
}
|
||||
if rec.Code != http.StatusForbidden {
|
||||
t.Errorf("PATCH /src?action=rename = %d; want 403", rec.Code)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("deleting the parent does not delete it", func(t *testing.T) {
|
||||
userScope, st := scope(t)
|
||||
rec := do(t, st, resourceDeleteHandler(diskcache.NewNoOp()), http.MethodDelete, "/src")
|
||||
|
||||
if !exists(t, filepath.Join(userScope, "src", "secret", "marker.txt")) {
|
||||
t.Fatalf("VULNERABLE: denied descendant deleted through its parent (status %d)", rec.Code)
|
||||
}
|
||||
if rec.Code != http.StatusForbidden {
|
||||
t.Errorf("DELETE /src = %d; want 403", rec.Code)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("an entirely allowed tree still copies", func(t *testing.T) {
|
||||
userScope, st := scope(t)
|
||||
rec := do(t, st, resourcePatchHandler(diskcache.NewNoOp()), http.MethodPatch, "/clean?action=copy&destination=/clean-copy")
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("PATCH /clean?action=copy = %d, body=%q; want 200", rec.Code, rec.Body.String())
|
||||
}
|
||||
if !exists(t, filepath.Join(userScope, "clean-copy", "file.txt")) {
|
||||
t.Error("allowed tree was not copied")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -110,6 +110,7 @@ func getStaticHandlers(store *storage.Storage, server *settings.Server, assetsFs
|
||||
}
|
||||
|
||||
w.Header().Set("x-xss-protection", "1; mode=block")
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
return handleWithStaticData(w, r, d, assetsFs, "public/index.html", "text/html; charset=utf-8")
|
||||
}, "", store, server)
|
||||
|
||||
@@ -124,6 +125,7 @@ func getStaticHandlers(store *storage.Storage, server *settings.Server, assetsFs
|
||||
|
||||
const maxAge = 86400 // 1 day
|
||||
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%v", maxAge))
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
|
||||
if d.settings.Branding.Files != "" {
|
||||
if strings.HasPrefix(r.URL.Path, "img/") {
|
||||
|
||||
+136
-81
@@ -15,6 +15,24 @@ import (
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
// maxPatchDrainBytes bounds how much of a rejected PATCH body is discarded to
|
||||
// keep the connection reusable. It comfortably covers a default-sized chunk;
|
||||
// beyond that the body is not worth reading just to throw away.
|
||||
const maxPatchDrainBytes = 32 << 20 // 32MB
|
||||
|
||||
// drainRequestBody discards what the client already put on the wire for a
|
||||
// request the handler answered without reading. net/http only drains 256KiB on
|
||||
// its own before giving up and closing the connection, and a connection closed
|
||||
// while the client is still streaming a chunk reaches the browser as a transport
|
||||
// error instead of the status we replied with. The client then cannot tell a
|
||||
// conflict from a network fault, retries blindly, and the upload stalls.
|
||||
func drainRequestBody(r *http.Request) {
|
||||
if r.Body == nil {
|
||||
return
|
||||
}
|
||||
_, _ = io.Copy(io.Discard, io.LimitReader(r.Body, maxPatchDrainBytes))
|
||||
}
|
||||
|
||||
// keepUploadActive periodically touches the cache entry to prevent eviction during transfer
|
||||
func keepUploadActive(cache UploadCache, filePath string) func() {
|
||||
stop := make(chan bool)
|
||||
@@ -109,8 +127,13 @@ func tusPostHandler(cache UploadCache) handleFunc {
|
||||
return http.StatusBadRequest, fmt.Errorf("invalid upload length: %w", err)
|
||||
}
|
||||
|
||||
// Enables the user to utilize the PATCH endpoint for uploading file data
|
||||
cache.Register(file.RealPath(), uploadLength)
|
||||
// Enables the user to utilize the PATCH endpoint for uploading file data.
|
||||
// The removal callback deletes an abandoned upload through the user's
|
||||
// scoped filesystem, so eviction cannot follow a symlink out of scope.
|
||||
uploadPath := r.URL.Path
|
||||
cache.Register(file.RealPath(), uploadLength, func() error {
|
||||
return d.user.Fs.Remove(uploadPath)
|
||||
})
|
||||
|
||||
basePath := "/" + strings.Trim(strings.TrimSpace(d.server.BaseURL), "/")
|
||||
if basePath == "/" {
|
||||
@@ -155,89 +178,121 @@ func tusHeadHandler(cache UploadCache) handleFunc {
|
||||
|
||||
func tusPatchHandler(cache UploadCache) handleFunc {
|
||||
return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||
if !d.user.Perm.Create || !d.Check(r.URL.Path) {
|
||||
return http.StatusForbidden, nil
|
||||
status, err := tusPatchUpload(w, r, d, cache)
|
||||
// A rejected chunk is still a chunk the client is streaming: read what is
|
||||
// left of it so the answer reaches the client on a connection that stays
|
||||
// usable, instead of being lost to a reset.
|
||||
if status >= 400 {
|
||||
drainRequestBody(r)
|
||||
}
|
||||
if r.Header.Get("Content-Type") != "application/offset+octet-stream" {
|
||||
return http.StatusUnsupportedMediaType, nil
|
||||
}
|
||||
|
||||
uploadOffset, err := getUploadOffset(r)
|
||||
if err != nil {
|
||||
return http.StatusBadRequest, fmt.Errorf("invalid upload offset")
|
||||
}
|
||||
|
||||
file, err := files.NewFileInfo(&files.FileOptions{
|
||||
Fs: d.user.Fs,
|
||||
Path: r.URL.Path,
|
||||
Modify: d.user.Perm.Modify,
|
||||
Expand: false,
|
||||
ReadHeader: d.server.TypeDetectionByHeader,
|
||||
Checker: d,
|
||||
})
|
||||
|
||||
switch {
|
||||
case errors.Is(err, afero.ErrFileNotFound):
|
||||
return http.StatusNotFound, nil
|
||||
case err != nil:
|
||||
return errToStatus(err), err
|
||||
}
|
||||
|
||||
uploadLength, err := cache.GetLength(file.RealPath())
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
|
||||
// Prevent the upload from being evicted during the transfer
|
||||
stop := keepUploadActive(cache, file.RealPath())
|
||||
defer stop()
|
||||
|
||||
switch {
|
||||
case file.IsDir:
|
||||
return http.StatusBadRequest, fmt.Errorf("cannot upload to a directory %s", file.RealPath())
|
||||
case file.Size != uploadOffset:
|
||||
return http.StatusConflict, fmt.Errorf(
|
||||
"%s file size doesn't match the provided offset: %d",
|
||||
file.RealPath(),
|
||||
uploadOffset,
|
||||
)
|
||||
}
|
||||
|
||||
openFile, err := d.user.Fs.OpenFile(r.URL.Path, os.O_WRONLY|os.O_APPEND, d.settings.FileMode)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not open file: %w", err)
|
||||
}
|
||||
defer openFile.Close()
|
||||
|
||||
_, err = openFile.Seek(uploadOffset, 0)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not seek file: %w", err)
|
||||
}
|
||||
|
||||
defer r.Body.Close()
|
||||
bytesWritten, err := io.Copy(openFile, r.Body)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not write to file: %w", err)
|
||||
}
|
||||
|
||||
// Sync the file to ensure all data is written to storage
|
||||
// to prevent file corruption.
|
||||
if err := openFile.Sync(); err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not sync file: %w", err)
|
||||
}
|
||||
|
||||
newOffset := uploadOffset + bytesWritten
|
||||
w.Header().Set("Upload-Offset", strconv.FormatInt(newOffset, 10))
|
||||
|
||||
if newOffset >= uploadLength {
|
||||
cache.Complete(file.RealPath())
|
||||
_ = d.RunHook(func() error { return nil }, "upload", r.URL.Path, "", d.user)
|
||||
}
|
||||
|
||||
return http.StatusNoContent, nil
|
||||
return status, err
|
||||
})
|
||||
}
|
||||
|
||||
func tusPatchUpload(w http.ResponseWriter, r *http.Request, d *data, cache UploadCache) (int, error) {
|
||||
if !d.user.Perm.Create || !d.Check(r.URL.Path) {
|
||||
return http.StatusForbidden, nil
|
||||
}
|
||||
if r.Header.Get("Content-Type") != "application/offset+octet-stream" {
|
||||
return http.StatusUnsupportedMediaType, nil
|
||||
}
|
||||
|
||||
uploadOffset, err := getUploadOffset(r)
|
||||
if err != nil {
|
||||
return http.StatusBadRequest, fmt.Errorf("invalid upload offset")
|
||||
}
|
||||
|
||||
file, err := files.NewFileInfo(&files.FileOptions{
|
||||
Fs: d.user.Fs,
|
||||
Path: r.URL.Path,
|
||||
Modify: d.user.Perm.Modify,
|
||||
Expand: false,
|
||||
ReadHeader: d.server.TypeDetectionByHeader,
|
||||
Checker: d,
|
||||
})
|
||||
|
||||
switch {
|
||||
case errors.Is(err, afero.ErrFileNotFound):
|
||||
return http.StatusNotFound, nil
|
||||
case err != nil:
|
||||
return errToStatus(err), err
|
||||
}
|
||||
|
||||
uploadLength, err := cache.GetLength(file.RealPath())
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
|
||||
if uploadOffset > uploadLength {
|
||||
return http.StatusBadRequest, fmt.Errorf("upload offset %d exceeds declared length %d", uploadOffset, uploadLength)
|
||||
}
|
||||
|
||||
// Prevent the upload from being evicted during the transfer
|
||||
stop := keepUploadActive(cache, file.RealPath())
|
||||
defer stop()
|
||||
|
||||
switch {
|
||||
case file.IsDir:
|
||||
return http.StatusBadRequest, fmt.Errorf("cannot upload to a directory %s", file.RealPath())
|
||||
case file.Size != uploadOffset:
|
||||
return http.StatusConflict, fmt.Errorf(
|
||||
"%s file size doesn't match the provided offset: %d",
|
||||
file.RealPath(),
|
||||
uploadOffset,
|
||||
)
|
||||
}
|
||||
|
||||
openFile, err := d.user.Fs.OpenFile(r.URL.Path, os.O_WRONLY|os.O_APPEND, d.settings.FileMode)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not open file: %w", err)
|
||||
}
|
||||
defer openFile.Close()
|
||||
|
||||
_, err = openFile.Seek(uploadOffset, 0)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not seek file: %w", err)
|
||||
}
|
||||
|
||||
// The server closes the request body once the handler returns; closing it
|
||||
// here would run before the caller gets to drain a rejected chunk, so every
|
||||
// status raised below this point would still cost the connection.
|
||||
//
|
||||
// Enforce the declared Upload-Length: never write more than the bytes
|
||||
// still expected for this upload. Reading one byte past the remainder
|
||||
// lets an over-length body be detected and rejected. Without this bound a
|
||||
// PATCH could stream arbitrary data to disk regardless of the length the
|
||||
// client declared when the upload was created.
|
||||
remaining := uploadLength - uploadOffset
|
||||
bytesWritten, err := io.Copy(openFile, io.LimitReader(r.Body, remaining+1))
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not write to file: %w", err)
|
||||
}
|
||||
if bytesWritten > remaining {
|
||||
// The client sent more than it declared; roll this chunk back so the
|
||||
// file stays consistent with the tracked offset, and reject it.
|
||||
if truncErr := openFile.Truncate(uploadOffset); truncErr != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not truncate file: %w", truncErr)
|
||||
}
|
||||
return http.StatusRequestEntityTooLarge, fmt.Errorf("upload exceeds declared length of %d bytes", uploadLength)
|
||||
}
|
||||
|
||||
// Sync the file to ensure all data is written to storage
|
||||
// to prevent file corruption.
|
||||
if err := openFile.Sync(); err != nil {
|
||||
return http.StatusInternalServerError, fmt.Errorf("could not sync file: %w", err)
|
||||
}
|
||||
|
||||
newOffset := uploadOffset + bytesWritten
|
||||
w.Header().Set("Upload-Offset", strconv.FormatInt(newOffset, 10))
|
||||
|
||||
if newOffset >= uploadLength {
|
||||
cache.Complete(file.RealPath())
|
||||
_ = d.RunHook(func() error { return nil }, "upload", r.URL.Path, "", d.user)
|
||||
}
|
||||
|
||||
return http.StatusNoContent, nil
|
||||
}
|
||||
|
||||
func tusDeleteHandler(cache UploadCache) handleFunc {
|
||||
return withUser(func(_ http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||
if r.URL.Path == "/" || !d.user.Perm.Delete {
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/http/httptrace"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/storage"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// newTusTestServer mounts the TUS handlers behind a real HTTP server, under the
|
||||
// same "/api/tus" prefix used in production, so tests exercise connection
|
||||
// handling and header round-tripping instead of a bare ResponseRecorder.
|
||||
func newTusTestServer(t *testing.T, st *storage.Storage, cache UploadCache) *httptest.Server {
|
||||
t.Helper()
|
||||
|
||||
server := &settings.Server{}
|
||||
post := handle(tusPostHandler(cache), "/api/tus", st, server)
|
||||
head := handle(tusHeadHandler(cache), "/api/tus", st, server)
|
||||
patch := handle(tusPatchHandler(cache), "/api/tus", st, server)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/api/tus/", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodPost:
|
||||
post.ServeHTTP(w, r)
|
||||
case http.MethodHead:
|
||||
head.ServeHTTP(w, r)
|
||||
case http.MethodPatch:
|
||||
patch.ServeHTTP(w, r)
|
||||
default:
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
}
|
||||
})
|
||||
|
||||
srv := httptest.NewServer(mux)
|
||||
t.Cleanup(srv.Close)
|
||||
return srv
|
||||
}
|
||||
|
||||
// tusTestFixture wires a scoped user, an upload cache and a live server.
|
||||
type tusTestFixture struct {
|
||||
srv *httptest.Server
|
||||
client *http.Client
|
||||
token string
|
||||
scope string
|
||||
}
|
||||
|
||||
func newTusTestFixture(t *testing.T) *tusTestFixture {
|
||||
t.Helper()
|
||||
|
||||
root := t.TempDir()
|
||||
userScope := filepath.Join(root, "user")
|
||||
if err := os.MkdirAll(userScope, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Create: true, Modify: true}
|
||||
st := scopedUserStorage(t, userScope, perm, key)
|
||||
|
||||
cache := newMemoryUploadCache()
|
||||
t.Cleanup(cache.Close)
|
||||
|
||||
srv := newTusTestServer(t, st, cache)
|
||||
return &tusTestFixture{
|
||||
srv: srv,
|
||||
client: srv.Client(),
|
||||
token: signToken(t, perm, key),
|
||||
scope: userScope,
|
||||
}
|
||||
}
|
||||
|
||||
// create sends the TUS creation request and returns the absolute upload URL.
|
||||
func (f *tusTestFixture) create(t *testing.T, name string, length int) string {
|
||||
t.Helper()
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, f.srv.URL+"/api/tus/"+name+"?override=false", http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Header.Set("X-Auth", f.token)
|
||||
req.Header.Set("Upload-Length", strconv.Itoa(length))
|
||||
|
||||
res, err := f.client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("POST create: %v", err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
body, _ := io.ReadAll(res.Body)
|
||||
|
||||
if res.StatusCode != http.StatusCreated {
|
||||
t.Fatalf("POST create: status %d body %q", res.StatusCode, body)
|
||||
}
|
||||
location := res.Header.Get("Location")
|
||||
if location == "" {
|
||||
t.Fatal("POST create: missing Location header")
|
||||
}
|
||||
return f.srv.URL + location
|
||||
}
|
||||
|
||||
// patch sends one chunk and reports the response plus whether the underlying
|
||||
// connection was reused from the pool.
|
||||
func (f *tusTestFixture) patch(t *testing.T, url string, offset int, chunk []byte) (*http.Response, bool) {
|
||||
t.Helper()
|
||||
|
||||
req, err := http.NewRequest(http.MethodPatch, url, bytes.NewReader(chunk))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Header.Set("X-Auth", f.token)
|
||||
req.Header.Set("Content-Type", "application/offset+octet-stream")
|
||||
req.Header.Set("Upload-Offset", strconv.Itoa(offset))
|
||||
|
||||
var reused bool
|
||||
trace := &httptrace.ClientTrace{
|
||||
GotConn: func(info httptrace.GotConnInfo) { reused = info.Reused },
|
||||
}
|
||||
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
|
||||
|
||||
res, err := f.client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("PATCH at offset %d: %v", offset, err)
|
||||
}
|
||||
return res, reused
|
||||
}
|
||||
|
||||
func testPayload(size int) []byte {
|
||||
payload := make([]byte, size)
|
||||
for i := range payload {
|
||||
payload[i] = byte(i % 251)
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
// A file larger than the chunk size must upload across several PATCH requests
|
||||
// over a single reused connection, exactly as the web UI drives it. Each chunk
|
||||
// has to be acknowledged with 204 and the new Upload-Offset, and the resulting
|
||||
// file must be byte-identical to the source.
|
||||
func TestTusMultiChunkUpload(t *testing.T) {
|
||||
const chunkSize = 64 * 1024
|
||||
const fileSize = chunkSize*3 + 1234
|
||||
|
||||
f := newTusTestFixture(t)
|
||||
payload := testPayload(fileSize)
|
||||
uploadURL := f.create(t, "movie.bin", fileSize)
|
||||
|
||||
for offset := 0; offset < fileSize; {
|
||||
end := min(offset+chunkSize, fileSize)
|
||||
|
||||
res, _ := f.patch(t, uploadURL, offset, payload[offset:end])
|
||||
body, _ := io.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
t.Fatalf("PATCH at offset %d: status %d body %q", offset, res.StatusCode, body)
|
||||
}
|
||||
if got, want := res.Header.Get("Upload-Offset"), strconv.Itoa(end); got != want {
|
||||
t.Fatalf("PATCH at offset %d: Upload-Offset = %q, want %q", offset, got, want)
|
||||
}
|
||||
|
||||
offset = end
|
||||
}
|
||||
|
||||
got, err := os.ReadFile(filepath.Join(f.scope, "movie.bin"))
|
||||
if err != nil {
|
||||
t.Fatalf("read uploaded file: %v", err)
|
||||
}
|
||||
if !bytes.Equal(got, payload) {
|
||||
t.Fatalf("uploaded file differs from source (got %d bytes, want %d)", len(got), len(payload))
|
||||
}
|
||||
}
|
||||
|
||||
// Between chunks a client may re-synchronise with a HEAD request. It must
|
||||
// report the bytes already on disk plus the declared total, so the client can
|
||||
// resume from the right offset.
|
||||
func TestTusHeadReportsOffsetBetweenChunks(t *testing.T) {
|
||||
const chunkSize = 32 * 1024
|
||||
const fileSize = chunkSize * 2
|
||||
|
||||
f := newTusTestFixture(t)
|
||||
payload := testPayload(fileSize)
|
||||
uploadURL := f.create(t, "resume.bin", fileSize)
|
||||
|
||||
res, _ := f.patch(t, uploadURL, 0, payload[:chunkSize])
|
||||
res.Body.Close()
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
t.Fatalf("first PATCH: status %d", res.StatusCode)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(http.MethodHead, uploadURL, http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Header.Set("X-Auth", f.token)
|
||||
|
||||
headRes, err := f.client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("HEAD: %v", err)
|
||||
}
|
||||
defer headRes.Body.Close()
|
||||
|
||||
if headRes.StatusCode != http.StatusOK {
|
||||
t.Fatalf("HEAD: status %d", headRes.StatusCode)
|
||||
}
|
||||
if got, want := headRes.Header.Get("Upload-Offset"), strconv.Itoa(chunkSize); got != want {
|
||||
t.Fatalf("HEAD Upload-Offset = %q, want %q", got, want)
|
||||
}
|
||||
if got, want := headRes.Header.Get("Upload-Length"), strconv.Itoa(fileSize); got != want {
|
||||
t.Fatalf("HEAD Upload-Length = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// A PATCH that the handler rejects before reading the body must still leave the
|
||||
// connection usable. Go abandons draining an unread request body after 256 KiB
|
||||
// and then closes the socket, which turns a plain 409 into an opaque transport
|
||||
// error for the client and stalls the upload. Rejecting a chunk-sized body must
|
||||
// not cost the connection.
|
||||
func TestTusPatchRejectionKeepsConnectionUsable(t *testing.T) {
|
||||
const chunkSize = 1024 * 1024
|
||||
const fileSize = chunkSize * 2
|
||||
|
||||
f := newTusTestFixture(t)
|
||||
payload := testPayload(fileSize)
|
||||
uploadURL := f.create(t, "conflict.bin", fileSize)
|
||||
|
||||
// Land the first chunk so the file size no longer matches offset 0.
|
||||
res, _ := f.patch(t, uploadURL, 0, payload[:chunkSize])
|
||||
res.Body.Close()
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
t.Fatalf("first PATCH: status %d", res.StatusCode)
|
||||
}
|
||||
|
||||
// Replaying offset 0 with a full chunk must be answered with a real 409.
|
||||
res, _ = f.patch(t, uploadURL, 0, payload[:chunkSize])
|
||||
body, _ := io.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
if res.StatusCode != http.StatusConflict {
|
||||
t.Fatalf("stale-offset PATCH: status %d body %q, want 409", res.StatusCode, body)
|
||||
}
|
||||
|
||||
// And the connection must survive it, so the client's next attempt is not
|
||||
// reported as a network failure.
|
||||
res, reused := f.patch(t, uploadURL, chunkSize, payload[chunkSize:])
|
||||
body, _ = io.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
t.Fatalf("PATCH after rejection: status %d body %q", res.StatusCode, body)
|
||||
}
|
||||
if !reused {
|
||||
t.Fatal("connection was dropped by the rejected PATCH instead of being reused")
|
||||
}
|
||||
|
||||
got, err := os.ReadFile(filepath.Join(f.scope, "conflict.bin"))
|
||||
if err != nil {
|
||||
t.Fatalf("read uploaded file: %v", err)
|
||||
}
|
||||
if !bytes.Equal(got, payload) {
|
||||
t.Fatalf("uploaded file differs from source (got %d bytes, want %d)", len(got), len(payload))
|
||||
}
|
||||
}
|
||||
|
||||
// Same requirement for a rejection raised once the write is already underway:
|
||||
// an over-length body is refused after part of it has been read, and the rest
|
||||
// still has to be drained for the answer to survive.
|
||||
func TestTusOverLengthPatchKeepsConnectionUsable(t *testing.T) {
|
||||
const declared = 1024
|
||||
|
||||
f := newTusTestFixture(t)
|
||||
payload := testPayload(4 << 20)
|
||||
uploadURL := f.create(t, "toolong.bin", declared)
|
||||
|
||||
res, _ := f.patch(t, uploadURL, 0, payload)
|
||||
body, _ := io.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
if res.StatusCode != http.StatusRequestEntityTooLarge {
|
||||
t.Fatalf("over-length PATCH: status %d body %q, want 413", res.StatusCode, body)
|
||||
}
|
||||
|
||||
res, reused := f.patch(t, uploadURL, 0, payload[:declared])
|
||||
body, _ = io.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
if res.StatusCode != http.StatusNoContent {
|
||||
t.Fatalf("PATCH after rejection: status %d body %q", res.StatusCode, body)
|
||||
}
|
||||
if !reused {
|
||||
t.Fatal("connection was dropped by the over-length PATCH instead of being reused")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/settings"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// A TUS PATCH must not write more than the declared Upload-Length. A client that
|
||||
// declares a small length and then streams a large body must be rejected without
|
||||
// the excess being written to disk, while a correctly-sized upload still works.
|
||||
func TestTusPatchEnforcesUploadLength(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
userScope := filepath.Join(root, "user")
|
||||
if err := os.MkdirAll(userScope, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
key := []byte("test-signing-key")
|
||||
perm := users.Permissions{Create: true, Modify: true}
|
||||
st := scopedUserStorage(t, userScope, perm, key)
|
||||
signed := signToken(t, perm, key)
|
||||
|
||||
cache := newMemoryUploadCache()
|
||||
t.Cleanup(cache.Close)
|
||||
post := handle(tusPostHandler(cache), "", st, &settings.Server{})
|
||||
patch := handle(tusPatchHandler(cache), "", st, &settings.Server{})
|
||||
|
||||
patchReq := func(body string) *httptest.ResponseRecorder {
|
||||
req, _ := http.NewRequest(http.MethodPatch, "/file.txt", strings.NewReader(body))
|
||||
req.Header.Set("X-Auth", signed)
|
||||
req.Header.Set("Content-Type", "application/offset+octet-stream")
|
||||
req.Header.Set("Upload-Offset", "0")
|
||||
rec := httptest.NewRecorder()
|
||||
patch.ServeHTTP(rec, req)
|
||||
return rec
|
||||
}
|
||||
|
||||
// Create an upload that declares only 5 bytes.
|
||||
reqPost, _ := http.NewRequest(http.MethodPost, "/file.txt", http.NoBody)
|
||||
reqPost.Header.Set("X-Auth", signed)
|
||||
reqPost.Header.Set("Upload-Length", "5")
|
||||
recPost := httptest.NewRecorder()
|
||||
post.ServeHTTP(recPost, reqPost)
|
||||
if recPost.Code != http.StatusCreated {
|
||||
t.Fatalf("POST expected 201, got %d body=%q", recPost.Code, recPost.Body.String())
|
||||
}
|
||||
|
||||
// A body far larger than the declared length must be rejected, and nothing
|
||||
// beyond the declared length may reach disk.
|
||||
if rec := patchReq(strings.Repeat("A", 5000)); rec.Code != http.StatusRequestEntityTooLarge {
|
||||
t.Fatalf("over-length PATCH expected 413, got %d body=%q", rec.Code, rec.Body.String())
|
||||
}
|
||||
if fi, err := os.Stat(filepath.Join(userScope, "file.txt")); err != nil {
|
||||
t.Fatalf("stat file.txt: %v", err)
|
||||
} else if fi.Size() > 5 {
|
||||
t.Fatalf("wrote %d bytes despite Upload-Length 5", fi.Size())
|
||||
}
|
||||
|
||||
// A correctly-sized upload still completes.
|
||||
if rec := patchReq("hello"); rec.Code != http.StatusNoContent {
|
||||
t.Fatalf("valid PATCH expected 204, got %d body=%q", rec.Code, rec.Body.String())
|
||||
}
|
||||
if data, _ := os.ReadFile(filepath.Join(userScope, "file.txt")); string(data) != "hello" {
|
||||
t.Fatalf("expected file content \"hello\", got %q", string(data))
|
||||
}
|
||||
}
|
||||
+26
-10
@@ -3,7 +3,6 @@ package fbhttp
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/jellydator/ttlcache/v3"
|
||||
@@ -15,8 +14,11 @@ const uploadCacheTTL = 3 * time.Minute
|
||||
// Allows for different backends (e.g. in-memory or redis)
|
||||
// to support both single instance and multi replica deployments.
|
||||
type UploadCache interface {
|
||||
// Register stores an upload with its expected file size
|
||||
Register(filePath string, fileSize int64)
|
||||
// Register stores an upload with its expected file size. remove is called if
|
||||
// the upload expires before completion, to delete the partial file; it must
|
||||
// route through the uploading user's scoped filesystem so that eviction
|
||||
// cannot follow a symlink out of the user's scope.
|
||||
Register(filePath string, fileSize int64, remove func() error)
|
||||
|
||||
// Complete removes an upload from the cache
|
||||
Complete(filePath string)
|
||||
@@ -31,17 +33,31 @@ type UploadCache interface {
|
||||
Close()
|
||||
}
|
||||
|
||||
// memoryUploadEntry is the value stored for each active upload.
|
||||
type memoryUploadEntry struct {
|
||||
size int64
|
||||
remove func() error
|
||||
}
|
||||
|
||||
// memoryUploadCache is an upload cache for single replica deployments
|
||||
type memoryUploadCache struct {
|
||||
cache *ttlcache.Cache[string, int64]
|
||||
cache *ttlcache.Cache[string, memoryUploadEntry]
|
||||
}
|
||||
|
||||
func newMemoryUploadCache() *memoryUploadCache {
|
||||
cache := ttlcache.New[string, int64]()
|
||||
cache.OnEviction(func(_ context.Context, reason ttlcache.EvictionReason, item *ttlcache.Item[string, int64]) {
|
||||
cache := ttlcache.New[string, memoryUploadEntry]()
|
||||
cache.OnEviction(func(_ context.Context, reason ttlcache.EvictionReason, item *ttlcache.Item[string, memoryUploadEntry]) {
|
||||
if reason == ttlcache.EvictionReasonExpired {
|
||||
fmt.Printf("deleting incomplete upload file: \"%s\"\n", item.Key())
|
||||
os.Remove(item.Key())
|
||||
// Delete through the scoped removal callback rather than a raw
|
||||
// os.Remove on the cached path, so an ancestor directory swapped for
|
||||
// a symlink during the TTL window cannot redirect the delete outside
|
||||
// the user's scope.
|
||||
if remove := item.Value().remove; remove != nil {
|
||||
if err := remove(); err != nil {
|
||||
fmt.Printf("failed to delete incomplete upload file %q: %v\n", item.Key(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
go cache.Start()
|
||||
@@ -49,8 +65,8 @@ func newMemoryUploadCache() *memoryUploadCache {
|
||||
return &memoryUploadCache{cache: cache}
|
||||
}
|
||||
|
||||
func (c *memoryUploadCache) Register(filePath string, fileSize int64) {
|
||||
c.cache.Set(filePath, fileSize, uploadCacheTTL)
|
||||
func (c *memoryUploadCache) Register(filePath string, fileSize int64, remove func() error) {
|
||||
c.cache.Set(filePath, memoryUploadEntry{size: fileSize, remove: remove}, uploadCacheTTL)
|
||||
}
|
||||
|
||||
func (c *memoryUploadCache) Complete(filePath string) {
|
||||
@@ -62,7 +78,7 @@ func (c *memoryUploadCache) GetLength(filePath string) (int64, error) {
|
||||
if item == nil {
|
||||
return 0, fmt.Errorf("no active upload found for the given path")
|
||||
}
|
||||
return item.Value(), nil
|
||||
return item.Value().size, nil
|
||||
}
|
||||
|
||||
func (c *memoryUploadCache) Touch(filePath string) {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package fbhttp
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// On expiry the memory upload cache must delete an abandoned upload through the
|
||||
// registered scoped removal callback, not with a raw os.Remove on the cached
|
||||
// path. This test registers an entry keyed by a real file's path whose callback
|
||||
// does not delete the file; if the old raw os.Remove behaviour were still in
|
||||
// place the file (whose path is the key) would be removed.
|
||||
func TestMemoryUploadCacheEvictionUsesRemovalCallback(t *testing.T) {
|
||||
c := newMemoryUploadCache()
|
||||
t.Cleanup(c.Close)
|
||||
|
||||
f := filepath.Join(t.TempDir(), "partial.upload")
|
||||
if err := os.WriteFile(f, []byte("x"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
var once sync.Once
|
||||
// Deliberately do NOT delete the file here.
|
||||
c.cache.Set(f, memoryUploadEntry{size: 1, remove: func() error {
|
||||
once.Do(func() { close(done) })
|
||||
return nil
|
||||
}}, time.Millisecond)
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatal("eviction did not invoke the removal callback")
|
||||
}
|
||||
|
||||
if _, err := os.Stat(f); err != nil {
|
||||
t.Fatalf("file at the cache key was deleted, so eviction bypassed the callback (raw os.Remove?): %v", err)
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,9 @@ func (c *redisUploadCache) filePathKey(filePath string) string {
|
||||
return "filebrowser:upload:" + filePath
|
||||
}
|
||||
|
||||
func (c *redisUploadCache) Register(filePath string, fileSize int64) {
|
||||
// Register stores the upload length. The scoped removal callback is unused by
|
||||
// the redis backend, which does not delete partial files on eviction.
|
||||
func (c *redisUploadCache) Register(filePath string, fileSize int64, _ func() error) {
|
||||
err := c.client.Set(context.Background(), c.filePathKey(filePath), fileSize, uploadCacheTTL).Err()
|
||||
if err != nil {
|
||||
log.Printf("failed to register upload in redis cache: %v", err)
|
||||
|
||||
+48
-1
@@ -6,12 +6,56 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
gopath "path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
libErrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
imgErrors "github.com/filebrowser/filebrowser/v2/img"
|
||||
)
|
||||
|
||||
// slashClean canonicalizes a virtual path to the absolute, "/"-separated,
|
||||
// lexically cleaned form that both the rule checker and the scoped filesystem
|
||||
// expect.
|
||||
//
|
||||
// Paths reach us either verbatim from a request or built by the OS — afero.Walk
|
||||
// and filepath.Join use "\" on Windows. There the filesystem resolves "\" as a
|
||||
// separator while the rule checker treated it as an ordinary character, so
|
||||
// "/allow\..\Secret.txt" evaded a rule for "/Secret.txt" and still opened it.
|
||||
// Normalizing with the host's own separator makes both layers agree on which
|
||||
// file a path names, and is a no-op on POSIX, where "\" is a legal character in
|
||||
// a filename and must stay one.
|
||||
func slashClean(name string) string {
|
||||
return cleanSeparators(name, string(filepath.Separator))
|
||||
}
|
||||
|
||||
// canonicalizeRequestPath rewrites the request path to its canonical virtual
|
||||
// form, so that the filesystem operation, the hook, the stored share record and
|
||||
// the thumbnail cache key all use the same string the rule check approved.
|
||||
//
|
||||
// A trailing separator is preserved: handlers distinguish "/dir/" from "/dir"
|
||||
// to decide whether to create a directory, and gopath.Clean would drop it.
|
||||
func canonicalizeRequestPath(r *http.Request) {
|
||||
p := slashClean(r.URL.Path)
|
||||
trailing := strings.HasSuffix(r.URL.Path, "/") || strings.HasSuffix(r.URL.Path, string(filepath.Separator))
|
||||
if p != "/" && trailing {
|
||||
p += "/"
|
||||
}
|
||||
r.URL.Path = p
|
||||
}
|
||||
|
||||
// cleanSeparators is slashClean with the host separator passed in explicitly,
|
||||
// so the Windows behaviour can be exercised on any platform.
|
||||
func cleanSeparators(name, sep string) string {
|
||||
if sep != "/" {
|
||||
name = strings.ReplaceAll(name, sep, "/")
|
||||
}
|
||||
if name == "" || name[0] != '/' {
|
||||
name = "/" + name
|
||||
}
|
||||
return gopath.Clean(name)
|
||||
}
|
||||
|
||||
func renderJSON(w http.ResponseWriter, _ *http.Request, data interface{}) (int, error) {
|
||||
marsh, err := json.Marshal(data)
|
||||
|
||||
@@ -21,7 +65,10 @@ func renderJSON(w http.ResponseWriter, _ *http.Request, data interface{}) (int,
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
if _, err := w.Write(marsh); err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
// The status line is already on the wire, so there is no error status
|
||||
// left to send: a failed write here means the client hung up. Report it
|
||||
// for the log without asking the caller to write a second header.
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package fbhttp
|
||||
|
||||
import "testing"
|
||||
|
||||
// cleanSeparators takes the host separator explicitly so the Windows behaviour
|
||||
// can be asserted from any platform. See GHSA-fgm5-pw99-w2p7: on Windows a
|
||||
// backslash is a path separator the filesystem resolves but the rule checker
|
||||
// used to treat as an ordinary character, so "/allow\..\Secret.txt" evaded a
|
||||
// rule for "/Secret.txt" and still opened it.
|
||||
func TestCleanSeparators(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
in string
|
||||
sep string
|
||||
want string
|
||||
}{
|
||||
// Windows: a backslash is a separator and must be resolved before the
|
||||
// path is matched against a rule.
|
||||
{"windows traversal", `/allow\..\Secret.txt`, `\`, "/Secret.txt"},
|
||||
{"windows leading backslash", `\Secret.txt`, `\`, "/Secret.txt"},
|
||||
{"windows mixed separators", `/a/b\..\..\c`, `\`, "/c"},
|
||||
{"windows already canonical", "/Secret.txt", `\`, "/Secret.txt"},
|
||||
{"windows relative", `allow\..\Secret.txt`, `\`, "/Secret.txt"},
|
||||
{"windows empty", "", `\`, "/"},
|
||||
|
||||
// POSIX: a backslash is a legal filename character and must survive, or
|
||||
// files named with one become unreachable.
|
||||
{"posix backslash is a filename character", `/a\b.txt`, "/", `/a\b.txt`},
|
||||
{"posix traversal", "/allow/../Secret.txt", "/", "/Secret.txt"},
|
||||
{"posix relative", "Secret.txt", "/", "/Secret.txt"},
|
||||
{"posix multiple slashes", "//a///b", "/", "/a/b"},
|
||||
{"posix empty", "", "/", "/"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := cleanSeparators(tc.in, tc.sep); got != tc.want {
|
||||
t.Errorf("cleanSeparators(%q, %q) = %q; want %q", tc.in, tc.sep, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
"group:allNonMajor",
|
||||
"group:allDigest",
|
||||
":disableDependencyDashboard",
|
||||
":disableMajorUpdates",
|
||||
":semanticCommitTypeAll(chore)"
|
||||
],
|
||||
"postUpdateOptions": [
|
||||
"gomodUpdateImportPaths",
|
||||
"gomodTidy"
|
||||
],
|
||||
"schedule": "* * * * 0,6"
|
||||
}
|
||||
+16
-4
@@ -25,17 +25,29 @@ func MatchHidden(path string) bool {
|
||||
return path != "" && strings.HasPrefix(filepath.Base(path), ".")
|
||||
}
|
||||
|
||||
// Matches matches a path against a rule.
|
||||
func (r *Rule) Matches(path string) bool {
|
||||
// Matches matches a path against a rule. When fold is true the comparison is
|
||||
// case-insensitive: on a case-insensitive filesystem two paths differing only
|
||||
// in case name the same file, so a rule written for one spelling has to cover
|
||||
// the others or it can be trivially evaded.
|
||||
//
|
||||
// Regex rules are never folded. An admin-authored pattern means what it says,
|
||||
// and lowering its input would silently change it; use (?i) for those.
|
||||
func (r *Rule) Matches(path string, fold bool) bool {
|
||||
if r.Regex {
|
||||
return r.Regexp.MatchString(path)
|
||||
}
|
||||
|
||||
if path == r.Path {
|
||||
rulePath := r.Path
|
||||
if fold {
|
||||
path = strings.ToLower(path)
|
||||
rulePath = strings.ToLower(rulePath)
|
||||
}
|
||||
|
||||
if path == rulePath {
|
||||
return true
|
||||
}
|
||||
|
||||
prefix := r.Path
|
||||
prefix := rulePath
|
||||
if prefix != "/" && !strings.HasSuffix(prefix, "/") {
|
||||
prefix += "/"
|
||||
}
|
||||
|
||||
+49
-10
@@ -9,30 +9,69 @@ func TestRuleMatches(t *testing.T) {
|
||||
name string
|
||||
rulePath string
|
||||
testPath string
|
||||
fold bool
|
||||
want bool
|
||||
}{
|
||||
{"exact match", "/uploads", "/uploads", true},
|
||||
{"child path", "/uploads", "/uploads/file.txt", true},
|
||||
{"sibling prefix", "/uploads", "/uploads_backup/secret.txt", false},
|
||||
{"root rule", "/", "/anything", true},
|
||||
{"trailing slash rule", "/uploads/", "/uploads/file.txt", true},
|
||||
{"trailing slash no sibling", "/uploads/", "/uploads_backup/file.txt", false},
|
||||
{"nested child", "/data/shared", "/data/shared/docs/file.txt", true},
|
||||
{"nested sibling", "/data/shared", "/data/shared_private/file.txt", false},
|
||||
{"exact match", "/uploads", "/uploads", false, true},
|
||||
{"child path", "/uploads", "/uploads/file.txt", false, true},
|
||||
{"sibling prefix", "/uploads", "/uploads_backup/secret.txt", false, false},
|
||||
{"root rule", "/", "/anything", false, true},
|
||||
{"trailing slash rule", "/uploads/", "/uploads/file.txt", false, true},
|
||||
{"trailing slash no sibling", "/uploads/", "/uploads_backup/file.txt", false, false},
|
||||
{"nested child", "/data/shared", "/data/shared/docs/file.txt", false, true},
|
||||
{"nested sibling", "/data/shared", "/data/shared_private/file.txt", false, false},
|
||||
|
||||
// On a case-insensitive filesystem /Secret.txt and /secret.TXT name the
|
||||
// same file, so a rule for one must cover the other. See
|
||||
// GHSA-fgm5-pw99-w2p7.
|
||||
{"case variant not folded", "/Secret.txt", "/secret.TXT", false, false},
|
||||
{"case variant folded", "/Secret.txt", "/secret.TXT", true, true},
|
||||
{"case variant child folded", "/Private", "/private/notes.txt", true, true},
|
||||
{"exact match folded", "/uploads", "/uploads", true, true},
|
||||
// Folding must not widen a rule past its own path segment.
|
||||
{"sibling prefix folded", "/uploads", "/UPLOADS_backup/secret.txt", true, false},
|
||||
{"nested sibling folded", "/data/shared", "/data/SHARED_private/x", true, false},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
r := &Rule{Path: tc.rulePath}
|
||||
got := r.Matches(tc.testPath)
|
||||
got := r.Matches(tc.testPath, tc.fold)
|
||||
if got != tc.want {
|
||||
t.Errorf("Rule{Path: %q}.Matches(%q) = %v; want %v", tc.rulePath, tc.testPath, got, tc.want)
|
||||
t.Errorf("Rule{Path: %q}.Matches(%q, fold=%v) = %v; want %v",
|
||||
tc.rulePath, tc.testPath, tc.fold, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A regex rule is authored by an administrator and means exactly what it says,
|
||||
// so folding must not reach it: the admin opts in with (?i) instead.
|
||||
func TestRuleMatchesRegexIgnoresFold(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
raw string
|
||||
path string
|
||||
want bool
|
||||
}{
|
||||
{`^/Secret\.txt$`, "/Secret.txt", true},
|
||||
{`^/Secret\.txt$`, "/secret.TXT", false},
|
||||
{`(?i)^/Secret\.txt$`, "/secret.TXT", true},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
for _, fold := range []bool{false, true} {
|
||||
r := &Rule{Regex: true, Regexp: &Regexp{Raw: tc.raw}}
|
||||
if got := r.Matches(tc.path, fold); got != tc.want {
|
||||
t.Errorf("Rule{Regexp: %q}.Matches(%q, fold=%v) = %v; want %v",
|
||||
tc.raw, tc.path, fold, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatchHidden(t *testing.T) {
|
||||
cases := map[string]bool{
|
||||
"/": false,
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -39,6 +41,33 @@ func (s *Settings) MakeUserDir(username, userScope, serverRoot string) (string,
|
||||
return userScope, nil
|
||||
}
|
||||
|
||||
// CreateUserHome derives and creates the home directory for a user that is
|
||||
// being provisioned (via signup, proxy auth or hook auth) and sets user.Scope
|
||||
// to the resulting path. When CreateUserDir is enabled and the caller did not
|
||||
// supply an explicit scope, the scope is cleared so that MakeUserDir derives a
|
||||
// per-user home from the username instead of falling back to the default scope
|
||||
// (which normalizes to the server root, leaving every provisioned user sharing
|
||||
// it).
|
||||
//
|
||||
// It reports whether the scope was derived from the username. A derived scope
|
||||
// must be persisted with users.Storage.SaveProvisioned, which rejects a scope
|
||||
// already owned by another user so that distinct usernames cannot silently
|
||||
// share one home directory.
|
||||
func (s *Settings) CreateUserHome(user *users.User, serverRoot string, explicitScope bool) (derived bool, err error) {
|
||||
derived = s.CreateUserDir && !explicitScope
|
||||
if derived {
|
||||
user.Scope = ""
|
||||
}
|
||||
|
||||
userHome, err := s.MakeUserDir(user.Username, user.Scope, serverRoot)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
user.Scope = userHome
|
||||
|
||||
return derived, nil
|
||||
}
|
||||
|
||||
func cleanUsername(s string) string {
|
||||
// Remove any trailing space to avoid ending on -
|
||||
s = strings.Trim(s, " ")
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// A user provisioned with CreateUserDir must receive a per-user home directory
|
||||
// derived from its username, not the default scope which normalizes to the
|
||||
// server root.
|
||||
func TestCreateUserHomeDerivesPerUserScope(t *testing.T) {
|
||||
s := &Settings{CreateUserDir: true, UserHomeBasePath: "/users"}
|
||||
|
||||
user := &users.User{Username: "alice", Scope: "."}
|
||||
derived, err := s.CreateUserHome(user, t.TempDir(), false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if !derived {
|
||||
t.Error("expected the scope to be reported as derived")
|
||||
}
|
||||
if user.Scope != "/users/alice" {
|
||||
t.Errorf("expected derived scope /users/alice, got %q", user.Scope)
|
||||
}
|
||||
}
|
||||
|
||||
// A scope explicitly supplied by the caller (e.g. returned by an auth hook) must
|
||||
// be preserved instead of being replaced by a derived home directory, and must
|
||||
// not be reported as derived: it is legitimate for several users to share it.
|
||||
func TestCreateUserHomePreservesExplicitScope(t *testing.T) {
|
||||
s := &Settings{CreateUserDir: true, UserHomeBasePath: "/users"}
|
||||
|
||||
user := &users.User{Username: "alice", Scope: "/custom"}
|
||||
derived, err := s.CreateUserHome(user, t.TempDir(), true)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if derived {
|
||||
t.Error("an explicit scope must not be reported as derived")
|
||||
}
|
||||
if user.Scope != "/custom" {
|
||||
t.Errorf("explicit scope should be preserved, got %q", user.Scope)
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,11 @@ type Server struct {
|
||||
AuthHook string `json:"authHook"`
|
||||
TokenExpirationTime string `json:"tokenExpirationTime"`
|
||||
FollowExternalSymlinks bool `json:"followExternalSymlinks"`
|
||||
|
||||
// CaseInsensitiveFs is detected from Root at startup rather than
|
||||
// configured, and tells the rule checker to match paths case-insensitively.
|
||||
// It is never persisted.
|
||||
CaseInsensitiveFs bool `json:"-"`
|
||||
}
|
||||
|
||||
// Clean cleans any variables that might need cleaning.
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
|
||||
"github.com/asdine/storm/v3"
|
||||
"github.com/asdine/storm/v3/q"
|
||||
@@ -44,7 +45,11 @@ func (st usersBackend) GetBy(i interface{}) (user *users.User, err error) {
|
||||
|
||||
func (st usersBackend) GetByScope(scope string) (*users.User, error) {
|
||||
user := &users.User{}
|
||||
err := st.db.Select(q.Eq("Scope", scope)).First(user)
|
||||
// Match case-insensitively: on a case-insensitive filesystem two scopes
|
||||
// that differ only in case (e.g. /users/Alice and /users/alice) resolve to
|
||||
// the same home directory, so they must be treated as a collision.
|
||||
pattern := "(?i)^" + regexp.QuoteMeta(scope) + "$"
|
||||
err := st.db.Select(q.Re("Scope", pattern)).First(user)
|
||||
if err != nil {
|
||||
if errors.Is(err, storm.ErrNotFound) {
|
||||
return nil, fberrors.ErrNotExist
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package bolt
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/asdine/storm/v3"
|
||||
|
||||
fberrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
"github.com/filebrowser/filebrowser/v2/users"
|
||||
)
|
||||
|
||||
// GetByScope must match case-insensitively: on a case-insensitive filesystem
|
||||
// two scopes that differ only in case resolve to the same home directory, so
|
||||
// the provisioning collision check has to treat them as the same scope.
|
||||
func TestGetByScopeCaseInsensitive(t *testing.T) {
|
||||
db, err := storm.Open(filepath.Join(t.TempDir(), "db"))
|
||||
if err != nil {
|
||||
t.Fatalf("open db: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = db.Close() })
|
||||
|
||||
st, err := NewStorage(db)
|
||||
if err != nil {
|
||||
t.Fatalf("new storage: %v", err)
|
||||
}
|
||||
if err := st.Users.Save(&users.User{Username: "CaseVictim", Password: "pw", Scope: "/users/CaseVictim"}); err != nil {
|
||||
t.Fatalf("save: %v", err)
|
||||
}
|
||||
|
||||
for _, scope := range []string{"/users/CaseVictim", "/users/casevictim", "/USERS/CASEVICTIM"} {
|
||||
u, err := st.Users.GetByScope(scope)
|
||||
if err != nil {
|
||||
t.Errorf("GetByScope(%q) unexpected error: %v", scope, err)
|
||||
continue
|
||||
}
|
||||
if u.Username != "CaseVictim" {
|
||||
t.Errorf("GetByScope(%q) returned %q, want CaseVictim", scope, u.Username)
|
||||
}
|
||||
}
|
||||
|
||||
// A genuinely different scope must still miss (and the regex-escaped query
|
||||
// must not match a superstring).
|
||||
for _, scope := range []string{"/users/other", "/users/CaseVictimX"} {
|
||||
if _, err := st.Users.GetByScope(scope); !errors.Is(err, fberrors.ErrNotExist) {
|
||||
t.Errorf("GetByScope(%q) expected ErrNotExist, got %v", scope, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -25,6 +26,7 @@ type Store interface {
|
||||
Gets(baseScope string, followExternalSymlinks bool) ([]*User, error)
|
||||
Update(user *User, fields ...string) error
|
||||
Save(user *User) error
|
||||
SaveProvisioned(user *User, derivedScope bool) error
|
||||
Delete(id interface{}) error
|
||||
LastUpdate(id uint) int64
|
||||
}
|
||||
@@ -34,6 +36,10 @@ type Storage struct {
|
||||
back StorageBackend
|
||||
updated map[uint]int64
|
||||
mux sync.RWMutex
|
||||
|
||||
// provision serializes the scope-collision check and the save of newly
|
||||
// provisioned users, which must not interleave. See SaveProvisioned.
|
||||
provision sync.Mutex
|
||||
}
|
||||
|
||||
// NewStorage creates a users storage from a backend.
|
||||
@@ -108,6 +114,32 @@ func (s *Storage) Save(user *User) error {
|
||||
return s.back.Save(user)
|
||||
}
|
||||
|
||||
// SaveProvisioned saves a user that is being provisioned (via signup, proxy
|
||||
// auth or hook auth). When its scope was derived from the username, it first
|
||||
// rejects the save if another user already owns that scope, so that distinct
|
||||
// usernames cannot silently share one home directory.
|
||||
//
|
||||
// The check and the save are held under a single lock. Performing them as two
|
||||
// independent operations lets two concurrent provisioning requests both observe
|
||||
// a free scope and both save, leaving two users sharing one home directory.
|
||||
func (s *Storage) SaveProvisioned(user *User, derivedScope bool) error {
|
||||
if !derivedScope {
|
||||
return s.Save(user)
|
||||
}
|
||||
|
||||
s.provision.Lock()
|
||||
defer s.provision.Unlock()
|
||||
|
||||
switch _, err := s.back.GetByScope(user.Scope); {
|
||||
case err == nil:
|
||||
return fberrors.ErrExist
|
||||
case !errors.Is(err, fberrors.ErrNotExist):
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Save(user)
|
||||
}
|
||||
|
||||
// Delete allows you to delete a user by its name or username. The provided
|
||||
// id must be a string for username lookup or a uint for id lookup. If id
|
||||
// is neither, a ErrInvalidDataType will be returned.
|
||||
|
||||
@@ -1,4 +1,117 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
fberrors "github.com/filebrowser/filebrowser/v2/errors"
|
||||
)
|
||||
|
||||
// Interface is implemented by storage
|
||||
var _ Store = &Storage{}
|
||||
|
||||
// slowBackend is a minimal StorageBackend whose scope lookup is deliberately
|
||||
// slow, so that an unsynchronized check-then-save reliably interleaves.
|
||||
type slowBackend struct {
|
||||
mu sync.Mutex
|
||||
users []*User
|
||||
delay time.Duration
|
||||
}
|
||||
|
||||
func (b *slowBackend) GetByScope(scope string) (*User, error) {
|
||||
time.Sleep(b.delay)
|
||||
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
for _, u := range b.users {
|
||||
if strings.EqualFold(u.Scope, scope) {
|
||||
return u, nil
|
||||
}
|
||||
}
|
||||
return nil, fberrors.ErrNotExist
|
||||
}
|
||||
|
||||
func (b *slowBackend) Save(u *User) error {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
b.users = append(b.users, u)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *slowBackend) GetBy(interface{}) (*User, error) { return nil, fberrors.ErrNotExist }
|
||||
func (b *slowBackend) Gets() ([]*User, error) { return b.users, nil }
|
||||
func (b *slowBackend) Update(*User, ...string) error { return nil }
|
||||
func (b *slowBackend) DeleteByID(uint) error { return nil }
|
||||
func (b *slowBackend) DeleteByUsername(string) error { return nil }
|
||||
func (b *slowBackend) CountAdmins() (int, error) { return 0, nil }
|
||||
|
||||
// Two usernames that normalize to the same home directory must not both be
|
||||
// provisioned, even when their requests are handled concurrently: checking the
|
||||
// scope and saving the user has to be a single atomic step.
|
||||
func TestSaveProvisionedRejectsConcurrentScopeCollision(t *testing.T) {
|
||||
back := &slowBackend{delay: 50 * time.Millisecond}
|
||||
store := NewStorage(back)
|
||||
|
||||
errs := make([]error, 2)
|
||||
var wg, ready sync.WaitGroup
|
||||
ready.Add(2)
|
||||
for i, username := range []string{"teamone-x", "teamone/x"} {
|
||||
wg.Add(1)
|
||||
go func(i int, username string) {
|
||||
defer wg.Done()
|
||||
// Only start once both goroutines are actually running, so that an
|
||||
// unsynchronized implementation is guaranteed to interleave rather
|
||||
// than to pass by scheduling luck.
|
||||
ready.Done()
|
||||
ready.Wait()
|
||||
errs[i] = store.SaveProvisioned(&User{
|
||||
Username: username,
|
||||
Password: "pw",
|
||||
Scope: "/users/teamone-x",
|
||||
}, true)
|
||||
}(i, username)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
saved := 0
|
||||
for _, err := range errs {
|
||||
switch {
|
||||
case err == nil:
|
||||
saved++
|
||||
case !errors.Is(err, fberrors.ErrExist):
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if saved != 1 {
|
||||
t.Fatalf("VULNERABLE: %d users provisioned into /users/teamone-x, want 1", saved)
|
||||
}
|
||||
if len(back.users) != 1 {
|
||||
t.Fatalf("%d users stored, want 1", len(back.users))
|
||||
}
|
||||
}
|
||||
|
||||
// A scope that was not derived from the username (explicitly configured by an
|
||||
// administrator or returned by an auth hook) may legitimately be shared, so it
|
||||
// must not be subject to the collision check.
|
||||
func TestSaveProvisionedAllowsSharedExplicitScope(t *testing.T) {
|
||||
back := &slowBackend{}
|
||||
store := NewStorage(back)
|
||||
|
||||
for _, username := range []string{"alice", "bob"} {
|
||||
if err := store.SaveProvisioned(&User{
|
||||
Username: username,
|
||||
Password: "pw",
|
||||
Scope: "/shared/team",
|
||||
}, false); err != nil {
|
||||
t.Fatalf("saving %q with an explicit shared scope: %v", username, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(back.users) != 2 {
|
||||
t.Fatalf("%d users stored, want 2", len(back.users))
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,10 @@ The Hook Authentication method in FileBrowser allows developers to delegate user
|
||||
|
||||
The hook’s output controls user permissions, scope, locale, and other attributes, making it a powerful and extensible authentication mechanism.
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> The submitted username and password are attacker-controlled and are handed to your hook command as the `USERNAME` and `PASSWORD` environment variables. File Browser runs the command directly, without a shell, so the values themselves are inert. However, your script must treat them as untrusted: always quote them (`"$USERNAME"`, `"$PASSWORD"`) and never pass them unquoted to a shell, `eval`, `bash -c`, command substitution, or backticks. A hook script that shell-evaluates these values turns any login request into remote code execution.
|
||||
|
||||
For example, the following code delegates filebrowser authentication to a PowerShell script on Windows. You can configure any command (for example, a script in Python, Node.js, etc.).
|
||||
|
||||
```sh
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> This project is on **maintenance-only** mode. For more information, read the information on [GitHub](https://github.com/filebrowser/filebrowser#project-status).
|
||||
> **File Browser is being archived on 2026-09-01.** There will be no further releases and no security fixes. Existing releases and Docker images stay online. For the project status, the known unfixed security issues, and hardening guidance, read the [README on GitHub](https://github.com/filebrowser/filebrowser#project-status).
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ docker run \
|
||||
|
||||
Where `filebrowser_data`, `filebrowser_database` and `filebrowser_config` are Docker [volumes](https://docs.docker.com/engine/storage/volumes/), where the data, database and configuration will be stored, respectively. The default configuration and database will be automatically initialized.
|
||||
|
||||
The default user that runs File Browser inside the container has PID 1000 and GID 1000. If, for one reason or another, you want to run the Docker container with a different user, please consult Docker's [user documentation](https://docs.docker.com/engine/containers/run/#user).
|
||||
The default user that runs File Browser inside the container has UID 1000 and GID 1000. If, for one reason or another, you want to run the Docker container with a different user, please consult Docker's [user documentation](https://docs.docker.com/engine/containers/run/#user).
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user