【问题标题】:Oracle Grant Debug Privilege without AlterOracle 授予调试权限而不进行更改
【发布时间】:2021-11-26 15:32:07
【问题描述】:

我需要授予某些开发人员特权,以便能够在 Oracle 数据库上调试包/过程/功能。

但是当我授予调试任何程序调试连接会话时,他/她也能够更改代码。如何预防?

【问题讨论】:

    标签: oracle privileges


    【解决方案1】:

    解决方案是将过程的所有者与开发人员分离。让我告诉你怎么做

    创建拥有过程的用户

    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/schemasusers 解耦,这样您就可以授予调试权限,但用户将无法更改代码或执行过程。

    顺便说一句,debug any procedure 是一种非常糟糕的安全做法。除非绝对必要,否则不应将ANY 特权授予任何人。

    【讨论】:

    • 您好,非常感谢您的回答和帮助,我按照您的指示如下:CREATE USER TEST5 IDENTIFIED BY ORACLE_1234 ;授予调试连接会话,创建会话到测试5;将 SCHEMA.PACKAGE_NAME 上的调试授予 TEST5;但用户仍然可以更改代码。
    • 这是不可能的@aliyousef。用户 test5 不能更改拥有 test4 的任何内容,除非您在那里拥有其他权限
    • 如果您复制我的示例,您会发现 test5 无法更改或执行 test4 拥有的过程。不可能。
    • 是的,现在可以工作了,谢谢
    • @aliyousef,不客气;)
    猜你喜欢
    • 2011-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    • 2013-12-12
    相关资源
    最近更新 更多