2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-06-08 14:23:48 +02:00
``++PreparedStatement++``s and ``++CallableStatement++``s (for stored procedures) are safer and more efficient than ``++Statement++``s and should always be preferred.
This rule raises an issue each time a ``++Statement++`` is declared.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-06-08 14:23:48 +02:00
----
Statement stmt = null; // Noncompliant
// ...
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-06-08 14:23:48 +02:00
----
PreparedStatement stmt = null;
// ...
----
2023-05-03 11:06:20 +02:00
== Resources
2021-06-08 14:23:48 +02:00
2024-01-15 17:15:56 +01:00
* OWASP - https://owasp.org/Top10/A05_2021-Security_Misconfiguration/[Top 10 2021 Category A5 - Security Misconfiguration]
* CWE - https://cwe.mitre.org/data/definitions/20[CWE-20 - Improper Input Validation]
* CWE - https://cwe.mitre.org/data/definitions/89[CWE-89 - Improper Neutralization of Special Elements used in an SQL Command]
2024-01-17 17:20:28 +01:00
* OWASP - https://owasp.org/www-project-top-ten/2017/A1_2017-Injection[OWASP Top 10 2017 Category A1 - Injection]
2021-06-08 14:23:48 +02:00
ifdef::env-github,rspecator-view[]
2021-06-08 15:52:13 +02:00
'''
2021-06-08 14:23:48 +02:00
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== duplicates: S2077
=== on 1 Dec 2015, 11:14:50 Michael Gumowski wrote:
LGTM!
2021-06-08 14:23:48 +02:00
endif::env-github,rspecator-view[]