Repository navigation
C++: Modify tests for an upcoming PR #22990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e6b9042
b63ce1d
f9e4a41
dd2c720
e00b975
18200b7
77f9f05
13a069f
dc46def
5f676c6
3dee9f9
60f268c
eb60024
620bdf1
e20cd3f
0854cc0
559f91e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,18 @@ | ||
| #include "../taint-tests/stl.h" | ||
| using uint16_t = unsigned short; | ||
| using int64_t = long long; | ||
| using size_t = unsigned long; | ||
| using uint8_t = unsigned char; | ||
| using int32_t = int; | ||
| using uint32_t = unsigned int; | ||
|
|
||
| namespace std | ||
| { | ||
| class string | ||
| { | ||
| public: | ||
| string(); | ||
| string(const char *); | ||
| ~string(); | ||
| }; | ||
|
|
||
| template <typename K, typename V> | ||
| class map | ||
| { | ||
| public: | ||
| map(); | ||
| ~map(); | ||
|
|
||
| V& operator[](const K& key); | ||
| }; | ||
|
|
||
| template <typename T> | ||
| class vector | ||
| { | ||
| public: | ||
| vector(); | ||
| ~vector(); | ||
|
|
||
| T& operator[](size_t); | ||
| }; | ||
|
|
||
| template<typename T> | ||
| class unique_ptr { | ||
| public: | ||
| unique_ptr(); | ||
| ~unique_ptr(); | ||
|
|
||
| T* get(); | ||
| }; | ||
| } | ||
|
|
||
| namespace Azure | ||
| { | ||
| template <typename T> | ||
| class Nullable | ||
| { | ||
| T m_value; | ||
|
|
||
| public: | ||
| Nullable(); | ||
| Nullable(const T); | ||
|
|
@@ -284,6 +247,9 @@ void test_RawResponse(Azure::Core::Http::RawResponse& resp) { | |
| } | ||
|
|
||
| void test_GetHeader() { | ||
| // We instantiate the `std::pair` class since we need the `FieldContent` for | ||
| // `std::pair::second` to be present in the test DB. | ||
| std::pair<std::string, std::string>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks weird, as it just adds a constructor call.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the commit message here: 5f676c6 Does that explain it?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it uses that somewhere under the hood, but doesn't instantiate it there?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case we need the class to be instantiated since we need a specific There are two related problems that are being solved by instantiating the The main problem is that we've stubbed the body of the So this commit adds the instantiations that were missing from the test database. In this case we need it because #22939 will model There are other places where we need the constructor to be present since #22939 will model certain insertion-like STL member functions by forwarding the container insertion arguments to the corresponding constructor, and if the constructor isn't in the DB we cannot do that. Again, this would not be a problem in a real DB since those constructors will always exist, but with our tests stubs that won't happen since we only have declarations of the insertion-like functions and not the actual bodies. Does that make sense?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. Makes sense. I see that in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 0854cc0 |
||
| Azure::Core::Http::Request request(Azure::Core::Http::Get, Azure::Core::Url("http://example.com")); | ||
| { | ||
| auto headerValue = request.GetHeader("Content-Type").Value(); | ||
|
|
@@ -294,4 +260,11 @@ void test_GetHeader() { | |
| std::string contentType = headers["Content-Type"]; | ||
| sink(contentType); // $ ir | ||
| } | ||
| } | ||
|
|
||
| void test_QueryParameters() { | ||
| Azure::Core::Http::Request request(Azure::Core::Http::Get, Azure::Core::Url("http://example.com")); | ||
| Azure::Core::Url url; | ||
| url.SetQueryParameters(request.GetHeaders()); | ||
| sink(url.GetQueryParameters()["query"]); // $ ir | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these swap over to missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's a good question. It took me some time to figure out what's going on here. I apologize for not making that clear in the commit why that is.
On
mainthestring_viewclass declaration that's imported byasio_streamsis very simplistic:codeql/cpp/ql/test/library-tests/dataflow/external-models/asio_streams.cpp
Lines 8 to 13 in 81a1deb
In 18200b7 we make the
string_viewmuch more realistic. In particular, we make the 6'th constructor from cppreference explicit. This has the effect of removing the generic taint-model we have for this constructor. So that's why we're losing the result.