| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b921ff0 commit de31688
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -121,6 +121,7 @@ | |||
| 121 | 121 | "dumpTable": "boolean", | |
| 122 | 122 | "dumpAll": "boolean", | |
| 123 | 123 | "search": "boolean", | |
| 124 | + "getComments": "boolean", | ||
| 124 | 125 | "db": "string", | |
| 125 | 126 | "tbl": "string", | |
| 126 | 127 | "col": "string", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -386,6 +386,9 @@ def cmdLineParser(): | |||
| 386 | 386 | enumeration.add_option("--search", dest="search", action="store_true", | |
| 387 | 387 | help="Search column(s), table(s) and/or database name(s)") | |
| 388 | 388 | ||
| 389 | + enumeration.add_option("--comments", dest="getComments", action="store_true", | ||
| 390 | + help="Retrieve DBMS comments") | ||
| 391 | + | ||
| 389 | 392 | enumeration.add_option("-D", dest="db", | |
| 390 | 393 | help="DBMS database to enumerate") | |
| 391 | 394 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -554,6 +554,19 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None): | |||
| 554 | 554 | name = safeSQLIdentificatorNaming(columnData[0]) | |
| 555 | 555 | ||
| 556 | 556 | if name: | |
| 557 | + if conf.getComments: | ||
| 558 | + _ = queries[Backend.getIdentifiedDbms()].column_comment | ||
| 559 | + if hasattr(_, "query"): | ||
| 560 | + if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2): | ||
| 561 | + query = _.query % (unsafeSQLIdentificatorNaming(conf.db.upper()), unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(name.upper())) | ||
| 562 | + else: | ||
| 563 | + query = _.query % (unsafeSQLIdentificatorNaming(conf.db), unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(name)) | ||
| 564 | + comment = unArrayizeValue(inject.getValue(query, blind=False, time=False)) | ||
| 565 | + else: | ||
| 566 | + warnMsg = "on %s it is not " % Backend.getIdentifiedDbms() | ||
| 567 | + warnMsg += "possible to get column comments" | ||
| 568 | + singleTimeWarnMessage(warnMsg) | ||
| 569 | + | ||
| 557 | 570 | if len(columnData) == 1: | |
| 558 | 571 | columns[name] = None | |
| 559 | 572 | else: | |
@@ -666,6 +679,19 @@ def getColumns(self, onlyColNames=False, colTuple=None, bruteForce=None): | |||
| 666 | 679 | column = unArrayizeValue(inject.getValue(query, union=False, error=False)) | |
| 667 | 680 | ||
| 668 | 681 | if not isNoneValue(column): | |
| 682 | + if conf.getComments: | ||
| 683 | + _ = queries[Backend.getIdentifiedDbms()].column_comment | ||
| 684 | + if hasattr(_, "query"): | ||
| 685 | + if Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2): | ||
| 686 | + query = _.query % (unsafeSQLIdentificatorNaming(conf.db.upper()), unsafeSQLIdentificatorNaming(tbl.upper()), unsafeSQLIdentificatorNaming(column.upper())) | ||
| 687 | + else: | ||
| 688 | + query = _.query % (unsafeSQLIdentificatorNaming(conf.db), unsafeSQLIdentificatorNaming(tbl), unsafeSQLIdentificatorNaming(column)) | ||
| 689 | + comment = unArrayizeValue(inject.getValue(query, union=False, error=False)) | ||
| 690 | + else: | ||
| 691 | + warnMsg = "on %s it is not " % Backend.getIdentifiedDbms() | ||
| 692 | + warnMsg += "possible to get column comments" | ||
| 693 | + singleTimeWarnMessage(warnMsg) | ||
| 694 | + | ||
| 669 | 695 | if not onlyColNames: | |
| 670 | 696 | if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL): | |
| 671 | 697 | query = rootQuery.blind.query2 % (unsafeSQLIdentificatorNaming(tbl), column, unsafeSQLIdentificatorNaming(conf.db)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -429,6 +429,10 @@ dumpAll = False | |||
| 429 | 429 | # Valid: True or False | |
| 430 | 430 | search = False | |
| 431 | 431 | ||
| 432 | + # Retrieve back-end database management system comments. | ||
| 433 | + # Valid: True or False | ||
| 434 | + getComments = False | ||
| 435 | + | ||
| 432 | 436 | # Back-end database management system database to enumerate. | |
| 433 | 437 | db = | |
| 434 | 438 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -240,9 +240,9 @@ | |||
| 240 | 240 | NOTE: in Oracle to check if the session user is DBA you can use: | |
| 241 | 241 | SELECT USERENV('ISDBA') FROM DUAL | |
| 242 | 242 | --> | |
| 243 | - <hostname query="SELECT UTL_INADDR.get_host_name FROM DUAL"/> | ||
| 244 | - <table_comment query="SELECT comments FROM user_tab_comments WHERE table_name='%s'"/> | ||
| 245 | - <column_comment query="SELECT comments FROM user_col_comments WHERE table_name='%s' AND column_name='%s'"/> | ||
| 243 | + <hostname query="SELECT UTL_INADDR.GET_HOST_NAME FROM DUAL"/> | ||
| 244 | + <table_comment query="SELECT COMMENTS FROM ALL_TAB_COMMENTS WHERE OWNER='%s' AND TABLE_NAME='%s'"/> | ||
| 245 | + <column_comment query="SELECT COMMENTS FROM ALL_COL_COMMENTS WHERE OWNER='%s' AND TABLE_NAME='%s' AND COLUMN_NAME='%s'"/> | ||
| 246 | 246 | <is_dba query="(SELECT GRANTED_ROLE FROM DBA_ROLE_PRIVS WHERE GRANTEE=USER AND GRANTED_ROLE='DBA')='DBA'"/> | |
| 247 | 247 | <users> | |
| 248 | 248 | <inband query="SELECT USERNAME FROM SYS.ALL_USERS"/> | |
@@ -324,6 +324,8 @@ | |||
| 324 | 324 | <current_user/> | |
| 325 | 325 | <current_db/> | |
| 326 | 326 | <hostname/> | |
| 327 | + <table_comment/> | ||
| 328 | + <column_comment/> | ||
| 327 | 329 | <is_dba/> | |
| 328 | 330 | <check_udf/> | |
| 329 | 331 | <users/> | |
@@ -374,6 +376,8 @@ | |||
| 374 | 376 | <current_user/> | |
| 375 | 377 | <current_db/> | |
| 376 | 378 | <hostname/> | |
| 379 | + <table_comment/> | ||
| 380 | + <column_comment/> | ||
| 377 | 381 | <is_dba/> | |
| 378 | 382 | <dbs/> | |
| 379 | 383 | <!--MSysObjects have no read permission by default--> | |
@@ -415,6 +419,8 @@ | |||
| 415 | 419 | <current_user query="SELECT CURRENT_USER FROM RDB$DATABASE"/> | |
| 416 | 420 | <current_db query="SELECT RDB$GET_CONTEXT('SYSTEM','DB_NAME') FROM RDB$DATABASE"/> | |
| 417 | 421 | <hostname/> | |
| 422 | + <table_comment/> | ||
| 423 | + <column_comment/> | ||
| 418 | 424 | <is_dba query="CURRENT_USER='SYSDBA'"/> | |
| 419 | 425 | <users> | |
| 420 | 426 | <inband query="SELECT RDB$USER FROM RDB$USER_PRIVILEGES"/> | |
@@ -471,6 +477,8 @@ | |||
| 471 | 477 | <current_user query="SELECT USER() FROM DUAL"/> | |
| 472 | 478 | <current_db query="SELECT DATABASE() FROM DUAL"/> | |
| 473 | 479 | <hostname/> | |
| 480 | + <table_comment/> | ||
| 481 | + <column_comment/> | ||
| 474 | 482 | <is_dba/> | |
| 475 | 483 | <users> | |
| 476 | 484 | <inband query="SELECT username FROM domain.users"/> | |
@@ -521,6 +529,8 @@ | |||
| 521 | 529 | <current_user query="SELECT SUSER_NAME()"/> | |
| 522 | 530 | <current_db query="SELECT DB_NAME()"/> | |
| 523 | 531 | <hostname/> | |
| 532 | + <table_comment/> | ||
| 533 | + <column_comment/> | ||
| 524 | 534 | <is_dba query="PATINDEX('%sa_role%',SHOW_ROLE())>0" query2="EXISTS(SELECT * FROM master..syslogins,master..sysloginroles WHERE srid=0 and name='%s')"/> | |
| 525 | 535 | <users> | |
| 526 | 536 | <inband query="SELECT name FROM master..syslogins"/> | |
@@ -592,6 +602,8 @@ | |||
| 592 | 602 | <!-- NOTE: On DB2 we use the current user as default schema (database) --> | |
| 593 | 603 | <current_db query="SELECT current server FROM SYSIBM.SYSDUMMY1"/> | |
| 594 | 604 | <hostname query="SELECT host_name FROM TABLE(sysproc.env_get_sys_info())"/> | |
| 605 | + <table_comment/> | ||
| 606 | + <column_comment/> | ||
| 595 | 607 | <is_dba query="(SELECT dbadmauth FROM syscat.dbauth WHERE grantee=current user)='Y'"/> | |
| 596 | 608 | <users> | |
| 597 | 609 | <inband query="SELECT grantee FROM sysibm.sysdbauth WHERE grantee!='SYSTEM' AND grantee!='PUBLIC'"/> | |
@@ -657,6 +669,8 @@ | |||
| 657 | 669 | <current_user query="CURRENT_USER"/> | |
| 658 | 670 | <current_db query="DATABASE()"/> | |
| 659 | 671 | <hostname/> | |
| 672 | + <table_comment/> | ||
| 673 | + <column_comment/> | ||
| 660 | 674 | <is_dba query="SELECT ADMIN FROM INFORMATION_SCHEMA.SYSTEM_USERS WHERE USER=CURRENT_USER"/> | |
| 661 | 675 | <check_udf/> | |
| 662 | 676 | <users> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments