Class: Ace::Git::Secrets::Commands::RevokeCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/git/secrets/commands/revoke_command.rb

Overview

CLI command for revoking tokens via provider APIs

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RevokeCommand

Returns a new instance of RevokeCommand.



16
17
18
# File 'lib/ace/git/secrets/commands/revoke_command.rb', line 16

def initialize(options)
  @options = options
end

Class Method Details

.execute(options) ⇒ Integer

Execute revoke command

Parameters:

  • options (Hash)

    Command options

Returns:

  • (Integer)

    Exit code (0=success, 1=partial/failure, 2=error)



12
13
14
# File 'lib/ace/git/secrets/commands/revoke_command.rb', line 12

def self.execute(options)
  new(options).execute
end

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ace/git/secrets/commands/revoke_command.rb', line 20

def execute
  tokens = load_tokens
  return 1 if tokens.nil?

  if tokens.empty?
    puts "No tokens found to revoke."
    puts "Run 'ace-git-secrets scan' first to detect tokens."
    return 0
  end

  # Filter by service if specified
  services = @options[:service] ? [@options[:service]] : nil

  revoker = Molecules::TokenRevoker.new
  results = revoker.revoke_all(tokens, services: services)

  # Display results
  display_results(results)

  # Return code based on results
  if results.all?(&:success?)
    0
  elsif results.any?(&:success?)
    1 # Partial success
  else
    1
  end
rescue => e
  puts "Error: #{e.message}"
  puts e.backtrace.first(5).join("\n") if ENV["DEBUG"]
  2
end