From 546017a426503379e42bcd6e5c0d3c039973d263 Mon Sep 17 00:00:00 2001 From: mikera Date: Thu, 14 Dec 2023 14:43:21 +0000 Subject: [PATCH] Stub implementation for generic trust monitors --- .../src/main/cvx/convex/trust/monitors.cvx | 17 +++++++++++++++++ .../src/main/java/convex/core/init/Init.java | 1 + 2 files changed, 18 insertions(+) create mode 100644 convex-core/src/main/cvx/convex/trust/monitors.cvx 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; }