35 lines
842 B
Plaintext
35 lines
842 B
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
[source,java]
|
|
----
|
|
public void makeItPublic(String methodName) throws NoSuchMethodException {
|
|
|
|
this.getClass().getMethod(methodName).setAccessible(true); // Noncompliant
|
|
}
|
|
|
|
public void setItAnyway(String fieldName, int value) {
|
|
this.getClass().getDeclaredField(fieldName).setInt(this, value); // Noncompliant; bypasses controls in setter
|
|
}
|
|
----
|
|
|
|
include::../resources.adoc[]
|
|
|
|
* https://wiki.sei.cmu.edu/confluence/x/_jZGBQ[CERT, SEC05-J.] - Do not use reflection to increase accessibility of classes, methods, or fields
|
|
|
|
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[]
|