java - False positive MS_PKGPROTECT bug in FindBugs -
i pretty sure getting false positive findbugs. code following:
public class myclass { protected static string filenameprefix; }
and bug i'm getting:
field should package protected
a mutable static field changed malicious code or accident. field made package protected avoid vulnerability.
bug kind , pattern: ms - ms_pkgprotect
is false positive or i'm missing something?
the protected modifier allows 3rd party subclass elevated access field.
class myevilsubclass extends myclass { static { filenameprefix = "../" + filenameprefix; } }
findbugs pointing out 'protected' doesn't protect field public access in wild. if field package protected know intent share secret among trusted friends.
in general, hide field , create accessor methods more flexible in terms of encapsulation, thread-safety, , lazy loading.
Comments
Post a Comment