Module: Rex::Proto::Ssh::AccessControlList
- Included in:
- Connection
- Defined in:
- lib/rex/proto/ssh/connection.rb
Overview
Whitelist-based access control scaffold
Instance Method Summary collapse
-
#deny=(host, port, bind = false) ⇒ Object
Delete permitted access control entry from access control list.
-
#permit=(host, port, bind = false) ⇒ Object
Add permitted access control entry to access control list Create ACL if it does not yet exist.
-
#permit?(host, port, bind = false) ⇒ TrueClass, FalseClass
Check if access control entry exists in access control list.
Instance Method Details
#deny=(host, port, bind = false) ⇒ Object
Delete permitted access control entry from access control list
35 36 37 38 39 |
# File 'lib/rex/proto/ssh/connection.rb', line 35 def deny=(host, port, bind = false) @acl[ bind ? :bind : :connect ].select! do |ent| ent != "#{host}:#{port}" end if @acl end |
#permit=(host, port, bind = false) ⇒ Object
Add permitted access control entry to access control list Create ACL if it does not yet exist
21 22 23 24 25 26 |
# File 'lib/rex/proto/ssh/connection.rb', line 21 def permit=(host, port, bind = false) @acl ||= { bind:[], connect:[] } unless permit?(host, port, bind) @acl[ bind ? :bind : :connect ] << "#{host}:#{port}" end end |
#permit?(host, port, bind = false) ⇒ TrueClass, FalseClass
Check if access control entry exists in access control list
49 50 51 52 53 |
# File 'lib/rex/proto/ssh/connection.rb', line 49 def permit?(host, port, bind = false) @acl and ["#{host}:#{port}", "*:*", "#{host}:*", "*:#{port}"].any? do |m| @acl[ bind ? :bind : :connect ].include?(m) end end |