@@ -103,12 +103,7 @@ private predicate posixSystemInfo(FunctionCall source, Element use) {
103
103
// - various filesystem parameters
104
104
// int uname(struct utsname *buf)
105
105
// - 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
112
107
use = source .getArgument ( 1 )
113
108
}
114
109
@@ -128,14 +123,9 @@ private predicate posixPWInfo(FunctionCall source, Element use) {
128
123
// struct group *getgrnam(const char *name);
129
124
// struct group *getgrgid(gid_t);
130
125
// 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
139
129
use = source
140
130
or
141
131
// int getpwnam_r(const char *name, struct passwd *pwd,
@@ -146,31 +136,15 @@ private predicate posixPWInfo(FunctionCall source, Element use) {
146
136
// char *buf, size_t buflen, struct group **result);
147
137
// int getgrnam_r(const char *name, struct group *grp,
148
138
// 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 ] )
160
141
or
161
142
// int getpwent_r(struct passwd *pwd, char *buffer, size_t bufsize,
162
143
// struct passwd **result);
163
144
// int getgrent_r(struct group *gbuf, char *buf,
164
145
// 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 ] )
174
148
}
175
149
176
150
/**
@@ -190,13 +164,11 @@ private predicate windowsSystemInfo(FunctionCall source, Element use) {
190
164
// BOOL WINAPI GetVersionEx(_Inout_ LPOSVERSIONINFO lpVersionInfo);
191
165
// void WINAPI GetSystemInfo(_Out_ LPSYSTEM_INFO lpSystemInfo);
192
166
// 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
200
172
use = source .getArgument ( 0 )
201
173
}
202
174
@@ -216,11 +188,11 @@ private predicate windowsFolderPath(FunctionCall source, Element use) {
216
188
// _In_ int csidl,
217
189
// _In_ BOOL fCreate
218
190
// );
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
224
196
use = source .getArgument ( 1 )
225
197
or
226
198
// HRESULT SHGetKnownFolderPath(
@@ -239,11 +211,7 @@ private predicate windowsFolderPath(FunctionCall source, Element use) {
239
211
// _In_ DWORD dwFlags,
240
212
// _Out_ LPTSTR pszPath
241
213
// );
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
247
215
use = source .getArgument ( 4 )
248
216
or
249
217
// HRESULT SHGetFolderPathAndSubDir(
@@ -254,11 +222,11 @@ private predicate windowsFolderPath(FunctionCall source, Element use) {
254
222
// _In_ LPCTSTR pszSubDir,
255
223
// _Out_ LPTSTR pszPath
256
224
// );
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
262
230
use = source .getArgument ( 5 )
263
231
}
264
232
@@ -273,11 +241,7 @@ class WindowsFolderPath extends SystemData {
273
241
}
274
242
275
243
private 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
281
245
use = source .getAnArgument ( )
282
246
}
283
247
@@ -297,11 +261,7 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
297
261
// _Out_opt_ LPTSTR lpValue,
298
262
// _Inout_opt_ PLONG lpcbValue
299
263
// );
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
305
265
use = source .getArgument ( 2 )
306
266
or
307
267
// LONG WINAPI RegQueryMultipleValues(
@@ -311,11 +271,11 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
311
271
// _Out_opt_ LPTSTR lpValueBuf,
312
272
// _Inout_opt_ LPDWORD ldwTotsize
313
273
// );
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
319
279
use = source .getArgument ( 3 )
320
280
or
321
281
// LONG WINAPI RegQueryValueEx(
@@ -326,11 +286,7 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
326
286
// _Out_opt_ LPBYTE lpData,
327
287
// _Inout_opt_ LPDWORD lpcbData
328
288
// );
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
334
290
use = source .getArgument ( 4 )
335
291
or
336
292
// LONG WINAPI RegGetValue(
@@ -342,11 +298,7 @@ private predicate regQuery(FunctionCall source, VariableAccess use) {
342
298
// _Out_opt_ PVOID pvData,
343
299
// _Inout_opt_ LPDWORD pcbData
344
300
// );
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
350
302
use = source .getArgument ( 5 )
351
303
}
352
304
@@ -408,12 +360,7 @@ private predicate socketOutput(FunctionCall call, Expr data) {
408
360
// const struct sockaddr *dest_addr, socklen_t addrlen);
409
361
// ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
410
362
// 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
417
364
data = call .getArgument ( 1 ) and
418
365
socketFileDescriptor ( call .getArgument ( 0 ) )
419
366
)
0 commit comments