mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 06:52:47 +00:00
🪤 chore: Prevent CI Path Argument Injection (#13284)
Some checks are pending
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
GitNexus Index / index (push) Waiting to run
GitNexus Index / post-index (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
Some checks are pending
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
GitNexus Index / index (push) Waiting to run
GitNexus Index / post-index (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
This commit is contained in:
parent
9799f7e698
commit
a7c18f54f7
1 changed files with 14 additions and 8 deletions
22
.github/workflows/eslint-ci.yml
vendored
22
.github/workflows/eslint-ci.yml
vendored
|
|
@ -44,14 +44,17 @@ jobs:
|
|||
echo "Base commit SHA: $BASE_SHA"
|
||||
|
||||
# Get changed files (only JS/TS files in api/, client/, or packages/)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true)
|
||||
mapfile -d '' -t CHANGED_FILES < <(
|
||||
git diff -z --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD |
|
||||
grep -zE '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true
|
||||
)
|
||||
|
||||
# Debug output
|
||||
echo "Changed files:"
|
||||
echo "$CHANGED_FILES"
|
||||
printf '%s\n' "${CHANGED_FILES[@]}"
|
||||
|
||||
# Ensure there are files to lint before running ESLint
|
||||
if [[ -z "$CHANGED_FILES" ]]; then
|
||||
if [[ ${#CHANGED_FILES[@]} -eq 0 ]]; then
|
||||
echo "No matching files changed. Skipping ESLint."
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -60,7 +63,7 @@ jobs:
|
|||
npx eslint --no-error-on-unmatched-pattern \
|
||||
--config eslint.config.mjs \
|
||||
--max-warnings=0 \
|
||||
$CHANGED_FILES
|
||||
-- "${CHANGED_FILES[@]}"
|
||||
|
||||
# Run Prettier --check on the same set of changed files to catch
|
||||
# formatting drift in PRs that bypassed the local pre-commit hook
|
||||
|
|
@ -68,20 +71,23 @@ jobs:
|
|||
- name: Run Prettier --check on changed files
|
||||
run: |
|
||||
BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true)
|
||||
mapfile -d '' -t CHANGED_FILES < <(
|
||||
git diff -z --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD |
|
||||
grep -zE '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true
|
||||
)
|
||||
|
||||
if [[ -z "$CHANGED_FILES" ]]; then
|
||||
if [[ ${#CHANGED_FILES[@]} -eq 0 ]]; then
|
||||
echo "No matching files changed. Skipping Prettier."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Files to check:"
|
||||
echo "$CHANGED_FILES"
|
||||
printf '%s\n' "${CHANGED_FILES[@]}"
|
||||
|
||||
# `prettier --check` exits non-zero if any file would be reformatted.
|
||||
# Suggest the local fix in the failure message so contributors aren't
|
||||
# left guessing how to resolve.
|
||||
if ! npx prettier --check --no-error-on-unmatched-pattern $CHANGED_FILES; then
|
||||
if ! npx prettier --check --no-error-on-unmatched-pattern -- "${CHANGED_FILES[@]}"; then
|
||||
echo ""
|
||||
echo "::error::Prettier formatting drift detected. Fix locally with:"
|
||||
echo "::error:: npx prettier --write <files>"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue