infer icon indicating copy to clipboard operation
infer copied to clipboard

Can I use infer static analysis to find a string?

Open LRH-iOS opened this issue 3 years ago • 5 comments

I can use infer static analysis to find

  1. Does a function exist?
  2. How many functions exist? Which class exists? For example, "sscanf", "strncpy"

LRH-iOS avatar Oct 29 '21 09:10 LRH-iOS

hello

LRH-iOS avatar Nov 01 '21 01:11 LRH-iOS

I think you're not getting much of a reply, because your question doesn't (really) make sense in the context of infer.

infer is a static analysis tool aimed at finding bugs in source code; it is not designed to find the kind of metrics you're after.

That being said, you can "abuse" infer to answer your "functions" question:

echo "select proc_uid, source_file from procedures;" | sqlite3 infer-out/results.db

You'll also see classes here, if you have methods in classes -- just using a type isn't enough for it appear in the results.db.

Types are logged to the tenv file if you run with debugging (run with -g and then look for files ending with .tenv.debug).

aytey avatar Nov 01 '21 09:11 aytey

I think you're not getting much of a reply, because your question doesn't (really) make sense in the context of infer.

infer is a static analysis tool aimed at finding bugs in source code; it is not designed to find the kind of metrics you're after.

That being said, you can "abuse" infer to answer your "functions" question:

echo "select proc_uid, source_file from procedures;" | sqlite3 infer-out/results.db

You'll also see classes here, if you have methods in classes -- just using a type isn't enough for it appear in the results.db.

Types are logged to the tenv file if you run with debugging (run with -g and then look for files ending with .tenv.debug).

I mean, in the project, I want to use infer to count the number of times a string appears and the file name where it appears. Does infer have any methods in this regard, or can I customize such statistical methods in infer?

  1. Infor is there a method to count a string?

  2. If not, can I customize this method in infer?

LRH-iOS avatar Nov 02 '21 09:11 LRH-iOS

I want [...] to count the number of times a string appears and the file name where it appears

So you want grep -c?

aytey avatar Nov 02 '21 09:11 aytey

I want [...] to count the number of times a string appears and the file name where it appears

So you want grep -c?

NO, I want to analysis xx.ipa or xx.app or xx.xcworkspace

LRH-iOS avatar Nov 02 '21 10:11 LRH-iOS