Example #1
0
// NewTemporaryDatalogGuard returns a new datalog guard with a fresh, unsigned,
// non-persistent rule set. It adds a custom predicate subprin(P, O, E) to check
// if a principal P is a subprincipal O.E.
func NewTemporaryDatalogGuard() Guard {
	sp := &subprinPrim{max: 1}
	sp.SetArity(3)
	eng := dlengine.NewEngine()
	eng.AddPred(sp)
	return &DatalogGuard{dl: eng, sp: sp}
}
Example #2
0
// NewDatalogGuard returns a new datalog guard without configuring a rules
// file.
func NewDatalogGuard(verifier *Verifier) *DatalogGuard {
	sp := &subprinPrim{max: 1}
	sp.SetArity(3)
	eng := dlengine.NewEngine()
	eng.AddPred(sp)
	dg := &DatalogGuard{Key: verifier, dl: eng, sp: sp}
	dg.Config.SignedRulesPath = nil
	return dg
}
Example #3
0
func setup(t *testing.T, input string, asserts, retracts, queries, errors int) *dlengine.Engine {
	e := dlengine.NewEngine()
	e.AddPred(Equals)
	a, r, q, errs := e.Process("test", input)
	if a != asserts || r != retracts || q != queries || errs != errors {
		t.Fatalf("setup process failed: %d %d %d %d\ninput = %s", a, r, q, errs, input)
	}
	// fmt.Printf("setup: %s\n", input)
	return e
}
Example #4
0
// Clear removes all rules.
func (g *DatalogGuard) Clear() error {
	g.db.Rules = nil
	g.dl = dlengine.NewEngine()
	return nil
}