Skip to content

Commit

Permalink
Merge pull request #1340 from 3scale/THREESCALE-7906_fix_missing_vari…
Browse files Browse the repository at this point in the history
…ables

THREESCALE-7906 - initialization of $post_action_impact and $target_host variables as tables
  • Loading branch information
samugi authored Jun 7, 2022
2 parents 602e21d + 5d1e799 commit 88b7589
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
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 {
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/
]

0 comments on commit 88b7589

Please sign in to comment.