Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet: emit enclosing class information for nested classes #1780

Closed
mike-hunhoff opened this issue Sep 4, 2023 · 1 comment · Fixed by #1913 or mandiant/capa-testfiles#224
Closed
Assignees
Labels
dotnet enhancement New feature or request

Comments

@mike-hunhoff
Copy link
Collaborator

mike-hunhoff commented Sep 4, 2023

capa does not emit the <namespace>.<class> of the class that encloses a nested class.

e.g when processing Settings.System::PutInt, capa emits only System::PutInt when ideally capa would emit something like Android.Provider.Settings.System::PutInt.

The suggestion of using Android.Provider.Settings.System::PutInt could be confusing though because, based on how capa currently treats namespaces + classes, this makes it appear that Android.Provider.Settings is a namespace when it is a class. Alternately, capa could take the same route as dnSpy by emitting Android.Provider.Settings/System::PutInt where / denotes a nested class signifying that Android.Provider.Settings is the enclosing class and System is the nested class.

How should capa emit features for Android.Provider.Settings/System::PutInt?

capa currently emits:

  • namespace(Android.Provider)
  • class(Android.Provider.Settings)
  • class(System)
  • import(System::PutInt)
  • api(System::PutInt)

I propose that capa emit:

  • namespace(Android.Provider)
  • class(Android.Provider.Settings)
  • class(Android.Provider.Settings/System)
  • import(Android.Provider.Settings/System::PutInt)
  • api(Android.Provider.Settings/System::PutInt)

Reading the ECMA specs, I can't find anything that states a max nesting depth for .NET types. Therefore, we should not assume a max depth when coding this new feature.

capa should handle nested classes for both locally defined (TypeDef) classes and imported (TypeRef) classes. For TypeDef classes, capa should be able to use the NestedClasses (0x29) table. For TypeRef classes, capa should be able to use the ResolutionScope index where a TypeRef is nested if its ResolutionScope index is a TypeRef index.

@mike-hunhoff mike-hunhoff added enhancement New feature or request dotnet labels Sep 4, 2023
@bkojusner
Copy link
Contributor

Working on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet enhancement New feature or request
Projects
None yet
2 participants