Class: Alf::Lang::Parser::Safer::Policy

Inherits:
RubyCop::Policy
  • Object
show all
Defined in:
lib/alf/lang/parser/safer.rb

Constant Summary collapse

ALF_CALL_BLACKLIST =
%w[
  gem
  puts
  to_cog
  to_relvar
  to_relation
  insert
  delete
  update
  affect
  upsert
].to_set.freeze
ALF_CONSTANT_WHITELIST =
%w[
  DEE
  DUM
].to_set.freeze

Instance Method Summary collapse

Instance Method Details

#visit_Call(node) ⇒ Object


47
48
49
# File 'lib/alf/lang/parser/safer.rb', line 47

def visit_Call(node)
  super && !ALF_CALL_BLACKLIST.include?(node.identifier.token.to_s)
end

#visit_Constant(node) ⇒ Object


56
57
58
# File 'lib/alf/lang/parser/safer.rb', line 56

def visit_Constant(node)
  ALF_CONSTANT_WHITELIST.include?(node.token.to_s)
end

#visit_ConstantAssignment(node) ⇒ Object

Raises:


60
61
62
# File 'lib/alf/lang/parser/safer.rb', line 60

def visit_ConstantAssignment(node)
  raise SecurityError, "Forbidden: constant assignment"
end