rspec/rules/S1493/cobol/rule.adoc

40 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
It is a bad practice to use Dynamic SQL. It differs from static embedded SQL in that part or all of the actual SQL commands may be stored in a host variable that is built on the fly during execution of the program. In the extreme case, the SQL commands are generated in their entirety by the application program at run time. While dynamic SQL is more flexible than static embedded SQL, it does require additional overhead and is much more difficult to understand and to maintain.
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
Moreover, dynamic SQL may expose the application to SQL injection vulnerabilities.
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
This rule raises an issue when ``++PREPARE++`` or ``++EXECUTE IMMEDIATE++`` is used.
2020-06-30 12:47:33 +02:00
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
2020-06-30 12:47:33 +02:00
----
EXEC SQL PREPARE SEL INTO :SQLDA FROM :STMTBUF END-EXEC.
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,cobol]
----
EXEC SQL SELECT * FROM tableName END-EXEC.
----
2020-06-30 12:47:33 +02:00
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Make sure dynamic SQL is required here.
endif::env-github,rspecator-view[]