Skip to content

Prevent spec-derived values from escaping AutoRest output directories - #5340

Open
Timothee Guerin (timotheeguerin) with Copilot wants to merge 4 commits into
mainfrom
copilot/apply-change-to-typespec-autorest-emitter
Open

Prevent spec-derived values from escaping AutoRest output directories#5340
Timothee Guerin (timotheeguerin) with Copilot wants to merge 4 commits into
mainfrom
copilot/apply-change-to-typespec-autorest-emitter

Conversation

Copilot AI commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

The AutoRest emitter interpolated raw service names and API versions into filesystem paths, allowing traversal-like spec values to escape configured directories.

  • Path sanitization

    • Sanitize {service-name} and {version} in output paths.
    • Sanitize versions used to locate examples.
    • Preserve benign names and versions unchanged.
  • Compiler integration

    • Update the TypeSpec core reference to consume sanitizePathSegment.
  • Regression coverage

    • Cover path separators, traversal sequences, dot-only versions, and normal values.
@versioned(Versions)
@service namespace Service {
  enum Versions {
    v1: "../../../escaped"
  }
}

The version is emitted as .._.._.._escaped, keeping generated and example paths within their configured directories.

Copilot AI and others added 2 commits August 28, 2026 19:53
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:autorest Issues for @azure-tools/typespec-autorest emitter label Aug 28, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-autorest@5340

commit: 2d5438b

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @azure-tools/typespec-autorest
Show changes

@azure-tools/typespec-autorest - fix ✏️

Sanitize spec-provided service names and versions used in output and example paths so they cannot escape their configured directories.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Package size report

✅ No notable package size changes compared to the base branch.

13 package(s) with no notable change
Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/typespec-java 13.51 MB → 13.51 MB +89 B (+0.0%) 15.03 MB → 15.03 MB
@azure-tools/typespec-autorest 80.93 KB → 81.01 KB +85 B (+0.1%) 395.06 KB → 395.40 KB +348 B (+0.1%)
@azure-tools/typespec-azure-portal-core 42.40 KB → 42.40 KB +3 B (+0.0%) 192.91 KB → 192.91 KB
@azure-tools/azure-http-specs 146.71 KB → 146.71 KB 1.16 MB → 1.16 MB
@azure-tools/typespec-autorest-canonical 7.42 KB → 7.42 KB 26.00 KB → 26.00 KB
@azure-tools/typespec-azure-core 129.43 KB → 129.43 KB 702.77 KB → 702.77 KB
@azure-tools/typespec-azure-resource-manager 171.92 KB → 171.92 KB 1.04 MB → 1.04 MB
@azure-tools/typespec-azure-rulesets 5.16 KB → 5.16 KB 32.09 KB → 32.09 KB
@azure-tools/typespec-client-generator-core 229.48 KB → 229.48 KB 1.23 MB → 1.23 MB
@azure-tools/typespec-go 260.21 KB → 260.21 KB 1.33 MB → 1.33 MB
@azure-tools/typespec-metadata 15.91 KB → 15.91 KB 62.26 KB → 62.26 KB
@azure-tools/typespec-python 42.22 KB → 42.22 KB 164.91 KB → 164.91 KB
@azure-tools/typespec-ts 536.71 KB → 536.71 KB 2.58 MB → 2.58 MB

Packed = gzipped .tgz published to npm. Unpacked = total extracted size. 🆕 added, 🗑️ removed. Packages from the core/ submodule are not included.
🔴 grew · 🟢 shrank — only changes of at least 512 B and 0.5% are marked.

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

@timotheeguerin

Copy link
Copy Markdown
Member

Copilot resolve the merge conflicts in this pull request

…to-typespec-autorest-emitter

# Conflicts:
#	core
#	pnpm-lock.yaml

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>

Copilot AI commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts against the latest main in commit 2d5438b86 and verified the AutoRest build, formatting, lint, and focused tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:autorest Issues for @azure-tools/typespec-autorest emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants