Skip to content
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

Fix code scanning alert #1530

Merged
merged 8 commits into from
Aug 3, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/test/http/curl_http_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ TEST_F(BasicCurlHttpTests, SendGetRequestSyncTimeout)
curl::HttpClientSync http_client;

http_client::Headers m1 = {};
auto result = http_client.Get("http://222.222.222.200:19000/get/", m1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why is the IP address changed? I think it is intended as some invalid/unreachable address. @lalitb

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this address is invalid either

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some local app could listen on https://127.0.0.1:19000?

Copy link
Member

@lalitb lalitb Jul 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also use the address from Documentation Address Block (https://datatracker.ietf.org/doc/html/rfc5737#section-4), as they are not allowed to be used on the public internet, and so would be always unreachable.

192.0.2.0 – 192.0.2.255
198.51.100.0 – 198.51.100.255
233.252.0.0 - 233.252.0.255

auto result = http_client.Get("https://192.0.2.0:19000/get/", m1);
EXPECT_EQ(result, false);

// When network is under proxy, it may connect success but closed by peer when send data
Expand Down Expand Up @@ -415,7 +415,7 @@ TEST_F(BasicCurlHttpTests, SendGetRequestAsyncTimeout)
std::shared_ptr<GetEventHandler> handlers[batch_count];
for (unsigned i = 0; i < batch_count; ++i)
{
sessions[i] = http_client.CreateSession("http://222.222.222.200:19000/get/");
sessions[i] = http_client.CreateSession("https://192.0.2.0:19000/get/");
auto request = sessions[i]->CreateRequest();
request->SetMethod(http_client::Method::Get);
request->SetUri("get/");
Expand Down