diff options
| author | Pjotr <wrk@bosa.lan> | 2026-10-03 07:07:42 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-10-03 07:07:42 +0000 |
| commit | 9af835a6caed825bb0cd83b6ced23ffafb3de99f (patch) | |
| tree | 83ffc9590c95cc1be6deaefd40d999149f14c8a6 | |
| parent | cc460d81675a7207e0b3cc0d9feabb44914a4ad7 (diff) | |
| download | gn-machines-9af835a6caed825bb0cd83b6ced23ffafb3de99f.tar.gz | |
bnw: serve GN2 endpoints directly on the legacy /sourcecodes/ path
GN2's bnw_page.html posts to the LEGACY path
/sourcecodes/bn_genenet.php (the upstream deployment layout). The
legacy redirect from b820a0d answers that POST with a 301, and
browsers turn POST into GET when following redirects -- the payload
is silently dropped and bn_genenet.php renders its default form ("the
Loading data from GeneNetwork hang").
Exact-match locations (= /sourcecodes/bn_genenet.php and
= /sourcecodes/executionprogress_default.php) win over the
^~ /sourcecodes/ redirect and serve the endpoints directly, without
Anubis. The generic php body cannot be reused there: its
if(!-f $document_root$fastcgi_script_name) check and SCRIPT_FILENAME
are relative to the web root, which already IS .../sourcecodes, so
the legacy prefix doubles up and 404s. These locations set
SCRIPT_FILENAME explicitly and use fastcgi_params (fastcgi.conf would
override it).
New test t16: the GN2 handshake POST to /sourcecodes/bn_genenet.php
with a BROWSER user agent returns the prepared-data page (200, no
redirect, no challenge). bnw suite: 16/16.
| -rw-r--r-- | genenetwork/services/bnw.scm | 29 | ||||
| -rw-r--r-- | genenetwork/services/test/bnw_http_tests.py | 19 |
2 files changed, 48 insertions, 0 deletions
diff --git a/genenetwork/services/bnw.scm b/genenetwork/services/bnw.scm index f551843..6baec0b 100644 --- a/genenetwork/services/bnw.scm +++ b/genenetwork/services/bnw.scm @@ -244,6 +244,32 @@ Anubis enabled, by the internal server behind the challenge." (define %bnw-gn2-php-endpoints '("/bn_genenet.php" "/executionprogress_default.php")) +(define (bnw-nginx-legacy-gn2-blocks) + "GN2's form posts to the LEGACY path +/sourcecodes/bn_genenet.php (upstream deployment layout), so those +endpoints must also be served DIRECT under that prefix -- a 301 there +would turn the browser's POST into a GET and silently drop the +payload. Exact-match locations win over the ^~ /sourcecodes/ +redirect.\n\nThe generic php body cannot be reused here: its +if(!-f $document_root$fastcgi_script_name) check and its SCRIPT_FILENAME +are relative to the web root, which is already .../sourcecodes -- the +legacy prefix would double up (sourcecodes/sourcecodes/...) and 404. +So these locations point SCRIPT_FILENAME at the real file explicitly +and skip the existence check (the endpoint is our own script; it +exists). fastcgi_params is used instead of fastcgi.conf because the +latter would override SCRIPT_FILENAME." + (apply append + (map (lambda (script) + (list + " location = /sourcecodes/" script " {\n" + " include " (file-append nginx "/share/nginx/conf/fastcgi_params") ";\n" + " fastcgi_param SCRIPT_FILENAME $document_root/" script ";\n" + ;; Mitigate https://httpoxy.org/ vulnerabilities + " fastcgi_param HTTP_PROXY \"\";\n" + " fastcgi_pass unix:/var/run/php8-fpm.sock;\n" + " }\n")) + '("bn_genenet.php" "executionprogress_default.php")))) + (define (bnw-nginx-conf-file config) "Render the whole nginx.conf. Without Anubis: one server block with the php-fpm back-end. With Anubis: the PUBLIC server block proxies to @@ -297,6 +323,9 @@ direct so GN2 is never challenged." (bnw-nginx-bnw-data-block) (bnw-nginx-legacy-sourcecodes-block) (bnw-nginx-htm-block) + ;; GN2 posts to the LEGACY /sourcecodes/ path; serve those + ;; endpoints directly (a redirect would drop the POST). + (bnw-nginx-legacy-gn2-blocks) (list " location / {\n" " proxy_pass http://unix:" %anubis-unix-socket ";\n" diff --git a/genenetwork/services/test/bnw_http_tests.py b/genenetwork/services/test/bnw_http_tests.py index 3b9d114..8d4cd73 100644 --- a/genenetwork/services/test/bnw_http_tests.py +++ b/genenetwork/services/test/bnw_http_tests.py @@ -229,6 +229,25 @@ def t15(): and "Making sure" not in r.body) +@test("t16 GN2 legacy-path POST is served, not redirected") +def t16(): + # GN2's bnw_page.html posts to the LEGACY path + # /sourcecodes/bn_genenet.php. A 301 there would make the browser + # resend as GET and silently drop the payload (the classic + # "Loading data from GeneNetwork" hang). The endpoint must be + # served directly, with a browser UA (proving Anubis is out of the + # path), and the handshake must complete. + r = request_ua("/sourcecodes/bn_genenet.php", BROWSER_UA, + data=urllib.parse.urlencode( + {"My_Gennenet": GN2_DATA, + "My_key": "gnb"}).encode(), + method="POST") + return (r.status == 200 + and r.has("Perform Bayesian network modeling") + and r.has("var data1 = ") + and "Making sure" not in r.body) + + def main(): passed = failed = 0 for name, fn in TESTS: |
