Issue with creation of custom rules for Oracle SQL and PL/SQL scipts

103 views
Skip to first unread message

timo.ha...@gmail.com

unread,
Feb 1, 2018, 9:50:29 AM2/1/18
to SonarQube
Hello,

I have the following issue with SonarPLSQL plugin.

---

###### What version of SonarQube are you using?

SonarQube 6.7.1

SonarQube Scanner 3.0.3

Code Analyzer for PL/SQL

3.2 (build 1753)installed

SSLR Toolkit: PL/SQL sslr-plsql-toolkit-3.2.0.1753.jar

 

###### What database are you using (type & version)?

 

Oracle database 12.2.0.1.0

 

###### What operating system are you using?

 

Oracle Linux 7.3 (database host)

 

Windows 10 EE (SonarQube/SonarScanner installation)

 

###### What did you do?


Creating custom rules with XPath 1.0 for PL/SQL as per:

https://docs.sonarqube.org/display/DEV/Adding+Coding+Rules+using+XPath

 

Case 1: Using SSLR Toolkit to validate that compression is used in "create table" statement.

 

Normal case (without compression)

 

create table PERSON (

    ID int not null,

    NAME varchar(100) not null

);

 

-> This works fine: AST is generated correctly and custom rules can be used easily.

 

Table with compression:

create table PERSON (

    ID int not null,

    NAME varchar(100) not null

)

TABLESPACE MYTABLESPACE LOGGING ROW STORE COMPRESS ADVANCED;

 

-> This does not work: AST is not generated correctly

 

Case 2: Using SSLR Toolkit to validate that encryption is used in "create tablespace" statement.

 

Statement:

CREATE BIGFILE TABLESPACE MYTABLESPACE

LOGGING ENCRYPTION USING 'AES256' ONLINE DEFAULT NOCOMPRESS STORAGE ( ENCRYPT )

EXTENT MANAGEMENT LOCAL AUTOALLOCATE FLASHBACK ON ;

 

-> This does not work: AST is not generated correctly

 

###### What did you expect to see?

 

AST generated correctly so that I can use XPath expressions to build my custom rules

 

###### What did you see instead?

 

AST generated incorrectly. Custom rules are hard to implement.

 

---

Would you have any idea how to solve this?

BR,
Timo

alban....@sonarsource.com

unread,
Feb 2, 2018, 3:05:28 AM2/2/18
to SonarQube
Hi Timo,

The SQL grammar is not covered at 100%. It's often driven by needs coming from checks. For example, that's why CREATE TABLESPACE is not structured in the AST. There was no needs so it's not described in our SQL grammar and we have a recovery mechanism to continue on the next statement. I created the following tickets, and you will depend on them to implement your custom rules:

Regards,
Alban

timo.ha...@gmail.com

unread,
Feb 2, 2018, 3:40:44 AM2/2/18
to SonarQube
Ok, thank you Alban.

BR,
Timo
Reply all
Reply to author
Forward
0 new messages