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

THREESCALE-7906 - initialization of $post_action_impact and $target_host variables as tables #1340

Merged
merged 2 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed dirty context [PR #1328](https://github.com/3scale/APIcast/pull/1328) [THREESCALE-8000](https://issues.redhat.com/browse/THREESCALE-8000) [THREESCALE-8007](https://issues.redhat.com/browse/THREESCALE-8007) [THREESCALE-8252](https://issues.redhat.com/browse/THREESCALE-8252)
- Fixed dirty context (part 2 of PR #1328) when tls termination policy is in the policy chain [PR #1333](https://github.com/3scale/APIcast/pull/1333)
- Fixed NGINX filters policy error [PR #1339](https://github.com/3scale/APIcast/pull/1339) [THREESCALE-7349](https://issues.redhat.com/browse/THREESCALE-7349)
- Fix to avoid uninitialized variables when request URI is too large [PR #1340](https://github.com/3scale/APIcast/pull/1340) [THREESCALE-7906](https://issues.redhat.com/browse/THREESCALE-7906)

### Added

Expand Down
1 change: 0 additions & 1 deletion gateway/conf.d/apicast.conf
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ location / {

set $ctx_ref -1;

set $post_action_impact '';
set $original_request_id $request_id;
set $original_request_uri '$scheme://$host$request_uri';

Expand Down
7 changes: 7 additions & 0 deletions gateway/http.d/apicast.conf.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ map "" $extended_access_logs_enabled {
default '0';
}

map "" $post_action_impact {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be removed from

set $post_action_impact '';
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

currently investigating this. Removing this line would make sense but it seems to require reviewing our non-blackbox tests (that don't use apicast.conf.liquid).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

non blackbox tests conversion to Blackbox tracked here: #1343

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

default '';
}

map "" $target_host {
default '$host';
}

log_format extended escape=none '$extended_access_log';

Expand Down
33 changes: 33 additions & 0 deletions t/apicast-log.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ use Test::APIcast::Blackbox 'no_plan';
# stderr to be able to use "grep_error_log" by setting APICAST_ACCESS_LOG_FILE
$ENV{APICAST_ACCESS_LOG_FILE} = "$Test::Nginx::Util::ErrLogFile";

sub large_param {
my $res = "";
for (my $i=0; $i <= 1024; $i++) {
$res = $res . "aaaaaaaaaa";
}
return $res;
}

$ENV{'LARGE_PARAM'} = large_param();

repeat_each(2);

run_tests();
Expand Down Expand Up @@ -131,3 +141,26 @@ yay, api backend: test:$TEST_NGINX_SERVER_PORT
qr/\+0000\] localhost\:\d+ 127\.0\.0\.1\:\d+/
--- no_error_log
[error]


=== TEST 4: large URI is handled correctly without leaving variables uninitialized.
--- configuration
{
"services": [
{
"id": 42,
"proxy": {
"proxy_rules": [
{ "pattern": "/", "http_method": "GET", "metric_system_name": "hits", "delta": 2 }
]
}
}
]
}
--- request eval
"GET /?user_key=value&large_param=$ENV{LARGE_PARAM}"
--- error_code: 414
--- no_error_log eval
[
qr/using uninitialized \"\w+\" variable while logging request/
]