You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Create procedures and register UDFs while wildcard allows it
134
+
run_expect_success "$OP""create procedure myadd version 'test' {local function myadd(a, b) return a + b end}" \
135
+
"create myadd procedure for scalar UDF"
136
+
run_expect_success "$OP""create lua scalar function myadd" \
137
+
"register myadd as scalar UDF"
138
+
run_expect_success "$OP""create procedure mysum version 'test' {local agg = 0 local function step(v) agg = agg + v end local function final() return agg end}" \
139
+
"create mysum procedure for aggregate UDF"
140
+
run_expect_success "$OP""create lua aggregate function mysum" \
141
+
"register mysum as aggregate UDF"
142
+
run_expect_success "$OP""create procedure myproc version 'test' {local function main() db:column_name('result', 1) db:column_type('text', 1) db:emit('hello') end}" \
143
+
"create myproc stored procedure"
144
+
run_expect_success "$OP""create table if not exists t_udf(i int)" \
145
+
"create t_udf table"
146
+
run_expect_success "$OP""insert into t_udf values(10),(20),(30)" \
147
+
"populate t_udf"
148
+
149
+
# Verify everything works with wildcard in place
150
+
run_expect_success "$MARK""select myadd(1, 2)" \
151
+
"mk can call scalar UDF (wildcard allows)"
152
+
run_expect_success "$MARK""select mysum(i) from t_udf" \
# Set up restricted access: remove wildcard, grant mk only table access
158
+
run_expect_success "$OP""insert into comdb2_simple_auth(cluster, user, bpkg, verb, resourcetype, resourcename) values('*', 'op', '*', 'Write', 'table', 'comdb2_simple_auth') on conflict do nothing" \
159
+
"grant op write on auth table"
160
+
run_expect_success "$OP""insert into comdb2_simple_auth(cluster, user, bpkg, verb, resourcetype, resourcename) values('*', 'op', '*', 'Read', 'table', 'comdb2_simple_auth') on conflict do nothing" \
161
+
"grant op read on auth table"
162
+
run_expect_success "$OP""delete from comdb2_simple_auth where cluster='*' and user='*' and bpkg='*' and verb='*' and resourcetype='*' and resourcename='*'" \
163
+
"remove wildcard rule"
164
+
165
+
# Give mk Read access to t_udf table only (no stored-procedure access)
166
+
run_expect_success "$OP""insert into comdb2_simple_auth(cluster, user, bpkg, verb, resourcetype, resourcename) values('*', 'mk', '*', 'Read', 'table', 't_udf') on conflict do nothing" \
167
+
"add mk Read rule for t_udf"
168
+
169
+
# mk can call scalar UDF (no table involved, UDFs bypass auth entirely)
170
+
run_expect_success "$MARK""select myadd(1, 2)" \
171
+
"mk can call scalar UDF without stored-procedure access (UDFs bypass auth)"
172
+
173
+
# mk can call aggregate UDF on t_udf (table Read is enough, UDF itself needs no auth)
174
+
run_expect_success "$MARK""select mysum(i) from t_udf" \
175
+
"mk can call aggregate UDF with table access (UDFs bypass auth)"
0 commit comments