mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Add tests for various local Windows dataflow sources
This commit is contained in:
@@ -124,7 +124,11 @@ module IRTest {
|
||||
|
||||
/** Common data flow configuration to be used by tests. */
|
||||
module IRTestAllocationConfig implements DataFlow::ConfigSig {
|
||||
private import semmle.code.cpp.security.FlowSources
|
||||
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source instanceof FlowSource
|
||||
or
|
||||
source.asExpr().(FunctionCall).getTarget().getName() = "source"
|
||||
or
|
||||
source.asIndirectExpr(1).(FunctionCall).getTarget().getName() = "indirect_source"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
void sink(char);
|
||||
void sink(char*);
|
||||
|
||||
int WinMain(void *hInstance, void *hPrevInstance, char *pCmdLine, int nCmdShow) { // $ ast-def=hInstance ast-def=hPrevInstance ast-def=pCmdLine ir-def=*hInstance ir-def=*hPrevInstance ir-def=*pCmdLine
|
||||
sink(pCmdLine);
|
||||
sink(*pCmdLine); // $ MISSING: ir
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
void sink(char);
|
||||
void sink(char*);
|
||||
void sink(char**);
|
||||
|
||||
char* GetCommandLineA();
|
||||
char** CommandLineToArgvA(char*, int*);
|
||||
char* GetEnvironmentStringsA();
|
||||
int GetEnvironmentVariableA(const char*, char*, int);
|
||||
|
||||
void getCommandLine() {
|
||||
char* cmd = GetCommandLineA();
|
||||
sink(cmd);
|
||||
sink(*cmd); // $ MISSING: ir
|
||||
|
||||
int argc;
|
||||
char** argv = CommandLineToArgvA(cmd, &argc);
|
||||
sink(argv);
|
||||
sink(argv[1]);
|
||||
sink(*argv[1]); // $ MISSING: ir
|
||||
}
|
||||
|
||||
void getEnvironment() {
|
||||
char* env = GetEnvironmentStringsA();
|
||||
sink(env);
|
||||
sink(*env); // $ MISSING: ir
|
||||
|
||||
char buf[1024];
|
||||
GetEnvironmentVariableA("FOO", buf, sizeof(buf));
|
||||
sink(buf);
|
||||
sink(*buf); // $ MISSING: ir
|
||||
}
|
||||
Reference in New Issue
Block a user