Class: Rubino::Security::CommandAllowlist

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/security/command_allowlist.rb

Overview

Manages a whitelist of shell commands that can be executed without confirmation.

Instance Method Summary collapse

Constructor Details

#initialize(config: nil) ⇒ CommandAllowlist

Returns a new instance of CommandAllowlist.



7
8
9
10
# File 'lib/rubino/security/command_allowlist.rb', line 7

def initialize(config: nil)
  @config = config || Rubino.configuration
  @allowlist = @config.security_command_allowlist
end

Instance Method Details

#allowed?(command) ⇒ Boolean

Returns true if the command matches an entry in the allowlist. An EMPTY allowlist matches NOTHING — pre-approval is opt-in, so an unconfigured allowlist must never auto-approve everything.

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/rubino/security/command_allowlist.rb', line 15

def allowed?(command)
  return false if @allowlist.empty?

  @allowlist.any? do |allowed|
    command.strip.start_with?(allowed.strip)
  end
end