rspec/rules/S4972/swift/rule.adoc

44 lines
782 B
Plaintext
Raw Normal View History

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.
== Noncompliant Code Example
----
public class Parent {
protected void foo() {
//...
}
}
public class Child extends Parent {
public void foo() { // Noncompliant
// ...
super.foo();
}
}
----
== Compliant Solution
----
public class Parent {
protected void foo() {
//...
}
}
public class Child extends Parent {
protected void foo() {
// ...
super.foo();
}
}
----
== See
* https://wiki.sei.cmu.edu/confluence/x/3TVGBQ[CERT, MET04-J.] - Do not increase the accessibility of overridden or hidden methods