2021-04-28 16:49:39 +02:00
When a method doesn't match it's ``++super++`` method in visibility (``++public++``, ``++protected++``, ...), malicious callers could take advantage of the over-broad access offered by the child class to undermine the application.
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
public class Parent {
protected void foo() {
//...
}
}
public class Child extends Parent {
public void foo() { // Noncompliant
// ...
super.foo();
}
}
----
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
public class Parent {
protected void foo() {
//...
}
}
public class Child extends Parent {
protected void foo() {
// ...
super.foo();
}
}
----
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== See
* https://wiki.sei.cmu.edu/confluence/x/3TVGBQ[CERT, MET04-J.] - Do not increase the accessibility of overridden or hidden methods
2021-04-28 18:08:03 +02:00
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]