mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
C++: Extend tests.
This commit is contained in:
@@ -7,6 +7,10 @@ edges
|
|||||||
| test.cpp:40:11:40:17 | access to array | test.cpp:11:26:11:28 | url |
|
| test.cpp:40:11:40:17 | access to array | test.cpp:11:26:11:28 | url |
|
||||||
| test.cpp:46:18:46:26 | http:// | test.cpp:49:11:49:16 | buffer |
|
| test.cpp:46:18:46:26 | http:// | test.cpp:49:11:49:16 | buffer |
|
||||||
| test.cpp:49:11:49:16 | buffer | test.cpp:11:26:11:28 | url |
|
| test.cpp:49:11:49:16 | buffer | test.cpp:11:26:11:28 | url |
|
||||||
|
| test.cpp:93:28:93:36 | http:// | test.cpp:104:11:104:13 | ptr |
|
||||||
|
| test.cpp:104:11:104:13 | ptr | test.cpp:11:26:11:28 | url |
|
||||||
|
| test.cpp:110:21:110:40 | http://example.com | test.cpp:121:11:121:13 | ptr |
|
||||||
|
| test.cpp:121:11:121:13 | ptr | test.cpp:11:26:11:28 | url |
|
||||||
nodes
|
nodes
|
||||||
| test.cpp:11:26:11:28 | url | semmle.label | url |
|
| test.cpp:11:26:11:28 | url | semmle.label | url |
|
||||||
| test.cpp:15:30:15:32 | url | semmle.label | url |
|
| test.cpp:15:30:15:32 | url | semmle.label | url |
|
||||||
@@ -17,9 +21,15 @@ nodes
|
|||||||
| test.cpp:40:11:40:17 | access to array | semmle.label | access to array |
|
| test.cpp:40:11:40:17 | access to array | semmle.label | access to array |
|
||||||
| test.cpp:46:18:46:26 | http:// | semmle.label | http:// |
|
| test.cpp:46:18:46:26 | http:// | semmle.label | http:// |
|
||||||
| test.cpp:49:11:49:16 | buffer | semmle.label | buffer |
|
| test.cpp:49:11:49:16 | buffer | semmle.label | buffer |
|
||||||
|
| test.cpp:93:28:93:36 | http:// | semmle.label | http:// |
|
||||||
|
| test.cpp:104:11:104:13 | ptr | semmle.label | ptr |
|
||||||
|
| test.cpp:110:21:110:40 | http://example.com | semmle.label | http://example.com |
|
||||||
|
| test.cpp:121:11:121:13 | ptr | semmle.label | ptr |
|
||||||
subpaths
|
subpaths
|
||||||
#select
|
#select
|
||||||
| test.cpp:28:10:28:29 | http://example.com | test.cpp:28:10:28:29 | http://example.com | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
| test.cpp:28:10:28:29 | http://example.com | test.cpp:28:10:28:29 | http://example.com | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
||||||
| test.cpp:35:23:35:42 | http://example.com | test.cpp:35:23:35:42 | http://example.com | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
| test.cpp:35:23:35:42 | http://example.com | test.cpp:35:23:35:42 | http://example.com | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
||||||
| test.cpp:36:26:36:45 | http://example.com | test.cpp:36:26:36:45 | http://example.com | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
| test.cpp:36:26:36:45 | http://example.com | test.cpp:36:26:36:45 | http://example.com | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
||||||
| test.cpp:46:18:46:26 | http:// | test.cpp:46:18:46:26 | http:// | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
| test.cpp:46:18:46:26 | http:// | test.cpp:46:18:46:26 | http:// | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
||||||
|
| test.cpp:93:28:93:36 | http:// | test.cpp:93:28:93:36 | http:// | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
||||||
|
| test.cpp:110:21:110:40 | http://example.com | test.cpp:110:21:110:40 | http://example.com | test.cpp:15:30:15:32 | url | A URL may be constructed with the HTTP protocol. |
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ void test3(char *url)
|
|||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
ptr = strstr(url, "https://");
|
ptr = strstr(url, "https://"); // GOOD (https)
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
ptr = strstr(url, "http://"); // GOOD (we are not constructing the URL)
|
ptr = strstr(url, "http://"); // GOOD (we are not constructing the URL)
|
||||||
@@ -86,3 +86,38 @@ void test3(char *url)
|
|||||||
openUrl(ptr);
|
openUrl(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test4(char *url)
|
||||||
|
{
|
||||||
|
const char *https_string = "https://"; // GOOD (https)
|
||||||
|
const char *http_string = "http://"; // GOOD (we are not constructing the URL) [FALSE POSITIVE]
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
ptr = strstr(url, https_string);
|
||||||
|
if (!ptr)
|
||||||
|
{
|
||||||
|
ptr = strstr(url, http_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
openUrl(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test5()
|
||||||
|
{
|
||||||
|
char *url_string = "http://example.com"; // BAD
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
ptr = strstr(url_string, "https://"); // GOOD (https)
|
||||||
|
if (!ptr)
|
||||||
|
{
|
||||||
|
ptr = strstr(url_string, "http://"); // GOOD (we are not constructing the URL here)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
openUrl(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user