Skip to content

fix(har): reject extra positional args on push commands - #349

Open
BlueLabelscotch wants to merge 4 commits into
mainfrom
fix/har-push-arity
Open

BlueLabelscotch wants to merge 4 commits into
mainfrom
fix/har-push-arity

Conversation

@BlueLabelscotch

Copy link
Copy Markdown
Collaborator

Fixes #339

Problem

Single-file push commands read only ctx.Args[0], so extra positional args were silently ignored. For example push artifact:rpm <registry> a.rpm b.rpm uploaded a.rpm and dropped b.rpm without any error. The original hc commands reject this with cobra.ExactArgs.

Change

  • Add rejectExtraArgs(ctx, max) in modules/har/pkg/har/push.go, with a table test.
  • Call it at the top of each push handler, before any other work:
    • max 1: rpm, cargo, composer, conda, dart, npm, nuget, python, ruby, puppet, debian, maven, terraform, go
    • max 2: swift, conan
  • push artifact:generic is unchanged since it takes many paths; helm and docker are unimplemented stubs.

The check lives in the handlers, so this is a module-only change with no core edits.

Test

  • go test ./pkg/har in modules/har

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep Code Review Agent🐛

Review completed with 0 suggestions.

Reviewed commit: 192fcc6

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HAR: extra positional args silently ignored on single-file push

1 participant