Skip to content

fix(api-docs/sisters): close template-injection on ref in cpp/dotnet/python/typescript#71

Merged
WomB0ComB0 merged 1 commit intomainfrom
fix/api-docs-template-injection-sisters
May 10, 2026
Merged

fix(api-docs/sisters): close template-injection on ref in cpp/dotnet/python/typescript#71
WomB0ComB0 merged 1 commit intomainfrom
fix/api-docs-template-injection-sisters

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

Summary

Mirrors #70 (rust template fix) across the remaining four sister templates. Same root cause, same remediation.

Affected templates:

  • `automation/source-repo-templates/api-docs.cpp.yml`
  • `automation/source-repo-templates/api-docs.dotnet.yml`
  • `automation/source-repo-templates/api-docs.python.yml`
  • `automation/source-repo-templates/api-docs.typescript.yml`

Pattern (each file):

```yaml

Before

run: |
raw='${{ inputs.ref || github.ref_name }}'

After

env:
REF_RAW: ${{ inputs.ref || github.ref_name }}
run: |
raw="$REF_RAW"
```

The `${{ }}` interpolation runs at template-expansion time, before shell parsing. Tag names containing a single quote (Git permits them — only space, `~`, `^`, `:`, `?`, `*`, `[`, `\`, `..` are forbidden ref chars) would terminate the literal and inject shell. The runner has the source-tree checkout and `DOCS_REPO_PR_TOKEN` in env at that point.

Env indirection routes the value through the runner's env layer where shell metacharacters survive intact and cannot escape the variable boundary.

Per-template detail

Each template's existing slug-substitution rules are preserved unchanged:

  • cpp: `/` → `-`, `@` → `-`
  • dotnet: `/` → `-` (no @ handling)
  • python: `/` → `-` (no @ handling)
  • typescript: `/` → `-`, `@` → `` (so `@resq-sw/ui@v0.35.6` → `resq-sw-ui-v0.35.6`)

Only the source of `$raw` changes from interpolated literal to env var. `DOCS_REF_NAME` / `DOCS_REF_SLUG` outputs are byte-identical for every input ref.

Effect on downstream

`automation/sync-templates.sh` will produce sync PRs in:

  • `resq-software/vcpkg` (cpp)
  • `resq-software/dotnet-sdk` (dotnet)
  • `resq-software/pypi` (python)
  • `resq-software/npm` (typescript)

on its next run, each carrying the env-indirection patch into that repo's `.github/workflows/api-docs.yml`.

Test plan

  • Visual review: 4 identical hunks, ~10 lines added per file (8 comment lines + `env:` block + 1 changed `raw=` line). No other lines touched.
  • Slug rules preserved per-template (verified by inspection — see "Per-template detail").
  • After merge, run the per-language sync (or wait for the next cron) and confirm the resulting sync PRs in each source repo have the same diff shape.

Related

…python/typescript

Mirrors the rust-template fix (#70) across the remaining four sister
templates. Each has the same `inputs.ref || github.ref_name` inlined
into a single-quoted shell literal at template-expansion time. Tag
names containing a single quote (Git permits them) would break out of
the literal and run arbitrary shell with the runner's checkout and
DOCS_REPO_PR_TOKEN in scope.

Routes the value through a step-level env: REF_RAW: instead. Each
template's existing slug-substitution rules are preserved (cpp uses
\@/-, typescript uses \@/<empty>, dotnet/python only normalize /);
only the source of $raw changes from interpolated literal to env var.

DOCS_REF_NAME / DOCS_REF_SLUG outputs are byte-identical for every
input ref. Behavior unchanged.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@WomB0ComB0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 32 minutes and 40 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4e5bdee-1430-4b67-b491-263cd20faf71

📥 Commits

Reviewing files that changed from the base of the PR and between e6909a5 and e3bff19.

📒 Files selected for processing (4)
  • automation/source-repo-templates/api-docs.cpp.yml
  • automation/source-repo-templates/api-docs.dotnet.yml
  • automation/source-repo-templates/api-docs.python.yml
  • automation/source-repo-templates/api-docs.typescript.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/api-docs-template-injection-sisters

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the area:content MDX/MD documentation content label May 10, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements security hardening across several GitHub Actions workflow templates for C++, .NET, Python, and TypeScript. It replaces the direct inlining of GitHub context variables into shell scripts with environment variable indirection to prevent potential shell injection vulnerabilities from malformed ref names. I have no feedback to provide as there were no review comments.

@WomB0ComB0 WomB0ComB0 merged commit 048379a into main May 10, 2026
13 checks passed
@WomB0ComB0 WomB0ComB0 deleted the fix/api-docs-template-injection-sisters branch May 10, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:content MDX/MD documentation content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant