Now I am wondering do inner classes also need to be defined as
with sharing | without sharing | inherited sharing to pass the security review?
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