Skip to content

Commit a467ef6

Browse files
Merge pull request NoiseByNorthwest#265 from NoiseByNorthwest/fix/264
Fix report data access
2 parents 05e8508 + de72dff commit a467ef6

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed

src/php_spx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ static int http_ui_handler_data(const char * data_dir, const char *relative_path
10381038
if (
10391039
spx_reporter_full_build_metadata_file_name(
10401040
data_dir,
1041-
relative_path + strlen(get_report_metadata_uri),
1041+
relative_path + strlen(get_report_metadata_uri) - 1,
10421042
file_name,
10431043
sizeof(file_name)
10441044
) == NULL
@@ -1055,7 +1055,7 @@ static int http_ui_handler_data(const char * data_dir, const char *relative_path
10551055
if (
10561056
spx_reporter_full_build_file_name(
10571057
data_dir,
1058-
relative_path + strlen(get_report_uri),
1058+
relative_path + strlen(get_report_uri) - 1,
10591059
file_name,
10601060
sizeof(file_name)
10611061
) == NULL

tests/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*
22
!.gitignore
33
!*.phpt
4-
!*.inc
4+
!*.inc
5+
!data_dir

tests/data_dir/reportkey.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bar

tests/data_dir/reportkey.txt.gz

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo

tests/spx_ui_report_access.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
UI: URI confinement
3+
--CGI--
4+
--INI--
5+
spx.http_enabled=1
6+
spx.http_key="dev"
7+
spx.http_ip_whitelist="127.0.0.1"
8+
spx.data_dir="{PWD}/data_dir"
9+
log_errors=on
10+
--ENV--
11+
return <<<END
12+
REMOTE_ADDR=127.0.0.1
13+
REQUEST_URI=/
14+
END;
15+
--GET--
16+
SPX_KEY=dev&SPX_UI_URI=/data/reports/get/reportkey
17+
--FILE--
18+
<?php
19+
// noop
20+
?>
21+
--EXPECT--
22+
foo
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
UI: URI confinement
3+
--CGI--
4+
--INI--
5+
spx.http_enabled=1
6+
spx.http_key="dev"
7+
spx.http_ip_whitelist="127.0.0.1"
8+
spx.data_dir="{PWD}/data_dir"
9+
log_errors=on
10+
--ENV--
11+
return <<<END
12+
REMOTE_ADDR=127.0.0.1
13+
REQUEST_URI=/
14+
END;
15+
--GET--
16+
SPX_KEY=dev&SPX_UI_URI=/data/reports/metadata/reportkey
17+
--FILE--
18+
<?php
19+
// noop
20+
?>
21+
--EXPECT--
22+
bar

0 commit comments

Comments
 (0)