【发布时间】:2021-11-26 15:32:07
【问题描述】:
我需要授予某些开发人员特权,以便能够在 Oracle 数据库上调试包/过程/功能。
但是当我授予调试任何程序或调试连接会话时,他/她也能够更改代码。如何预防?
【问题讨论】:
标签: oracle privileges
我需要授予某些开发人员特权,以便能够在 Oracle 数据库上调试包/过程/功能。
但是当我授予调试任何程序或调试连接会话时,他/她也能够更改代码。如何预防?
【问题讨论】:
标签: oracle privileges
解决方案是将过程的所有者与开发人员分离。让我告诉你怎么做
创建拥有过程的用户
SQL> create user test4 identified by Oracle_1234 ;
User created.
SQL> grant create table, create procedure to test4 ;
Grant succeeded.
SQL> create procedure test4.pr_test ( p1 in number )
2 is
3 begin
4 dbms_output.put_line(p1);
5 end;
6 /
Procedure created.
创建一个对过程进行调试的用户
SQL> create user test5 identified by Oracle_1234 ;
User created.
SQL> grant debug connect session , create session to test5 ;
Grant succeeded.
SQL> grant debug on test4.pr_test to test5 ;
Grant succeeded.
现在,用户test5可以调试test4拥有的过程,但他可以执行,也不能改变它。
sqlplus test5/Oracle_1234
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Oct 6 17:04:20 2021
Version 19.6.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0
SQL> exec test4.pr_test ;
BEGIN test4.pr_test ; END;
*
ERROR at line 1:
ORA-06550: line 1, column 13:
PLS-00904: insufficient privilege to access object TEST4.PR_TEST
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL> create or replace procedure test4.pr_test
2 is
3 begin
4 null;
5 end;
6 /
create or replace procedure test4.pr_test
*
ERROR at line 1:
ORA-01031: insufficient privileges
避免这种情况的最佳方法是将owners/schemas 与users 解耦,这样您就可以授予调试权限,但用户将无法更改代码或执行过程。
顺便说一句,debug any procedure 是一种非常糟糕的安全做法。除非绝对必要,否则不应将ANY 特权授予任何人。
【讨论】: