From da641ad266775f517f9603135eb56bb53db309d8 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:33:19 +0800 Subject: [PATCH 1/5] ci: pass only the Discord secret to called workflows and drop checkout credentials - Each called workflow declares only DISCORD_WEBHOOK_URL, so it is passed by name instead of secrets: inherit forwarding every repository secret. - Checkouts set persist-credentials: false; no job pushes or fetches after checking out. - actionlint's installer is told 1.7.12; it defaults to 1.7.11. - Workflow comments are cut to two lines, and repo-events.yml says it posts only manually published releases. --- .github/workflows/codeql.yml | 2 ++ .github/workflows/docker-publish.yml | 16 +++++++++++----- .github/workflows/lint.yml | 2 ++ .github/workflows/release-please.yml | 12 +++++------- .github/workflows/repo-events.yml | 8 ++++---- .github/workflows/validate-workflows.yml | 4 +++- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f3374b5..531d98f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -25,6 +25,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Initialize CodeQL uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 6662ef7..286aeab 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,6 +29,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + persist-credentials: false fetch-depth: 0 - id: count run: | @@ -37,15 +38,16 @@ jobs: echo "date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" } >> "$GITHUB_OUTPUT" - # Gate the image build/publish on lint + smoke tests so a broken push to - # main can't publish :latest. (CodeQL runs in its own workflow; enforce it - # as a required status check via branch protection.) + # Lint and tests gate the build, so a broken push to main can't publish :latest. + # CodeQL runs in codeql.yml; branch protection is what makes it required. lint: permissions: contents: read runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: @@ -63,6 +65,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: @@ -92,7 +96,8 @@ jobs: VCS_REF=${{ github.sha }} VERSION=${{ github.ref_name }} BUILD_NUMBER=${{ needs.build-number.outputs.number }} - secrets: inherit + secrets: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} notify-failure: needs: build @@ -105,4 +110,5 @@ jobs: status: failure title: "❌ Docker build failed: ${{ github.ref_name }}" commit_sha: ${{ github.sha }} - secrets: inherit + secrets: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 02dccae..a8bd296 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,6 +19,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 605c868..7afb2fb 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -23,12 +23,8 @@ jobs: secrets: DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - # docker-publish.yml's tags:['v*'] trigger never fires: release-please pushes - # its tag with GITHUB_TOKEN, and GitHub runs no workflow for events raised by - # that token — so no release has ever produced a version-tagged image. Build it - # here instead, where release_created and the version are already known. The - # push-triggered build cannot do it: it starts in the same second as this - # workflow, before the tag exists. + # The version-tagged image is built here: a tag pushed with GITHUB_TOKEN starts + # no workflow, so docker-publish.yml's tag trigger never fires for a release. version-tag-meta: needs: release if: needs.release.outputs.release_created == 'true' @@ -39,6 +35,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + persist-credentials: false fetch-depth: 0 - id: m run: | @@ -63,4 +60,5 @@ jobs: VCS_REF=${{ github.sha }} VERSION=${{ needs.release.outputs.tag_name }} BUILD_NUMBER=${{ needs.version-tag-meta.outputs.build_number }} - secrets: inherit + secrets: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} diff --git a/.github/workflows/repo-events.yml b/.github/workflows/repo-events.yml index b70c0d2..317970e 100644 --- a/.github/workflows/repo-events.yml +++ b/.github/workflows/repo-events.yml @@ -1,6 +1,5 @@ -# Drop into .github/workflows/repo-events.yml of ANY repo. -# Fires Discord for: issue open/close, PR open/close/merge, release publish, discussion. -# Workflow-failure notifications are handled inline by the failing caller workflow (see caller-docker.yml). +# Discord posts for issues, PRs, discussions and manually published releases. +# release-please's releases post from release-please.yml: GITHUB_TOKEN events start no workflow. name: Repo events @@ -20,4 +19,5 @@ permissions: jobs: notify: uses: chodeus/chodeus-ops/.github/workflows/repo-events.yml@6e15484f5348c9862408046b962fa7083ceeffeb # main - secrets: inherit + secrets: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} diff --git a/.github/workflows/validate-workflows.yml b/.github/workflows/validate-workflows.yml index 4aba73e..bdfe553 100644 --- a/.github/workflows/validate-workflows.yml +++ b/.github/workflows/validate-workflows.yml @@ -23,12 +23,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Install actionlint id: install shell: bash run: | - bash <(curl -sSfL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.12/scripts/download-actionlint.bash) + bash <(curl -sSfL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.12/scripts/download-actionlint.bash) 1.7.12 echo "exe=$PWD/actionlint" >> "$GITHUB_OUTPUT" - name: Run actionlint From 9d0e1eeaaad5980c185d608c942850b627d9103f Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:33:19 +0800 Subject: [PATCH 2/5] docs: correct the README, compose and security notes - run_interval 0 scans once and then idles until rescan; it doesn't exit. - Only setup, login, logout and the login status skip the session check. - The WebUI uses no third-party Python packages; "no supply chain risk" overclaimed. - The manual delete option ran rm on corrupt.txt paths from the host, but they are container paths; it now points at the validated WebUI delete. - compose.yaml: the timezone comment no longer says TZ is unneeded while the example sets it, the WebUI note no longer says a login is required, and the comment blocks are cut to two lines. - SECURITY.md's second channel is a public issue, not email. - .coderabbit.yaml: typo fixed, and rules for named secrets and checkouts. --- .coderabbit.yaml | 6 ++++-- .github/SECURITY.md | 2 +- README.md | 13 +++++-------- compose.yaml | 32 +++++++++----------------------- 4 files changed, 19 insertions(+), 34 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 2f58a76..9ad4f7d 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -1,7 +1,7 @@ # .coderabbit.yaml — BeatsCheck (audio integrity / ID3 analysis; raw-Python HTTP server + Docker) language: "en-US" reviews: - # assertive: chill passed a diff clean that assertive flagged with two Major findings (2026-09-03); the "**" rule keeps style nits out + # assertive, not chill: chill misses Major findings here. The "**" rule keeps style nits out. profile: "assertive" request_changes_workflow: false pre_merge_checks: @@ -39,7 +39,7 @@ reviews: treat the sentinel as DENY, never as "no account / allow setup"). _check_auth() and _validate_session() must return False on any missing/ expired/malformed token or lookup failure — never fall through to the - authorated path. The ONLY session-free pass is _AUTH_OFF, which + authorized path. The ONLY session-free pass is _AUTH_OFF, which _load_auth() returns solely for the exact {"login": "off"} content; any other unexpected content must stay _AUTH_UNREADABLE. Turning the login off (/api/auth/disable) needs a session, the current password, @@ -217,6 +217,8 @@ reviews: - Enumerate allowed states positively (== 'success' || == 'skipped'), never by negation — a third state slips through `!= 'failure'`. - Pin third-party actions by commit SHA, not a mutable tag. + - Pass a called workflow only the secrets it declares, by name; never + `secrets: inherit`. Checkouts set persist-credentials: false. - Never echo a token, and never interpolate untrusted input (PR title, branch name, issue body) straight into a `run:` block — pass it via env. - A paths filter added or renamed must stay in step with what the job diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 5ccf590..db53cd9 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -12,7 +12,7 @@ If you discover a security vulnerability, please report it responsibly: 1. **GitHub Security Advisory** (preferred): [Create a private advisory](https://github.com/chodeus/BeatsCheck/security/advisories/new) -2. **Email**: Open a GitHub issue marked `[SECURITY]` if it is not sensitive +2. **Public issue**: for a problem that can't be exploited, open a GitHub issue marked `[SECURITY]` Please do **not** open a public issue for security vulnerabilities that could be exploited. diff --git a/README.md b/README.md index 814a04e..dc57771 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ On first run, BeatsCheck creates `/config/beatscheck.conf` with all options and | `output_dir` | `/corrupted` | Quarantine destination for move mode. Must match a mounted volume | | `mode` | `setup` | `setup` (idle), `report`, `delete`, or `move`. Can be changed at runtime via `rescan` | | `workers` | `4` | Parallel ffmpeg decode workers. 2 = conservative, 4 = balanced, 8+ = fast | -| `run_interval` | `0` | Hours between scans. `0` = run once and exit. `168` = weekly. `24` = daily | +| `run_interval` | `0` | Hours between scans. `0` = scan once, then stay idle until `rescan`. `168` = weekly. `24` = daily | | `delete_after` | `0` | Days before corrupt files are auto-deleted. `0` = never (manual only). `7` = 7 day review window | | `max_auto_delete` | `50` | Safety threshold — abort auto-delete if more than this many files would be removed. `0` = no limit | | `min_file_age` | `30` | Skip files modified within this many minutes. Prevents flagging active downloads | @@ -219,7 +219,7 @@ On the Configuration page, **Access → Turn off login** asks for your current p ### WebUI Security -- **Authentication required** — all API endpoints require a valid session (PBKDF2-SHA256 hashed passwords, HttpOnly session cookies), unless you chose **No login** or turned the login off. A damaged `webui_auth.json` keeps the WebUI locked, never open +- **Authentication required** — every API endpoint except setup, login, logout and the login status needs a valid session (PBKDF2-SHA256 hashed passwords, HttpOnly session cookies), unless you chose **No login** or turned the login off. A damaged `webui_auth.json` keeps the WebUI locked, never open - **Login lockout** — 5 attempts per client within 15 minutes, then a 5-minute lockout. Behind a reverse proxy, set `WEBUI_TRUSTED_PROXIES` so each client gets its own lockout - **Setup wizard** — on first access, create credentials (stored hashed in `/config/webui_auth.json`) or choose **No login** - **Cross-site POSTs refused** — the API accepts only JSON POSTs, which a browser sends from another site only after a CORS check the WebUI never passes. This holds with the login off too @@ -228,7 +228,7 @@ On the Configuration page, **Access → Turn off login** asks for your current p - **Delete validation** — files must be in `corrupt.txt` and inside the music directory; symlinks rejected - **Path traversal protection** — static file serving validates all paths against the static directory - **API key masking** — Lidarr API key shown as `********` in the UI -- **No external dependencies** — built on Python stdlib only (no supply chain risk) +- **No third-party Python packages** — the WebUI uses only the standard library **Important:** The WebUI is designed for trusted LAN / Docker bridge networks. For remote access, use a reverse proxy with HTTPS and authentication (Nginx, Caddy, Traefik). Do not expose the WebUI port directly to the internet. @@ -329,12 +329,9 @@ Change the music mount to `rw`, then from the Unraid **terminal**: docker exec -it BeatsCheck delete ``` -**Option 3: Manual delete from corrupt.txt** +**Option 3: From the WebUI** -```bash -cat /mnt/user/appdata/beatscheck/corrupt.txt -while IFS= read -r f; do rm -v "$f"; done < /mnt/user/appdata/beatscheck/corrupt.txt -``` +On **Corrupt Files**, select files or albums and click **Delete**. Each path is checked against `corrupt.txt` and the music directory before anything is removed. Don't feed `corrupt.txt` to `rm` on the host: it lists paths as the container sees them (`/data/...`), not host paths. ### Unraid Notifications (Optional) diff --git a/compose.yaml b/compose.yaml index 957fc00..d8b9d45 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,12 +1,5 @@ -### BeatsCheck compose.yaml Example -### https://github.com/chodeus/BeatsCheck -### -### Usage: -### docker compose up -d # Start in background -### docker compose logs -f # Follow logs -### docker exec -it beatscheck delete # Interactive delete -### docker exec beatscheck rescan # Trigger rescan -### +### BeatsCheck compose.yaml example: https://github.com/chodeus/BeatsCheck +### docker compose up -d, then `docker exec beatscheck rescan` or `docker exec -it beatscheck delete`. services: beatscheck: image: ghcr.io/chodeus/beatscheck:latest @@ -18,7 +11,7 @@ services: - /mnt/user/data:/data:ro ## Persistent config: logs, corrupt.txt, tracking data - /path/to/config:/config - ## Auto-detect host timezone (no TZ env var needed if mounted) + ## Host timezone. A TZ variable below overrides it, so keep one or the other. - /etc/localtime:/etc/localtime:ro environment: ## Container user/group IDs and timezone @@ -31,20 +24,14 @@ services: # - WEBUI_TRUSTED_PROXIES=172.18.0.10 ## All other settings (mode, workers, Lidarr, etc.) are configured in ## /config/beatscheck.conf — auto-created on first run. - ## WebUI: uncomment to enable the web interface. - ## Also set webui = true in /config/beatscheck.conf - ## On first access you'll create login credentials via a setup wizard. - ## To reset credentials: docker exec beatscheck reset-webui-password - ## WARNING: Do not expose the WebUI port directly to the internet. - ## Use a reverse proxy with HTTPS (Nginx, Caddy, Traefik) for remote access. + ## WebUI: uncomment, and set webui = true in /config/beatscheck.conf. + ## Never expose the port to the internet; use an HTTPS reverse proxy for remote access. # ports: # - "8484:8484" ## Optional: limit CPU usage to avoid impacting other services # cpus: 2 - ## Optional hardening: drop every capability, add back only the five - ## the entrypoint actually needs (PUID/PGID remap + chown + su-exec), - ## and block setuid escalation. Even during the brief root window at - ## startup, the container has no NET_RAW, SYS_ADMIN, or mount powers. + ## Optional hardening: only the five capabilities the entrypoint needs + ## (PUID/PGID remap, chown, su-exec), and no setuid escalation. # cap_drop: # - ALL # cap_add: @@ -55,7 +42,6 @@ services: # - DAC_OVERRIDE # security_opt: # - no-new-privileges:true - ## Fully rootless alternative: replace PUID/PGID env with `user:` and - ## pre-chown the host config dir (sudo chown -R 99:100 ./config). - ## The entrypoint detects non-root invocation and skips the chown/su-exec. + ## Fully rootless: replace PUID/PGID with `user:` and pre-chown the config dir + ## (sudo chown -R 99:100 ./config); the entrypoint then skips chown and su-exec. # user: "99:100" From dcaffa83f81a01cc2824c1b93671cf2c38938967 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 10 Oct 2026 02:59:34 +0800 Subject: [PATCH 3/5] docs: state the WebUI delete rules and fix two compose instructions - README Option 3: an album needs a flagged file in its folder before the whole folder goes, and files Lidarr doesn't track need the rw mount. - compose.yaml: remote access means an HTTPS proxy with authentication, and the rootless chown targets the directory mounted at /config. --- README.md | 2 +- compose.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc57771..532e0a5 100644 --- a/README.md +++ b/README.md @@ -331,7 +331,7 @@ docker exec -it BeatsCheck delete **Option 3: From the WebUI** -On **Corrupt Files**, select files or albums and click **Delete**. Each path is checked against `corrupt.txt` and the music directory before anything is removed. Don't feed `corrupt.txt` to `rm` on the host: it lists paths as the container sees them (`/data/...`), not host paths. +On **Corrupt Files**, select files or albums and click **Delete**. Each file is checked against `corrupt.txt` and the music directory. For an album, at least one flagged file must be in that album's folder before the whole folder is removed. Files Lidarr tracks are deleted through Lidarr; BeatsCheck removes the rest itself, so mount the music folder `rw` as in Option 2. Don't feed `corrupt.txt` to `rm` on the host: it lists paths as the container sees them (`/data/...`), not host paths. ### Unraid Notifications (Optional) diff --git a/compose.yaml b/compose.yaml index d8b9d45..b3e99b3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -25,7 +25,7 @@ services: ## All other settings (mode, workers, Lidarr, etc.) are configured in ## /config/beatscheck.conf — auto-created on first run. ## WebUI: uncomment, and set webui = true in /config/beatscheck.conf. - ## Never expose the port to the internet; use an HTTPS reverse proxy for remote access. + ## Never expose the port to the internet; for remote access, use an HTTPS reverse proxy with authentication. # ports: # - "8484:8484" ## Optional: limit CPU usage to avoid impacting other services @@ -43,5 +43,5 @@ services: # security_opt: # - no-new-privileges:true ## Fully rootless: replace PUID/PGID with `user:` and pre-chown the config dir - ## (sudo chown -R 99:100 ./config); the entrypoint then skips chown and su-exec. + ## (sudo chown -R 99:100 /path/to/config); the entrypoint then skips chown and su-exec. # user: "99:100" From 565c5e081382f96ac75812c6909482992c57f59e Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 10 Oct 2026 04:05:31 +0800 Subject: [PATCH 4/5] chore: word the review-profile comment as a warning --- .coderabbit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 9ad4f7d..8039fa9 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -1,7 +1,7 @@ # .coderabbit.yaml — BeatsCheck (audio integrity / ID3 analysis; raw-Python HTTP server + Docker) language: "en-US" reviews: - # assertive, not chill: chill misses Major findings here. The "**" rule keeps style nits out. + # Keep assertive: chill misses Major findings in this repo. The "**" rule filters style nits. profile: "assertive" request_changes_workflow: false pre_merge_checks: From 5637073afb82b66b013c5c739413840e6b0a2cc9 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 10 Oct 2026 06:06:46 +0800 Subject: [PATCH 5/5] fix(entrypoint): let a mounted /etc/localtime set the timezone The entrypoint left a bind-mounted /etc/localtime alone but kept TZ, which the image sets to UTC, and libc reads TZ ahead of /etc/localtime. So the documented host-timezone mount never took effect: BeatsCheck ran in UTC, or in whatever TZ said. TZ is now unset when the mount is present; without it, TZ applies as before. --- .coderabbit.yaml | 2 ++ compose.yaml | 2 +- scripts/entrypoint.sh | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 8039fa9..7b652c2 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -171,6 +171,8 @@ reviews: spaces. - Preserve correct PUID/PGID drop (default 99:100) and UMASK; do not run the delete/scan Python as root. + - entrypoint.sh unsets TZ when /etc/localtime is a mounted file: libc + reads TZ (the image sets UTC) first, so keeping it ignores the mount. - No secrets echoed or baked into the script or its logs. - rescan.sh accepts only report/move modes and writes .rescan as PUID via mkstemp + os.replace, so a symlink there is replaced, never diff --git a/compose.yaml b/compose.yaml index b3e99b3..dfc7b44 100644 --- a/compose.yaml +++ b/compose.yaml @@ -11,7 +11,7 @@ services: - /mnt/user/data:/data:ro ## Persistent config: logs, corrupt.txt, tracking data - /path/to/config:/config - ## Host timezone. A TZ variable below overrides it, so keep one or the other. + ## Host timezone. While this is mounted it wins; TZ below applies only without it. - /etc/localtime:/etc/localtime:ro environment: ## Container user/group IDs and timezone diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 2e12612..ed36f37 100644 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -9,7 +9,8 @@ TZ=${TZ:-UTC} # Timezone: if /etc/localtime is bind-mounted from host, use it as-is. # Otherwise set it from the TZ env var. if [ -f "/etc/localtime" ] && [ ! -L "/etc/localtime" ]; then - : # bind-mounted regular file from host + # libc reads TZ (the image defaults it to UTC) ahead of /etc/localtime. + unset TZ elif [ -n "$TZ" ] && [ -f "/usr/share/zoneinfo/$TZ" ]; then # Rootless cannot write /etc/localtime; TZ in the environment still applies. ln -sf "/usr/share/zoneinfo/$TZ" /etc/localtime 2>/dev/null || true