@@ -103,12 +103,7 @@ private predicate posixSystemInfo(FunctionCall source, Element use) {
103103 // - various filesystem parameters
104104 // int uname(struct utsname *buf)
105105 // - OS name and version
106- (
107- source .getTarget ( ) .hasName ( "confstr" ) or
108- source .getTarget ( ) .hasName ( "statvfs" ) or
109- source .getTarget ( ) .hasName ( "fstatvfs" ) or
110- source .getTarget ( ) .hasName ( "uname" )
111- ) and
106+ source .getTarget ( ) .hasName ( [ "confstr" , "statvfs" , "fstatvfs" , "uname" ] ) and
112107 use = source .getArgument ( 1 )
113108}
114109
@@ -128,14 +123,9 @@ private predicate posixPWInfo(FunctionCall source, Element use) {
128123 // struct group *getgrnam(const char *name);
129124 // struct group *getgrgid(gid_t);
130125 // struct group *getgrent(void);
131- (
132- source .getTarget ( ) .hasName ( "getpwnam" ) or
133- source .getTarget ( ) .hasName ( "getpwuid" ) or
134- source .getTarget ( ) .hasName ( "getpwent" ) or
135- source .getTarget ( ) .hasName ( "getgrnam" ) or
136- source .getTarget ( ) .hasName ( "getgrgid" ) or
137- source .getTarget ( ) .hasName ( "getgrent" )
138- ) and
126+ source
127+ .getTarget ( )
128+ .hasName ( [ "getpwnam" , "getpwuid" , "getpwent" , "getgrnam" , "getgrgid" , "getgrent" ] ) and
139129 use = source
140130 or
141131 // int getpwnam_r(const char *name, struct passwd *pwd,
@@ -146,31 +136,15 @@ private predicate posixPWInfo(FunctionCall source, Element use) {
146136 // char *buf, size_t buflen, struct group **result);
147137 // int getgrnam_r(const char *name, struct group *grp,
148138 // char *buf, size_t buflen, struct group **result);
149- (
150- source .getTarget ( ) .hasName ( "getpwnam_r" ) or
151- source .getTarget ( ) .hasName ( "getpwuid_r" ) or
152- source .getTarget ( ) .hasName ( "getgrgid_r" ) or
153- source .getTarget ( ) .hasName ( "getgrnam_r" )
154- ) and
155- (
156- use = source .getArgument ( 1 ) or
157- use = source .getArgument ( 2 ) or
158- use = source .getArgument ( 4 )
159- )
139+ source .getTarget ( ) .hasName ( [ "getpwnam_r" , "getpwuid_r" , "getgrgid_r" , "getgrnam_r" ] ) and
140+ use = source .getArgument ( [ 1 , 2 , 4 ] )
160141 or
161142 // int getpwent_r(struct passwd *pwd, char *buffer, size_t bufsize,
162143 // struct passwd **result);
163144 // int getgrent_r(struct group *gbuf, char *buf,
164145 // size_t buflen, struct group **gbufp);
165- (
166- source .getTarget ( ) .hasName ( "getpwent_r" ) or
167- source .getTarget ( ) .hasName ( "getgrent_r" )
168- ) and
169- (
170- use = source .getArgument ( 0 ) or
171- use = source .getArgument ( 1 ) or
172- use = source .getArgument ( 3 )
173- )
146+ source .getTarget ( ) .hasName ( [ "getpwent_r" , "getgrent_r" ] ) and
147+ use = source .getArgument ( [ 0 , 1 , 3 ] )
174148}
175149
176150/**
@@ -190,13 +164,11 @@ private predicate windowsSystemInfo(FunctionCall source, Element use) {
190164 // BOOL WINAPI GetVersionEx(_Inout_ LPOSVERSIONINFO lpVersionInfo);
191165 // void WINAPI GetSystemInfo(_Out_ LPSYSTEM_INFO lpSystemInfo);
192166 // void WINAPI GetNativeSystemInfo(_Out_ LPSYSTEM_INFO lpSystemInfo);
193- (
194- source .getTarget ( ) .hasGlobalName ( "GetVersionEx" ) or
195- source .getTarget ( ) .hasGlobalName ( "GetVersionExA" ) or
196- source .getTarget ( ) .hasGlobalName ( "GetVersionExW" ) or
197- source .getTarget ( ) .hasGlobalName ( "GetSystemInfo" ) or
198- source .getTarget ( ) .hasGlobalName ( "GetNativeSystemInfo" )
199- ) and
167+ source
168+ .getTarget ( )
169+ .hasGlobalName ( [
170+ "GetVersionEx" , "GetVersionExA" , "GetVersionExW" , "GetSystemInfo" , "GetNativeSystemInfo"
171+ ] ) and
200172 use = source .getArgument ( 0 )
201173}
202174
@@ -216,11 +188,11 @@ private predicate windowsFolderPath(FunctionCall source, Element use) {
216188 // _In_ int csidl,
217189 // _In_ BOOL fCreate
218190 // );
219- (
220- source .getTarget ( ) . hasGlobalName ( "SHGetSpecialFolderPath" ) or
221- source . getTarget ( ) . hasGlobalName ( "SHGetSpecialFolderPathA" ) or
222- source . getTarget ( ) . hasGlobalName ( " SHGetSpecialFolderPathW")
223- ) and
191+ source
192+ .getTarget ( )
193+ . hasGlobalName ( [
194+ "SHGetSpecialFolderPath" , "SHGetSpecialFolderPathA" , " SHGetSpecialFolderPathW"
195+ ] ) and
224196 use = source .getArgument ( 1 )
225197 or
226198 // HRESULT SHGetKnownFolderPath(
@@ -239,11 +211,7 @@ private predicate windowsFolderPath(FunctionCall source, Element use) {
239211 // _In_ DWORD dwFlags,
240212 // _Out_ LPTSTR pszPath
241213 // );
242- (
243- source .getTarget ( ) .hasGlobalName ( "SHGetFolderPath" ) or
244- source .getTarget ( ) .hasGlobalName ( "SHGetFolderPathA" ) or
245- source .getTarget ( ) .hasGlobalName ( "SHGetFolderPathW" )
246- ) and
214+ source .getTarget ( ) .hasGlobalName ( [ "SHGetFolderPath" , "SHGetFolderPathA" , "SHGetFolderPathW" ] ) and
247215 use = source .getArgument ( 4 )
248216 or
249217 // HRESULT SHGetFolderPathAndSubDir(
@@ -254,11 +222,11 @@ private predicate windowsFolderPath(FunctionCall source, Element use) {
254222 // _In_ LPCTSTR pszSubDir,
255223 // _Out_ LPTSTR pszPath
256224 // );
257- (
258- source .getTarget ( ) . hasGlobalName ( "SHGetFolderPathAndSubDir" ) or
259- source . getTarget ( ) . hasGlobalName ( "SHGetFolderPathAndSubDirA" ) or
260- source . getTarget ( ) . hasGlobalName ( " SHGetFolderPathAndSubDirW")
261- ) and
225+ source
226+ .getTarget ( )
227+ . hasGlobalName ( [
228+ "SHGetFolderPathAndSubDir" , "SHGetFolderPathAndSubDirA" , " SHGetFolderPathAndSubDirW"
229+ ] ) and
262230 use = source .getArgument ( 5 )
263231}
264232
@@ -273,11 +241,7 @@ class WindowsFolderPath extends SystemData {
273241}
274242
275243private predicate logonUser ( FunctionCall source , VariableAccess use ) {
276- (
277- source .getTarget ( ) .hasGlobalName ( "LogonUser" ) or
278- source .getTarget ( ) .hasGlobalName ( "LogonUserW" ) or
279- source .getTarget ( ) .hasGlobalName ( "LogonUserA" )
280- ) and
244+ source .getTarget ( ) .hasGlobalName ( [ "LogonUser" , "LogonUserW" , "LogonUserA" ] ) and
281245 use = source .getAnArgument ( )
282246}
283247
@@ -297,11 +261,7 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
297261 // _Out_opt_ LPTSTR lpValue,
298262 // _Inout_opt_ PLONG lpcbValue
299263 // );
300- (
301- source .getTarget ( ) .hasGlobalName ( "RegQueryValue" ) or
302- source .getTarget ( ) .hasGlobalName ( "RegQueryValueA" ) or
303- source .getTarget ( ) .hasGlobalName ( "RegQueryValueW" )
304- ) and
264+ source .getTarget ( ) .hasGlobalName ( [ "RegQueryValue" , "RegQueryValueA" , "RegQueryValueW" ] ) and
305265 use = source .getArgument ( 2 )
306266 or
307267 // LONG WINAPI RegQueryMultipleValues(
@@ -311,11 +271,11 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
311271 // _Out_opt_ LPTSTR lpValueBuf,
312272 // _Inout_opt_ LPDWORD ldwTotsize
313273 // );
314- (
315- source .getTarget ( ) . hasGlobalName ( "RegQueryMultipleValues" ) or
316- source . getTarget ( ) . hasGlobalName ( "RegQueryMultipleValuesA" ) or
317- source . getTarget ( ) . hasGlobalName ( " RegQueryMultipleValuesW")
318- ) and
274+ source
275+ .getTarget ( )
276+ . hasGlobalName ( [
277+ "RegQueryMultipleValues" , "RegQueryMultipleValuesA" , " RegQueryMultipleValuesW"
278+ ] ) and
319279 use = source .getArgument ( 3 )
320280 or
321281 // LONG WINAPI RegQueryValueEx(
@@ -326,11 +286,7 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
326286 // _Out_opt_ LPBYTE lpData,
327287 // _Inout_opt_ LPDWORD lpcbData
328288 // );
329- (
330- source .getTarget ( ) .hasGlobalName ( "RegQueryValueEx" ) or
331- source .getTarget ( ) .hasGlobalName ( "RegQueryValueExA" ) or
332- source .getTarget ( ) .hasGlobalName ( "RegQueryValueExW" )
333- ) and
289+ source .getTarget ( ) .hasGlobalName ( [ "RegQueryValueEx" , "RegQueryValueExA" , "RegQueryValueExW" ] ) and
334290 use = source .getArgument ( 4 )
335291 or
336292 // LONG WINAPI RegGetValue(
@@ -342,11 +298,7 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
342298 // _Out_opt_ PVOID pvData,
343299 // _Inout_opt_ LPDWORD pcbData
344300 // );
345- (
346- source .getTarget ( ) .hasGlobalName ( "RegGetValue" ) or
347- source .getTarget ( ) .hasGlobalName ( "RegGetValueA" ) or
348- source .getTarget ( ) .hasGlobalName ( "RegGetValueW" )
349- ) and
301+ source .getTarget ( ) .hasGlobalName ( [ "RegGetValue" , "RegGetValueA" , "RegGetValueW" ] ) and
350302 use = source .getArgument ( 5 )
351303}
352304
@@ -408,12 +360,7 @@ private predicate socketOutput(FunctionCall call, Expr data) {
408360 // const struct sockaddr *dest_addr, socklen_t addrlen);
409361 // ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
410362 // int write(int handle, void *buffer, int nbyte);
411- (
412- call .getTarget ( ) .hasGlobalName ( "send" ) or
413- call .getTarget ( ) .hasGlobalName ( "sendto" ) or
414- call .getTarget ( ) .hasGlobalName ( "sendmsg" ) or
415- call .getTarget ( ) .hasGlobalName ( "write" )
416- ) and
363+ call .getTarget ( ) .hasGlobalName ( [ "send" , "sendto" , "sendmsg" , "write" ] ) and
417364 data = call .getArgument ( 1 ) and
418365 socketFileDescriptor ( call .getArgument ( 0 ) )
419366 )
0 commit comments