diff --git a/aldc b/aldc index 3921be0..67f6533 100755 --- a/aldc +++ b/aldc @@ -1,8 +1,27 @@ #! /bin/bash # aldc: Add LaTeX DevContainer -REPOSITORY_NAME='latex-environment' -REPOSITORY_OWNER='smkwlab' +# Source of the LaTeX devcontainer. Defaults to smkwlab/latex-environment; +# other orgs can point aldc at their own fork via these env vars. +REPOSITORY_NAME="${ALDC_REPOSITORY_NAME:-latex-environment}" +REPOSITORY_OWNER="${ALDC_REPOSITORY_OWNER:-smkwlab}" +# REPOSITORY_OWNER goes into the download URL; REPOSITORY_NAME is additionally +# used as the extracted directory in `cd` / `rm -rf` below. Validate both: +# the GitHub login / repository character set, no leading dash (a leading `-` +# would be parsed as an option by cd/rm even when quoted), and — for the name — +# no dot-only / `..` traversal value. +case "$REPOSITORY_OWNER" in + ''|-*|*[!A-Za-z0-9-]*) + echo "Error: invalid ALDC_REPOSITORY_OWNER: ${REPOSITORY_OWNER}" >&2 + exit 1 + ;; +esac +case "$REPOSITORY_NAME" in + ''|.|..|-*|*[!A-Za-z0-9._-]*) + echo "Error: invalid ALDC_REPOSITORY_NAME: ${REPOSITORY_NAME}" >&2 + exit 1 + ;; +esac REPOSITORY_URL="https://github.com/${REPOSITORY_OWNER}/${REPOSITORY_NAME}" BRANCH='release' ZIP_NAME="${REPOSITORY_NAME}-${BRANCH}.zip" @@ -41,7 +60,9 @@ while [ $# -gt 0 ]; do echo " --help, -h Show this help message" echo "" echo "Environment Variables:" - echo " ALDC_QUIET=1 Enable quiet mode" + echo " ALDC_QUIET=1 Enable quiet mode" + echo " ALDC_REPOSITORY_OWNER Source org/user (default: smkwlab)" + echo " ALDC_REPOSITORY_NAME Source repo (default: latex-environment)" exit 0 ;; *) diff --git a/docs/CLAUDE-DEVELOPMENT.md b/docs/CLAUDE-DEVELOPMENT.md index 74ebaff..4be2614 100644 --- a/docs/CLAUDE-DEVELOPMENT.md +++ b/docs/CLAUDE-DEVELOPMENT.md @@ -10,10 +10,24 @@ This document covers the development workflow, architecture, and technical detai - **Git Integration**: Automatic repository initialization and commit handling ### Environment Source -- **Source Repository**: smkwlab/latex-environment +- **Source Repository**: smkwlab/latex-environment (default) - **Branch**: release (stable releases) - **Installation Method**: Downloads ZIP, extracts, and integrates files +The source is overridable for other-org deployments (defaults preserve +smkwlab behavior): + +| Variable | Default | Purpose | +|----------|---------|---------| +| `ALDC_REPOSITORY_OWNER` | `smkwlab` | Org/user hosting the latex-environment fork. | +| `ALDC_REPOSITORY_NAME` | `latex-environment` | Repository name to download. | + +`ALDC_REPOSITORY_OWNER` is used only in the download URL; `ALDC_REPOSITORY_NAME` +is additionally used as the extracted directory in `cd` / `rm -rf`. Both are +validated (GitHub character set, no leading dash, and — for the name — no `.` +or `..` traversal) before use. The release branch name is fixed to `release` +by convention. + ## Installation Process ### Process Flow @@ -65,7 +79,7 @@ texlive-ja-textlint (Docker base image) ## Configuration Details ### Default Settings -- **Repository**: smkwlab/latex-environment +- **Repository**: smkwlab/latex-environment (override with `ALDC_REPOSITORY_OWNER` / `ALDC_REPOSITORY_NAME`) - **Branch**: release (for stability) - **Installation Location**: Current working directory - **Backup Strategy**: Conflicts renamed with `-aldc` suffix @@ -99,7 +113,9 @@ texlive-ja-textlint (Docker base image) ## Security Considerations -- Downloads from official smkwlab repository only +- Downloads from smkwlab/latex-environment by default; the source is + overridable via `ALDC_REPOSITORY_OWNER`/`ALDC_REPOSITORY_NAME`, which are + character-validated (no path separators, leading dash, or `.`/`..`) - Uses HTTPS for all network communications - No external dependencies beyond standard unix tools - Repository verification through GitHub's infrastructure