I'm still new and learning the way to write checkers for static clang analyzer. I need to do the checker on Linux based, and I've read a lot of materials from blogs and websites, but almost all of them are based on Xcode, and none of them are telling me how to search a specific system call.
I'm trying to write a checker on Linux which can tell users that the system call they are using is dangerous, and showing the reason why it may be leak.
Could anyone tell me if it is possible to do this kind of checker? And if it could be made, how should I do or where can I find these materials to do it?
This guide, How to write a Checker in 24 hours is pretty informative and includes an example of identifying calls to fopen around the 34th slide. I highly recommend looking at it yourself but I'll try and summarize the most relevant parts to get you started.
Each checker registers callback functions that are called to check certain properties. In your case your checker will make use of a call event function:
void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
This member function on your checker will get called every time the static analyzer engine comes across a call event. You simply need to define your function to check if the call event is to the system call your are checking for. In the linked example they are looking for calls to fopen and so the beginning of their checkPostCall function looks something like this:
if(Call.isGlobalCFunction("fopen"))
//do stuff
Hopefully that's enough to help get your started!
Related
Recently i caught with the a thought of changing the implementation of method after deployment
When i googled about objective c runtime and all, came to know about method swizzling methodExchangeImplementations etc.
I know that it could be possible by https://rollout.io/
But my thought is how to do Hot Patching by myself for simple things.
my idea is injecting the code using webservice call.
Webservice should give a replacement for particular method.
That string has to be converted to executable code
What i want to know is ...
How to inject the code in existing method of enterprise application.
For ex:
Consider this method in objective c
-(void)fetchTheResult{
// some code lines
}
After deployment i would like to change the method implementation to
-(void)fetchTheresult{
NSLog(#"test log");
//some Code lines
//some more lines
}
Please guide me the way to achieve this
This is a big question and you've some research to do to figure out an answer. Here as some things you can look into:
First you've referenced Rollout, you could follow the same idea and send your update as JavaScript. You'll need to study how to call JavaScript, swizzle methods, and probably dynamically add methods - more on that in a moment.
An alternative you can investigate is dynamic library loading - you can open, and call code in, a library which your app loads at runtime. So you could look at sending your update as a library. You'll still need to do method swizzling and probably dynamically add methods...
As well as method swizzling you may find you need to dynamically add methods - e.g. so you have something to swap the existing implementation to. A good place to find out how to do that is Mike Ash's writings on KVO - go DuckDuckGo (or Google)
HTH
It is not as easy as you think, at least in Objective C and other similar compiled languages. This kind of runtime changes to the code is only possible in interpreted languages like Javascript.
The basic problem is, the apps are not allowed to change the executable files themselves. The apps on iOS and Android run in a sandboxed environment, and thus have access to limited disk locations only.
Also, after compiling the code, the code does not know where the part of code is converted and stored in machine language. You have to understand the basics of compilers to understand this. There are heavy optimisations happening to your code during this process.
So without the context, I have a method that returns a table.
Trying to print it out, it seems that the table mainly contains methods to be called.
However not being very knowledgeable in LUA, i have no idea how to properly get some information about these methods i should call.
I tried to get documentation from the creator of the thing, but there is none as far as i know. And since this is inside computercraft (minecraft mod) i don't have a lot of features to rely on either.
So knowing only that it is a table with methods that i can call, how do i properly figure out how to call them, and with what parameters etc. ?
Generally speaking, modules/ libraries always come with docs, or a method to print the docs.
But if this is not the case, here's what you can do:
You can print everything in the table! This is a must, the names of the methods can be very useful
You can seek out help! Find people who have used the same module, and ask them how it works. Why solve something others have already figured out?
Use debug.getinfo and other hacky functions for the debug library! They can provide more info than anything else in the Lua standard libraries!
C-Side coding can reveal what Lua cannot! If you have access to the C-Side you can see exactly what the code is doing (or at least I think so)
Check out the source code! This shows you what the code does and how it does it
And above all else, experiment! Try the methods on different parameters, different values, and identify what it does through continuous testing!
Just knowing the names of the methods is not enough to figure how to call them.
Their names may be a clue, but there is no guarantee.
If the methods are written in Lua, you could use the debug API to discover the names of parameters, which again may just be an indication of how to call the methods.
Bottom line: you need documentation or example code.
I knew this existed, didn't know how it worked. So for future reference:
You can dump your peripherals and methods by doing /op_dump in the minecraft chat.
This generates an XML which writes out all methods it has found in peripherals OR objects/tables.
This means that you have to call every interesting method once, which generates the table as return. And then calling /op_dump will include that newly encountered object with all information about there methods/parameters etc.
Does anyone have a list of native DreamBoard functions?
For instance: nothing, ScrollViewDidScroll (which seems to be == to 'nothing'), stop, etc.
I can't find one in the docs. Also, the "Actions" syntax is oddly reminiscent of javascript, does this mean there's a setTimeout or wait equivalent? Please excuse the poor tagging. If you need me to be more detailed or specific, just ask.
I'd like to make a simple Erlang console game. I need to control my "car" in that game by key strokes - key up or W key. Is there any way to do that? I read that wx library has such capability but I'm looking for something simple and in my opinion wx library is overkill. I want to grab an event not the character from stdin.
EDIT:
Ok, I've choosen ncurses and cecho as a Erlang library for that.
I know only 2 way to do this: gs and wx.
gs is a bit simpler but the first line of the documentation is a warning telling that gs is not recommended for new application, use wx instead :o)
wx isn't so complex, but its documentation is really poor, and simply refers to wxWidget one. at least there are some demo (demo, sudoku, xrc...) that helps to start to build something. And once you succeed to have your first panels and sizers working, it is really simple to get the key stroke or mouse events an react on them. My main difficulty was in displaying graphical things fast and smooth enough even if at the end it is only a few lines of code (a few 10s).
finally, the erlang console is meant to evaluate erlang expression, so there is no chance that you can capture simple event and control the display in that environment (at a reasonable effort at least).
You can try study kernel's modules group and user_drv but they both has undocumented interface and can be subject of change in any future Erlang/OPT version. You can also made your own driver or NIF to handle termios settings and make your own implementation.
BTW I would definitely stick with wx.
I am trying to build a very simple driver. Its sole purpose will be to register "PsSetCreateProcessNotifyRoutine" and on callbacks recieved from kernel, notify my Win32 application about which proccesses are started and stoped.
I only know how to build such a simple driver with "DriverEntry" and "DriverUnload" and compile it with DDK. But I don't know how to actually implement communication. I know it can be done with IOCTL. But beyond that I am in the dark. I cannot find simple example of how to do that in Delphi. I only know it can be done.
So what I am looking for is some simple and understandable tutorial on how to do it or event better an example delphi program with acompaniying driver code. Maybe there are even other ways of communication.
Any help would be appriciated.
Doesn't matter if in Delphi or not. You have to use the function DeviceIoControl. Read the article in MSDN about it.
In short, you'll have to choose some IOCTL codes from the available set. Then you call DeviceIoControl with one of these codes and pass some data, and in driver you handle that request and return something else.
You can also handle standard IOCTLS, such as the ones generated by calling ReadFile or WriteFile in user-mode.
Don't look for a "tutorial how to do that in Delphi", just look for any tutorial. They're all the same, no matter the language, it's pure Win32/Native api stuff. Here's one for example, just googled it out.