diff --git a/convex-core/src/main/cvx/convex/trust/monitors.cvx b/convex-core/src/main/cvx/convex/trust/monitors.cvx new file mode 100644 index 000000000..1b3e53906 --- /dev/null +++ b/convex-core/src/main/cvx/convex/trust/monitors.cvx @@ -0,0 +1,17 @@ +'convex.trust.monitors + +(import convex.trust :as trust) + +;; Generic check +(defn check-trusted? + ^:callable? + [subject action object] + (or *scope* (fail :ARGUMENT "Null scope in generic trust monitor")) + (let [[type arg] *scope*] + (cond + (= :wl type) (contains? arg subject) + (= :and type) (reduce (fn [a b] (and a (trust/trusted? b subject action object))) true arg) + (= :or type) (reduce (fn [a b] (or a (trust/trusted? b subject action object))) false arg) + (address? type) (call *scope* (check-trusted? subject action object)) + false + ))) \ No newline at end of file diff --git a/convex-core/src/main/java/convex/core/init/Init.java b/convex-core/src/main/java/convex/core/init/Init.java index 421828392..b64f8c2fd 100644 --- a/convex-core/src/main/java/convex/core/init/Init.java +++ b/convex-core/src/main/java/convex/core/init/Init.java @@ -245,6 +245,7 @@ private static State addStandardLibraries(State s) { s = doActorDeploy(s, "convex/trust/ownership-monitor.cvx"); s = doActorDeploy(s, "convex/trust/delegate.cvx"); s = doActorDeploy(s, "convex/trust/whitelist.cvx"); + s = doActorDeploy(s, "convex/trust/monitors.cvx"); return s; }