Documentation ¶
Index ¶
- Variables
- func ExpressionString(e Expression) string
- type And
- type Any
- type Argument
- type ArgumentType
- type Arithmetic
- type ArithmeticType
- type BinaryNegation
- type Boolean
- type BooleanLiteral
- type Call
- type Comparison
- type ComparisonType
- type EmptyTransformer
- func (s *EmptyTransformer) AcceptAnd(v And)
- func (s *EmptyTransformer) AcceptArgument(v Argument)
- func (s *EmptyTransformer) AcceptArithmetic(v Arithmetic)
- func (s *EmptyTransformer) AcceptBinaryNegation(v BinaryNegation)
- func (s *EmptyTransformer) AcceptBooleanLiteral(v BooleanLiteral)
- func (s *EmptyTransformer) AcceptCall(v Call)
- func (s *EmptyTransformer) AcceptComparison(v Comparison)
- func (s *EmptyTransformer) AcceptInclusion(v Inclusion)
- func (s *EmptyTransformer) AcceptNegation(v Negation)
- func (s *EmptyTransformer) AcceptNumericLiteral(v NumericLiteral)
- func (s *EmptyTransformer) AcceptOr(v Or)
- func (s *EmptyTransformer) AcceptVariable(v Variable)
- func (s *EmptyTransformer) Transform(inp Expression) Expression
- type EvaluatorVisitor
- func (sv *EvaluatorVisitor) AcceptAnd(v And)
- func (sv *EvaluatorVisitor) AcceptArgument(v Argument)
- func (sv *EvaluatorVisitor) AcceptArithmetic(v Arithmetic)
- func (sv *EvaluatorVisitor) AcceptBinaryNegation(v BinaryNegation)
- func (sv *EvaluatorVisitor) AcceptBooleanLiteral(v BooleanLiteral)
- func (sv *EvaluatorVisitor) AcceptCall(v Call)
- func (sv *EvaluatorVisitor) AcceptComparison(v Comparison)
- func (sv *EvaluatorVisitor) AcceptInclusion(v Inclusion)
- func (sv *EvaluatorVisitor) AcceptNegation(v Negation)
- func (sv *EvaluatorVisitor) AcceptNumericLiteral(v NumericLiteral)
- func (sv *EvaluatorVisitor) AcceptOr(v Or)
- func (sv *EvaluatorVisitor) AcceptVariable(v Variable)
- type Expression
- type Inclusion
- type Macro
- type Negation
- type Numeric
- type NumericLiteral
- type Or
- type Policy
- type RawPolicy
- type Rule
- type StringVisitor
- func (sv *StringVisitor) AcceptAnd(v And)
- func (sv *StringVisitor) AcceptArgument(v Argument)
- func (sv *StringVisitor) AcceptArithmetic(v Arithmetic)
- func (sv *StringVisitor) AcceptBinaryNegation(v BinaryNegation)
- func (sv *StringVisitor) AcceptBooleanLiteral(v BooleanLiteral)
- func (sv *StringVisitor) AcceptCall(v Call)
- func (sv *StringVisitor) AcceptComparison(v Comparison)
- func (sv *StringVisitor) AcceptInclusion(v Inclusion)
- func (sv *StringVisitor) AcceptNegation(v Negation)
- func (sv *StringVisitor) AcceptNumericLiteral(v NumericLiteral)
- func (sv *StringVisitor) AcceptOr(v Or)
- func (sv *StringVisitor) AcceptVariable(v Variable)
- func (sv *StringVisitor) String() string
- type Transformer
- type Variable
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var ArithmeticNames = map[ArithmeticType]string{ PLUS: "+", MINUS: "-", MULT: "*", DIV: "/", BINAND: "&", BINOR: "|", BINXOR: "^", LSH: "<<", RSH: ">>", MOD: "%", }
ArithmeticNames maps the types to names for presentation
var ArithmeticSymbols = map[ArithmeticType]string{ PLUS: "plus", MINUS: "minus", MULT: "mul", DIV: "div", BINAND: "binand", BINOR: "binor", BINXOR: "binxor", LSH: "lsh", RSH: "rsh", MOD: "mod", }
ArithmeticSymbols maps the types to names for symbolic processing
var ComparisonNames = map[ComparisonType]string{ EQL: "==", NEQL: "!=", GT: ">", GTE: ">=", LT: "<", LTE: "<=", BITSET: "&?", }
ComparisonNames maps types to names for presentation
var ComparisonSymbols = map[ComparisonType]string{ EQL: "eq", NEQL: "neq", GT: "gt", GTE: "gte", LT: "lt", LTE: "lte", BITSET: "bitset", }
ComparisonSymbols maps types to names for symbolic processing
Functions ¶
func ExpressionString ¶
func ExpressionString(e Expression) string
ExpressionString returns a string for the given expression
Types ¶
type Argument ¶
type Argument struct { Type ArgumentType Index int }
Argument represents an argment given to the syscall
type ArgumentType ¶
type ArgumentType int
ArgumentType represents one of the three types of argument loads we can do
const ( Full ArgumentType = iota Low Hi )
The different types of argument loads that can happen
type Arithmetic ¶
type Arithmetic struct { Op ArithmeticType Left, Right Numeric }
Arithmetic represents an arithmetic operation
type ArithmeticType ¶
type ArithmeticType int
ArithmeticType specifies the different possible arithmetic operations
const ( PLUS ArithmeticType = iota MINUS MULT DIV BINAND BINOR BINXOR LSH RSH MOD )
Constants for the different possible types
type BinaryNegation ¶
type BinaryNegation struct {
Operand Numeric
}
BinaryNegation represents binary negation of a number
func (BinaryNegation) Accept ¶
func (v BinaryNegation) Accept(vs Visitor)
Accept implements Expression
type BooleanLiteral ¶
type BooleanLiteral struct {
Value bool
}
BooleanLiteral represents a boolean literal
func (BooleanLiteral) Accept ¶
func (v BooleanLiteral) Accept(vs Visitor)
Accept implements Expression
type Comparison ¶
type Comparison struct { Op ComparisonType Left, Right Numeric }
Comparison represents a comparison
type ComparisonType ¶
type ComparisonType int
ComparisonType specifies the possible comparison types
const ( EQL ComparisonType = iota NEQL GT GTE LT LTE BITSET )
Contains all the comparison types
type EmptyTransformer ¶
type EmptyTransformer struct { Result Expression RealSelf Transformer }
EmptyTransformer does nothing - it returns the same tree as given It can be useful as the base for other transformers
func (*EmptyTransformer) AcceptAnd ¶
func (s *EmptyTransformer) AcceptAnd(v And)
AcceptAnd implements Visitor
func (*EmptyTransformer) AcceptArgument ¶
func (s *EmptyTransformer) AcceptArgument(v Argument)
AcceptArgument implements Visitor
func (*EmptyTransformer) AcceptArithmetic ¶
func (s *EmptyTransformer) AcceptArithmetic(v Arithmetic)
AcceptArithmetic implements Visitor
func (*EmptyTransformer) AcceptBinaryNegation ¶
func (s *EmptyTransformer) AcceptBinaryNegation(v BinaryNegation)
AcceptBinaryNegation implements Visitor
func (*EmptyTransformer) AcceptBooleanLiteral ¶
func (s *EmptyTransformer) AcceptBooleanLiteral(v BooleanLiteral)
AcceptBooleanLiteral implements Visitor
func (*EmptyTransformer) AcceptCall ¶
func (s *EmptyTransformer) AcceptCall(v Call)
AcceptCall implements Visitor
func (*EmptyTransformer) AcceptComparison ¶
func (s *EmptyTransformer) AcceptComparison(v Comparison)
AcceptComparison implements Visitor
func (*EmptyTransformer) AcceptInclusion ¶
func (s *EmptyTransformer) AcceptInclusion(v Inclusion)
AcceptInclusion implements Visitor
func (*EmptyTransformer) AcceptNegation ¶
func (s *EmptyTransformer) AcceptNegation(v Negation)
AcceptNegation implements Visitor
func (*EmptyTransformer) AcceptNumericLiteral ¶
func (s *EmptyTransformer) AcceptNumericLiteral(v NumericLiteral)
AcceptNumericLiteral implements Visitor
func (*EmptyTransformer) AcceptOr ¶
func (s *EmptyTransformer) AcceptOr(v Or)
AcceptOr implements Visitor
func (*EmptyTransformer) AcceptVariable ¶
func (s *EmptyTransformer) AcceptVariable(v Variable)
AcceptVariable implements Visitor
func (*EmptyTransformer) Transform ¶
func (s *EmptyTransformer) Transform(inp Expression) Expression
Transform implements Transformer
type EvaluatorVisitor ¶
type EvaluatorVisitor struct {
// contains filtered or unexported fields
}
EvaluatorVisitor will generate an unambigious representation of an expression
func (*EvaluatorVisitor) AcceptAnd ¶
func (sv *EvaluatorVisitor) AcceptAnd(v And)
AcceptAnd implements Visitor
func (*EvaluatorVisitor) AcceptArgument ¶
func (sv *EvaluatorVisitor) AcceptArgument(v Argument)
AcceptArgument implements Visitor
func (*EvaluatorVisitor) AcceptArithmetic ¶
func (sv *EvaluatorVisitor) AcceptArithmetic(v Arithmetic)
AcceptArithmetic implements Visitor
func (*EvaluatorVisitor) AcceptBinaryNegation ¶
func (sv *EvaluatorVisitor) AcceptBinaryNegation(v BinaryNegation)
AcceptBinaryNegation implements Visitor
func (*EvaluatorVisitor) AcceptBooleanLiteral ¶
func (sv *EvaluatorVisitor) AcceptBooleanLiteral(v BooleanLiteral)
AcceptBooleanLiteral implements Visitor
func (*EvaluatorVisitor) AcceptCall ¶
func (sv *EvaluatorVisitor) AcceptCall(v Call)
AcceptCall implements Visitor
func (*EvaluatorVisitor) AcceptComparison ¶
func (sv *EvaluatorVisitor) AcceptComparison(v Comparison)
AcceptComparison implements Visitor
func (*EvaluatorVisitor) AcceptInclusion ¶
func (sv *EvaluatorVisitor) AcceptInclusion(v Inclusion)
AcceptInclusion implements Visitor
func (*EvaluatorVisitor) AcceptNegation ¶
func (sv *EvaluatorVisitor) AcceptNegation(v Negation)
AcceptNegation implements Visitor
func (*EvaluatorVisitor) AcceptNumericLiteral ¶
func (sv *EvaluatorVisitor) AcceptNumericLiteral(v NumericLiteral)
AcceptNumericLiteral implements Visitor
func (*EvaluatorVisitor) AcceptOr ¶
func (sv *EvaluatorVisitor) AcceptOr(v Or)
AcceptOr implements Visitor
func (*EvaluatorVisitor) AcceptVariable ¶
func (sv *EvaluatorVisitor) AcceptVariable(v Variable)
AcceptVariable implements Visitor
type Macro ¶
type Macro struct { Name string ArgumentNames []string Body Expression }
Macro represents either a simple variable or a more complicated macro/func expression
type NumericLiteral ¶
type NumericLiteral struct {
Value uint64
}
NumericLiteral represents a numeric literal
func (NumericLiteral) Accept ¶
func (v NumericLiteral) Accept(vs Visitor)
Accept implements Expression
type Policy ¶
type Policy struct { DefaultPositiveAction string DefaultNegativeAction string DefaultPolicyAction string ActionOnX32 string ActionOnAuditFailure string Macros map[string]Macro Rules []*Rule }
Policy represents a complete policy file. It is possible to combine more than one policy file
type RawPolicy ¶
type RawPolicy struct {
RuleOrMacros []interface{}
}
RawPolicy represents the raw parsed rules and macros in the order they were encountered. This can be used to generate the final Policy
type Rule ¶
type Rule struct { Name string PositiveAction string NegativeAction string Body Expression }
Rule contains all the information for one specific rule
type StringVisitor ¶
type StringVisitor struct {
// contains filtered or unexported fields
}
StringVisitor will generate an unambigious representation of an expression
func (*StringVisitor) AcceptAnd ¶
func (sv *StringVisitor) AcceptAnd(v And)
AcceptAnd implements Visitor
func (*StringVisitor) AcceptArgument ¶
func (sv *StringVisitor) AcceptArgument(v Argument)
AcceptArgument implements Visitor
func (*StringVisitor) AcceptArithmetic ¶
func (sv *StringVisitor) AcceptArithmetic(v Arithmetic)
AcceptArithmetic implements Visitor
func (*StringVisitor) AcceptBinaryNegation ¶
func (sv *StringVisitor) AcceptBinaryNegation(v BinaryNegation)
AcceptBinaryNegation implements Visitor
func (*StringVisitor) AcceptBooleanLiteral ¶
func (sv *StringVisitor) AcceptBooleanLiteral(v BooleanLiteral)
AcceptBooleanLiteral implements Visitor
func (*StringVisitor) AcceptCall ¶
func (sv *StringVisitor) AcceptCall(v Call)
AcceptCall implements Visitor
func (*StringVisitor) AcceptComparison ¶
func (sv *StringVisitor) AcceptComparison(v Comparison)
AcceptComparison implements Visitor
func (*StringVisitor) AcceptInclusion ¶
func (sv *StringVisitor) AcceptInclusion(v Inclusion)
AcceptInclusion implements Visitor
func (*StringVisitor) AcceptNegation ¶
func (sv *StringVisitor) AcceptNegation(v Negation)
AcceptNegation implements Visitor
func (*StringVisitor) AcceptNumericLiteral ¶
func (sv *StringVisitor) AcceptNumericLiteral(v NumericLiteral)
AcceptNumericLiteral implements Visitor
func (*StringVisitor) AcceptOr ¶
func (sv *StringVisitor) AcceptOr(v Or)
AcceptOr implements Visitor
func (*StringVisitor) AcceptVariable ¶
func (sv *StringVisitor) AcceptVariable(v Variable)
AcceptVariable implements Visitor
func (*StringVisitor) String ¶
func (sv *StringVisitor) String() string
String returns the current string built up
type Transformer ¶
type Transformer interface { Visitor Transform(Expression) Expression }
Transformer is something that can transform expressions
type Visitor ¶
type Visitor interface { AcceptAnd(And) AcceptArgument(Argument) AcceptArithmetic(Arithmetic) AcceptBinaryNegation(BinaryNegation) AcceptBooleanLiteral(BooleanLiteral) AcceptCall(Call) AcceptComparison(Comparison) AcceptInclusion(Inclusion) AcceptNegation(Negation) AcceptNumericLiteral(NumericLiteral) AcceptOr(Or) AcceptVariable(Variable) }
Visitor is a visitor for all parse nodes