Skip to content

Commit 1c40231

Browse files
authored
Merge pull request #9110 from cthorn42/maint/main/PUP-11895_clean_subcommand_work
(PUP-11895) ssl application's clean shouldn't allow extra args
2 parents 617e136 + 41548c6 commit 1c40231

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/puppet/application/ssl.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ def main
146146
when 'verify'
147147
verify(certname)
148148
when 'clean'
149+
possible_extra_args = command_line.args.drop(1)
150+
unless possible_extra_args.empty?
151+
raise Puppet::Error, _(<<END) % { args: possible_extra_args.join(' ')}
152+
Extra arguments detected: %{args}
153+
Did you mean to run:
154+
puppetserver ca clean --certname <name>
155+
Or:
156+
puppet ssl clean --target <name>
157+
END
158+
end
149159
clean(certname)
150160
when 'bootstrap'
151161
if !Puppet::Util::Log.sendlevel?(:info)

spec/unit/application/ssl_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ def expects_command_to_fail(message)
391391
expects_command_to_fail(%r{Failed to connect to the CA to determine if certificate #{name} has been cleaned})
392392
end
393393

394+
it 'raises if we have extra args' do
395+
ssl.command_line.args << 'hostname.example.biz'
396+
expects_command_to_fail(/Extra arguments detected: hostname.example.biz/)
397+
end
398+
394399
context 'when deleting local CA' do
395400
before do
396401
ssl.command_line.args << '--localca'

0 commit comments

Comments
 (0)