rspec/rules/S2653/java/rule.adoc

46 lines
1.5 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
There is no reason to have a ``++main++`` method in a web application. It may have been useful for debugging during application development, but such a method should never make it into production. Having a ``++main++`` method in a web application opens a door to the application logic that an attacker may never be able to reach (but watch out if one does!), but it is a sloppy practice and indicates that other problems may be present.
This rule raises an issue when a ``++main++`` method is found in a servlet or an EJB.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
if (userIsAuthorized(req)) {
updatePrices(req);
}
}
public static void main(String[] args) { // Noncompliant
updatePrices(req);
}
}
----
2021-04-28 16:49:39 +02:00
== See
* https://www.owasp.org/index.php/Top_10-2017_A3-Sensitive_Data_Exposure[OWASP Top 10 2017 Category A3] - Sensitive Data Exposure
2021-10-21 11:23:23 +02:00
* https://cwe.mitre.org/data/definitions/489.html[MITRE, CWE-489] - Active Debug Code
2021-04-28 16:49:39 +02:00
* https://wiki.sei.cmu.edu/confluence/x/qzVGBQ[CERT, ENV06-J.] - Production code must not contain debugging entry points
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]