Now I am wondering do inner classes also need to be defined as
with sharing | without sharing | inherited sharing to pass the security review?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
According to Using the
without sharing, and
inherited sharing Keywords (emphasis mine):
- Both inner classes and outer classes can be declared as with sharing. The sharing setting applies to all code contained in the class, including initialization code, constructors, and methods.
- Inner classes do not inherit the sharing setting from their container class.
- Classes inherit this setting from a parent class when one class extends or implements another.
So yes, you need to declare sharing for each inner class as well.
Above all, you need to define sharing mode for inner classes separately, since they are separate classes in terms of inheritance.
you may use inherited sharing since winter 19 to avoid issues