Skip to content

DXE-7228 commands: validate package command names before deriving output paths - #227

Merged
mgwoj merged 1 commit into
akamai:feature/DXE-7228-gh-pr-validate-package-command-names-before-writing-binariesfrom
thesmartshadow:fix/validate-package-command-names
Oct 9, 2026
Merged

mgwoj merged 1 commit into
akamai:feature/DXE-7228-gh-pr-validate-package-command-names-before-writing-binariesfrom
thesmartshadow:fix/validate-package-command-names

Conversation

@thesmartshadow

Copy link
Copy Markdown

cli.json command names are normalized during package discovery, but were
not constrained to command identifiers before being incorporated into binary
output names.

Validate command names while reading package metadata, before installer
selection or dependency processing. Keep the same validation at the Go build
and binary download sinks so direct callers cannot reintroduce filesystem path
control.

Remove a pre-existing Go build output entry before invoking go build. This
prevents package contents from supplying a symlink at the expected output
location.

Add regressions for malformed local and remote metadata, the binary download
path, and the Go installation path.

Tests: go test ./...

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Address the ASCII validation issue and add coverage for pre-existing output symlink cleanup.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR validates package command names before deriving executable paths and removes pre-existing Go build outputs to mitigate path-control and symlink risks.

Changes:

  • Adds centralized command-name validation.
  • Applies validation during metadata loading, Go builds, and binary downloads.
  • Adds malformed-metadata and output-path regressions.
  • Removes existing Go build outputs before compilation.

Review findings:

  • pkg/tools/util.go:19 (moderate, 1 vote): validate raw values against ASCII ranges before lowercasing.
  • pkg/packages/golang.go:84 (nit, 3 votes): add a regression covering removal of a pre-existing output symlink.
File summaries
File Summary
pkg/tools/util.go Defines command-name normalization and validation.
pkg/packages/golang.go Validates Go commands and removes existing outputs.
pkg/packages/golang_test.go Tests malformed Go command names.
pkg/commands/subcommands.go Validates metadata and binary output paths.
pkg/commands/subcommands_test.go Tests malformed local, remote, and binary metadata.
Review details

Suppressed comments (1)

pkg/tools/util.go:20

  • The validation runs after Unicode lowercasing, so non-ASCII characters with an ASCII lowercase mapping (for example U+212A, the Kelvin sign) pass this supposedly ASCII identifier grammar and can collide with a distinct normalized name. Match the raw value against the ASCII ranges first, then lowercase it.
	normalized := strings.ToLower(name)
	if !commandNamePattern.MatchString(normalized) {
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/packages/golang.go
Comment on lines +84 to +88
// A package repository controls its own contents. Remove a pre-existing
// output entry so go build cannot follow a symlink planted in that repo.
if err := os.Remove(outputPath); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("remove existing Go build output %q: %w", outputPath, err)
}
@mstojanowski mstojanowski changed the title commands: validate package command names before deriving output paths DXE-7228 commands: validate package command names before deriving output paths Sep 17, 2026
@mgwoj
mgwoj changed the base branch from master to feature/DXE-7228-gh-pr-validate-package-command-names-before-writing-binaries October 9, 2026 12:10
@mgwoj
mgwoj merged commit 9145e31 into akamai:feature/DXE-7228-gh-pr-validate-package-command-names-before-writing-binaries Oct 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants