Class: Rubino::Security::PrefixDeriver::Rule
- Inherits:
-
Struct
- Object
- Struct
- Rubino::Security::PrefixDeriver::Rule
- Defined in:
- lib/rubino/security/prefix_deriver.rb
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#covers?(command) ⇒ Boolean
Does this remembered rule cover ‘command`? Matching mirrors the storage shape: a pattern covers any sibling of its class, a prefix covers any command that start_with? it (like CommandAllowlist), an exact command covers only itself.
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind
21 22 23 |
# File 'lib/rubino/security/prefix_deriver.rb', line 21 def kind @kind end |
#value ⇒ Object
Returns the value of attribute value
21 22 23 |
# File 'lib/rubino/security/prefix_deriver.rb', line 21 def value @value end |
Instance Method Details
#covers?(command) ⇒ Boolean
Does this remembered rule cover ‘command`? Matching mirrors the storage shape: a pattern covers any sibling of its class, a prefix covers any command that start_with? it (like CommandAllowlist), an exact command covers only itself.
26 27 28 29 30 31 32 33 |
# File 'lib/rubino/security/prefix_deriver.rb', line 26 def covers?(command) cmd = command.to_s case kind when :pattern then DangerousPatterns.detect(cmd)[1] == value when :prefix then cmd.strip.start_with?(value.to_s.strip) else cmd.strip == value.to_s.strip end end |