Weblog
More Cecil/Dot graphs
I did more Cecil/Dot hacking this weekend. The previous graphs has given me good ideas of how some user code could exploit some critical methods. It even shows some of the security checks, the declarative security attributes, on the methods (called before entering the method). But this picture is missing a lot of details, like any security checks done inside the methods (i.e. the imperative security checks).
|
A good example is when access to a file or an environment variable is required.
The name of the resource isn't known until runtime (at least from the framework point of view) so declarative security cannot be used.
This graphic shows the calls made to Note #1: The graphic shows public types/methods in blue. Bold is used on static methods. Note #2: Actually the previous graphic also show another problem. The static constructor (.cctor) of the
Ok, Back to the main issue... we expect to see a CAS permission demand in
| ![]() |
Note #3: Extracting the IL code with Cecil is very simple. See Jean-Baptiste Evain's sample code.
So this time I wanted to add graphs of the IL code, i.e. generate dot files from the previous IL. This is very similar to what other people have been doing. However my version as some security enhancements (well that's the whole point of it ;-). For example I mark some calls to the security runtime in red and display interal calls with "double lines". It's simple but effective as it makes it easy to see if (and where) some code can bypass a security check inside a method.
Now looking at the same IL code as a colored graph makes it perfectly clear.
If the security manager is enabled (first red box) then an EnvironmentPermission
instance is created with the variable name and a Demand (second red box) is made prior to returning
the value.
My only problem is that dot-ing IL can generate very big bitmaps (this one being small). They compress well on disk but their RAM requirements can be very high to display. I'll need to look at dot's options to see if I can squeeze them a little without loosing readability.
I still have many ideas to visualize code using Cecil and Dot but I think it's about time I put some Gtk# GUI on top of this...
4/18/2005 11:09:30 | Comments
The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.

