Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67d61f339c |
No files matched your search
@@ -2,6 +2,77 @@
|
|||||||
|
|
||||||
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
All notable changes are recorded here. Versions follow [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [1.1.1] — 2026-10-29
|
||||||
|
|
||||||
|
_A patch release: the slow-request-body limit 1.1.0 introduced now covers form posts and multipart uploads too, and
|
||||||
|
after a restore the Backups screen shows how the site is reached, for review._
|
||||||
|
|
||||||
|
### Upgrading — read this first
|
||||||
|
|
||||||
|
**From `1.1.0`: a kernel upgrade, no flag.** From `1.0.1` or `1.0.0`, read `1.1.0`'s *Upgrading* first (behind a
|
||||||
|
reverse proxy its step 1 matters), then install this release directly: `1.1.0` itself is not needed in between. Paths
|
||||||
|
are the installer defaults (`/opt/runway`, `/opt/runway-data`).
|
||||||
|
|
||||||
|
**1. Back up.** Take each site's backup (**Backups**) and copy `/opt/runway-data/external/` somewhere **outside**
|
||||||
|
`external/plugins/`.
|
||||||
|
|
||||||
|
**2. Upgrade the kernel:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x runway-1.1.1.bin
|
||||||
|
sudo ./runway-1.1.1.bin -y
|
||||||
|
```
|
||||||
|
|
||||||
|
The essential plugin moves with the kernel to `1.1.1` (its descriptor changes in version only, and its jar is
|
||||||
|
rebuilt), so the installer refreshes it; expect these lines, once:
|
||||||
|
|
||||||
|
```
|
||||||
|
refreshing bundled plugin 'protection' from this release (it moves with the kernel; files you edited are backed up)
|
||||||
|
plugin 'protection': plugin.yml replaced (the previous one kept as plugin.yml.bak, for a rollback)
|
||||||
|
plugin 'protection': runway-plugin-protection.jar replaced (the previous one kept as runway-plugin-protection.jar.bak, for a rollback)
|
||||||
|
keeping the bundled plugins in the release: /opt/runway-1.1.1/seed/ (the repair copy — Administration §12)
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. Check.**
|
||||||
|
- **About Runway** shows `1.1.1`.
|
||||||
|
- On **Plugins**, every row is *Loaded* and none *Blocked*; protection shows `1.1.1`.
|
||||||
|
- The start log says `request bodies slower than 4096 bytes/s are refused (runway.http.min-request-data-rate)`, with
|
||||||
|
your value if you changed it.
|
||||||
|
|
||||||
|
**4. Rollback**, if needed: `sudo bash runway-1.1.0.bin -y` puts 1.1.0 back, its protection files included; slow form
|
||||||
|
posts are then held until the idle timeout again. Nothing this release saves is read differently by 1.1.0.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Slow request bodies are refused on every path, as 1.1.0 said they would be.** In 1.1.0
|
||||||
|
`runway.http.min-request-data-rate` was enforced only where a body was read as a stream. Form posts — every login
|
||||||
|
form, the console's forms, a plugin's form — and multipart uploads were read past it, so a client trickling one in
|
||||||
|
still held a request thread until the 30-second idle timeout, as in 1.0.1. Runway now checks the rate on every read
|
||||||
|
of a request body and answers `408 Request Timeout`: within about two seconds for a steady drip (measured: form and
|
||||||
|
multipart posts at 20 bytes a second, on both login pages and a plugin's form route), and for a client that pauses
|
||||||
|
between packets when its next packet arrives, within one idle timeout. Only time spent waiting for the client
|
||||||
|
counts, and a body that has arrived complete is never refused, however late its last packet came. A proxy that
|
||||||
|
buffers the whole request body before forwarding it kept such clients off Runway already, in 1.1.0 too.
|
||||||
|
- **Sending part of a body fast no longer buys a long drip.** 1.1.0 averaged over the whole body, so a client that
|
||||||
|
sent most of a large one at full speed could then drip the rest for the body's size divided by the rate (16 MiB at
|
||||||
|
4 KiB/s: over an hour). Bytes sent early now earn at most 30 seconds of waiting.
|
||||||
|
- **A request refused for a slow body is answered `408`.** Depending on how the code above handled the failed read,
|
||||||
|
1.1.0 could answer it `400` (a form parser's "unable to parse") or an empty `200`.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **After a restore, the Backups screen shows how the site is reached.** On the application console, after a restore
|
||||||
|
or after creating a site from a backup, the screen shows the site's hosts and base URL as they now are, with the
|
||||||
|
same editor as **Sites → Edit hosts**: a restore made there brings back the hosts and base URL saved in the backup,
|
||||||
|
which may not be how this installation reaches the site. On a site's own console the hosts are shown read-only: a
|
||||||
|
restore made there keeps them. See `docs/ADMINISTRATION.md` §10.
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
- **Exempting a same-host proxy's health check from the rate limit** (`docs/ADMINISTRATION.md` §12.4): the proxy sends
|
||||||
|
its check with a fixed `X-Forwarded-For` that no visitor can produce, and that one address is listed in protection's
|
||||||
|
allowlist, so the check never shares a rate-limit bucket with a local crawl and loopback stays limited.
|
||||||
|
|
||||||
## [1.1.0] — 2026-10-29
|
## [1.1.0] — 2026-10-29
|
||||||
|
|
||||||
_A minor release: plugins can keep their data in PostgreSQL or MariaDB through the new database plugins, platform
|
_A minor release: plugins can keep their data in PostgreSQL or MariaDB through the new database plugins, platform
|
||||||
|
|||||||
+23
-2
@@ -710,7 +710,7 @@ from the configuration metadata shipped in the jar.
|
|||||||
| `runway.security.secret-key` | _(installer-set)_ | Master key for AES-256-GCM encryption of every stored secret (platform SMTP password or OAuth2 client secret, per-site CAPTCHA secrets, `secret`-typed plugin settings). The installer generates one on first install and stores it in a root-only systemd drop-in as `RUNWAY_SECURITY_SECRET_KEY` (see `--secret-key`, §3); Spring's relaxed binding maps that env var to this property. **While blank the secret cipher is unavailable and no secret can be saved** — the app console shows a persistent warning on every page until it is set. Holds a real secret — never in the classpath default. |
|
| `runway.security.secret-key` | _(installer-set)_ | Master key for AES-256-GCM encryption of every stored secret (platform SMTP password or OAuth2 client secret, per-site CAPTCHA secrets, `secret`-typed plugin settings). The installer generates one on first install and stores it in a root-only systemd drop-in as `RUNWAY_SECURITY_SECRET_KEY` (see `--secret-key`, §3); Spring's relaxed binding maps that env var to this property. **While blank the secret cipher is unavailable and no secret can be saved** — the app console shows a persistent warning on every page until it is set. Holds a real secret — never in the classpath default. |
|
||||||
| `runway.proxy.forwarded-headers` | `true` | Whether to honor `X-Forwarded-*` at all (still only from trusted peers; the standard `Forwarded` header is never read) — see **§7**. |
|
| `runway.proxy.forwarded-headers` | `true` | Whether to honor `X-Forwarded-*` at all (still only from trusted peers; the standard `Forwarded` header is never read) — see **§7**. |
|
||||||
| `runway.proxy.trusted-cidrs` | `127.0.0.1/32`, `::1/128` | Proxy peers whose forwarded headers are trusted. The **bound default is empty** (trust nothing); the shipped file seeds loopback. **§7**. |
|
| `runway.proxy.trusted-cidrs` | `127.0.0.1/32`, `::1/128` | Proxy peers whose forwarded headers are trusted. The **bound default is empty** (trust nothing); the shipped file seeds loopback. **§7**. |
|
||||||
| `runway.http.min-request-data-rate` | `4096` | The slowest a request body may arrive, in **bytes per second**, before Runway answers `408 Request Timeout` and frees the request thread. Without it a client sending a byte now and then kept a thread for as long as it liked (the idle timeout only limits one stalled read). Measured from the body's first byte on what has arrived, so a server slow to start reading is never blamed. 4096 (4 KiB/s) is below any real connection; `0` turns the check off. Set on **Settings → Server settings → Request limits**; applies after a restart. |
|
| `runway.http.min-request-data-rate` | `4096` | The slowest a request body may arrive, in **bytes per second**, before Runway answers `408 Request Timeout` and frees the request thread. It applies to every body — login and other forms, multipart uploads, raw bodies alike. Without it a client sending a byte now and then kept a thread for as long as it liked (the idle timeout only limits one stalled read). Only the time spent waiting for the client counts, from the first second of waiting on, so a server slow to start reading is never blamed, and a body that has arrived complete is never refused, however late its last packet came. Sending part of a body fast earns at most 30 seconds of waiting, so a large body cannot buy a long drip; a client pausing between packets is cut when its next packet arrives, within one idle timeout. 4096 (4 KiB/s) is below any real connection; `0` turns the check off. Set on **Settings → Server settings → Request limits**; applies after a restart. |
|
||||||
| `runway.i18n.cache-seconds` | `5` | How often a message lookup **outside** a public page (an error page, a plugin's background text) and the operator console's own bundle re-check their files on disk (`0` = on every lookup). Public pages re-check on every request, so a bundle edited on disk shows on the next page view, under a new ETag. |
|
| `runway.i18n.cache-seconds` | `5` | How often a message lookup **outside** a public page (an error page, a plugin's background text) and the operator console's own bundle re-check their files on disk (`0` = on every lookup). Public pages re-check on every request, so a bundle edited on disk shows on the next page view, under a new ETag. |
|
||||||
| `runway.csp.mode` | `report` | Content-Security-Policy delivery: `report` (report-only — violations are logged, nothing is blocked), `enforce`, or `off`. Upper or lower case; blank means `report`. Any other value (`enforced`, say) stops startup with a message naming it. See **§8.4**. |
|
| `runway.csp.mode` | `report` | Content-Security-Policy delivery: `report` (report-only — violations are logged, nothing is blocked), `enforce`, or `off`. Upper or lower case; blank means `report`. Any other value (`enforced`, say) stops startup with a message naming it. See **§8.4**. |
|
||||||
| `runway.csp.strict-dynamic` | `true` | `'strict-dynamic'` on the nonced pages. `false` rolls the whole estate (console **and** public pages) back to the host allowlist. **§8.4**. |
|
| `runway.csp.strict-dynamic` | `true` | `'strict-dynamic'` on the nonced pages. `false` rolls the whole estate (console **and** public pages) back to the host allowlist. **§8.4**. |
|
||||||
@@ -1588,7 +1588,10 @@ wherever a site gets hosts: creating a site, installing a demo, and creating a s
|
|||||||
malformed host or one another site answers on, before anything is created. Restoring a backup brings back the
|
malformed host or one another site answers on, before anything is created. Restoring a backup brings back the
|
||||||
hosts and base URL the site had when the backup was taken when it is made from the application console (a host
|
hosts and base URL the site had when the backup was taken when it is made from the application console (a host
|
||||||
given to another site since then is left off, the log says which: `restored site '…' without host(s) […]`, and you
|
given to another site since then is left off, the log says which: `restored site '…' without host(s) […]`, and you
|
||||||
can add it back with **Edit hosts** once it is free). A restore made from the site's own console keeps the hosts and
|
can add it back with **Edit hosts** once it is free). After such a restore, and after creating a site from a backup,
|
||||||
|
the Backups screen shows the site's hosts and base URL **as they now are**, with the same editor as **Edit hosts**:
|
||||||
|
check them before anything else, because a backup taken on another installation, or before the site moved, brings
|
||||||
|
back how it was reached then. A restore made from the site's own console keeps the hosts and
|
||||||
base URL the site has: how a site is reached is yours to set, never the site manager's, and a backup file is
|
base URL the site has: how a site is reached is yours to set, never the site manager's, and a backup file is
|
||||||
theirs to write. A host is a plain DNS name: no scheme, path,
|
theirs to write. A host is a plain DNS name: no scheme, path,
|
||||||
port (`example.com:8080`), wildcard (`*.example.com`) or underscore, and an international name is written in its
|
port (`example.com:8080`), wildcard (`*.example.com`) or underscore, and an international name is written in its
|
||||||
@@ -2431,6 +2434,24 @@ runway:
|
|||||||
- "198.51.100.7" # the audit runner
|
- "198.51.100.7" # the audit runner
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**A health check from a proxy on the same host.** Behind a same-host reverse proxy, the proxy's own health check
|
||||||
|
(`GET /actuator/health` or a site's `/__health`) usually reaches Runway from loopback with no `X-Forwarded-For`, so it
|
||||||
|
shares one rate-limit bucket with everything else run on that host — a local crawl or audit can then earn the check
|
||||||
|
`429`s and push the proxy towards marking the server down. Exempt the check alone, not loopback: have the proxy send
|
||||||
|
it with a fixed `X-Forwarded-For` from a documentation range, and list that address here. No visitor can pose as
|
||||||
|
it: on real traffic the proxy adds the visitor's own address to the right of anything the visitor sent (or replaces
|
||||||
|
the header), and Runway reads the header from the right. With HAProxy 2.2 or later:
|
||||||
|
|
||||||
|
```
|
||||||
|
backend runway
|
||||||
|
option httpchk
|
||||||
|
http-check send meth GET uri /actuator/health ver HTTP/1.1 hdr Host www.example.com hdr X-Forwarded-For 192.0.2.53
|
||||||
|
```
|
||||||
|
|
||||||
|
and `192.0.2.53` in `allowlist`. Loopback must be in `runway.proxy.trusted-cidrs` (it is, for a same-host proxy);
|
||||||
|
leave the probe's address out of it, which is for real proxies only. Checking
|
||||||
|
`/actuator/health` from outside the proxy (a monitoring service) needs no header: list that service's own address.
|
||||||
|
|
||||||
> **If you are blocked, stop — do not keep probing.** Once an address is auto-blocked, requests no longer
|
> **If you are blocked, stop — do not keep probing.** Once an address is auto-blocked, requests no longer
|
||||||
> reach the rate limiter at all; they hit the blocklist. So the `rate-limit` counter freezes while
|
> reach the rate limiter at all; they hit the blocklist. So the `rate-limit` counter freezes while
|
||||||
> `blocklist-auto` keeps climbing, and continued probing simply confirms the block rather than measuring it.
|
> `blocklist-auto` keeps climbing, and continued probing simply confirms the block rather than measuring it.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ How large a request may be. Applies after a restart.
|
|||||||
| Setting | Key | What it does | Values |
|
| Setting | Key | What it does | Values |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| Largest request before sign-in (bytes) | `runway.endpoints.max-form-bytes` | The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB). | whole number from 1024 to 104857600; default `262144` |
|
| Largest request before sign-in (bytes) | `runway.endpoints.max-form-bytes` | The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB). | whole number from 1024 to 104857600; default `262144` |
|
||||||
| Slowest request body (bytes per second) *(Advanced)* | `runway.http.min-request-data-rate` | A request body arriving more slowly is answered 408 Request Timeout, so a client sending a byte now and then cannot hold a request thread. Measured on what has arrived since the body's first byte. Default 4096; 0 turns the check off. | whole number from 0 to 1048576; default `4096` |
|
| Slowest request body (bytes per second) *(Advanced)* | `runway.http.min-request-data-rate` | A request body arriving more slowly is answered 408 Request Timeout: login and other forms, uploads and raw bodies alike, so a client sending a byte now and then cannot keep a request thread. Only time spent waiting for the client counts, and a body that has arrived complete is never refused. Sending part of a body fast earns at most 30 seconds of waiting. Default 4096; 0 turns the check off. | whole number from 0 to 1048576; default `4096` |
|
||||||
| Largest request to a plugin (bytes) | `runway.endpoints.max-body-bytes` | The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB). | whole number from 1024 to 1073741824; default `10485760` |
|
| Largest request to a plugin (bytes) | `runway.endpoints.max-body-bytes` | The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB). | whole number from 1024 to 1073741824; default `10485760` |
|
||||||
| Largest uploaded file | `spring.servlet.multipart.max-file-size` | For uploads such as a backup to restore. A size like 256MB or 1GB. Default 256MB. | text; default `256MB` |
|
| Largest uploaded file | `spring.servlet.multipart.max-file-size` | For uploads such as a backup to restore. A size like 256MB or 1GB. Default 256MB. | text; default `256MB` |
|
||||||
| Largest upload request | `spring.servlet.multipart.max-request-size` | All the files of one upload together. A size like 256MB. Default 256MB. | text; default `256MB` |
|
| Largest upload request | `spring.servlet.multipart.max-request-size` | All the files of one upload together. A size like 256MB. Default 256MB. | text; default `256MB` |
|
||||||
|
|||||||
@@ -1326,7 +1326,8 @@ Restore is safe by design: the platform first checks the file is a genuine, comp
|
|||||||
backup and only then swaps it in, in one step. **A corrupt, empty, or wrong file is rejected
|
backup and only then swaps it in, in one step. **A corrupt, empty, or wrong file is rejected
|
||||||
and your live site is left exactly as it was** — a failed or interrupted restore never leaves
|
and your live site is left exactly as it was** — a failed or interrupted restore never leaves
|
||||||
you with a half-restored or missing site. After a successful restore the site reflects the
|
you with a half-restored or missing site. After a successful restore the site reflects the
|
||||||
backup immediately (no restart).
|
backup immediately (no restart), and the Backups screen shows the site's host names and base URL for you to check: a restore made here keeps them as
|
||||||
|
they were (how the site is reached is set by the platform operator), so if they look wrong, ask the operator.
|
||||||
|
|
||||||
A backup made on a **newer** version of the platform than the one your site runs on is refused
|
A backup made on a **newer** version of the platform than the one your site runs on is refused
|
||||||
the same way, with the message *"This backup was made by a newer version of Runway … Ask the
|
the same way, with the message *"This backup was made by a newer version of Runway … Ask the
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<groupId>mx.quest</groupId>
|
<groupId>mx.quest</groupId>
|
||||||
<artifactId>runway</artifactId>
|
<artifactId>runway</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Runway</name>
|
<name>Runway</name>
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
extended timestamp through the build JVM's default time zone, so the same source built in CST and
|
extended timestamp through the build JVM's default time zone, so the same source built in CST and
|
||||||
in UTC differed by exactly 6 h inside the exec jar (found 2026-10-17 on a second host).
|
in UTC differed by exactly 6 h inside the exec jar (found 2026-10-17 on a second host).
|
||||||
.mvn/jvm.config pins -Duser.timezone=UTC for the Maven JVM, which removes the host's zone. -->
|
.mvn/jvm.config pins -Duser.timezone=UTC for the Maven JVM, which removes the host's zone. -->
|
||||||
<project.build.outputTimestamp>2026-10-29T15:02:00Z</project.build.outputTimestamp>
|
<project.build.outputTimestamp>2026-10-29T17:30:00Z</project.build.outputTimestamp>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<!-- runway-spi and runway-spi-testkit attach a sources jar (release assets for third-party plugin authors,
|
<!-- runway-spi and runway-spi-testkit attach a sources jar (release assets for third-party plugin authors,
|
||||||
docs/PLUGIN-DEVELOPMENT.md §3). Boot's parent manages 3.3.1; 3.4.0 is the version the build hosts'
|
docs/PLUGIN-DEVELOPMENT.md §3). Boot's parent manages 3.3.1; 3.4.0 is the version the build hosts'
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>mx.quest</groupId>
|
<groupId>mx.quest</groupId>
|
||||||
<artifactId>runway</artifactId>
|
<artifactId>runway</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>runway-app</artifactId>
|
<artifactId>runway-app</artifactId>
|
||||||
|
|||||||
@@ -49,10 +49,13 @@ public class AppBackupsController {
|
|||||||
private final AppActivityLog activity;
|
private final AppActivityLog activity;
|
||||||
|
|
||||||
private final mx.quest.runway.backup.BackupProperties policy;
|
private final mx.quest.runway.backup.BackupProperties policy;
|
||||||
|
private final mx.quest.runway.platform.PlatformSettingsStore platform;
|
||||||
|
|
||||||
public AppBackupsController(SiteStore sites, BackupService backups, PlatformAuthority platformAuthority,
|
public AppBackupsController(SiteStore sites, BackupService backups, PlatformAuthority platformAuthority,
|
||||||
@Qualifier("operatorAwareMessageSource") MessageSource messages,
|
@Qualifier("operatorAwareMessageSource") MessageSource messages,
|
||||||
AppActivityLog activity, mx.quest.runway.backup.BackupProperties policy) {
|
AppActivityLog activity, mx.quest.runway.backup.BackupProperties policy,
|
||||||
|
mx.quest.runway.platform.PlatformSettingsStore platform) {
|
||||||
|
this.platform = platform;
|
||||||
this.policy = policy;
|
this.policy = policy;
|
||||||
this.sites = sites;
|
this.sites = sites;
|
||||||
this.backups = backups;
|
this.backups = backups;
|
||||||
@@ -61,6 +64,9 @@ public class AppBackupsController {
|
|||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Flash attribute naming the site whose hosts the Backups screen shows for review after a restore. */
|
||||||
|
static final String REVIEW_HOSTS = "reviewHostsOf";
|
||||||
|
|
||||||
/** One site row: its id and the backups stored for it on the server. */
|
/** One site row: its id and the backups stored for it on the server. */
|
||||||
public record SiteBackups(String siteId, List<StoredBackup> stored) {
|
public record SiteBackups(String siteId, List<StoredBackup> stored) {
|
||||||
}
|
}
|
||||||
@@ -73,6 +79,15 @@ public class AppBackupsController {
|
|||||||
rows.add(new SiteBackups(site.id(), backups.list(site.id())));
|
rows.add(new SiteBackups(site.id(), backups.list(site.id())));
|
||||||
}
|
}
|
||||||
model.addAttribute("rows", rows);
|
model.addAttribute("rows", rows);
|
||||||
|
// After a restore (or a site created from a backup), how the site is reached now: the hosts and base URL may
|
||||||
|
// have come from the backup, so they are shown for review with the editor, read from the store as they stand.
|
||||||
|
if (model.getAttribute(REVIEW_HOSTS) instanceof String reviewed) {
|
||||||
|
sites.find(reviewed).ifPresent(site -> {
|
||||||
|
model.addAttribute("reviewSite", site);
|
||||||
|
// A site with no host is reached only if it is the default (catch-all) site; otherwise not at all.
|
||||||
|
model.addAttribute("reviewIsDefault", platform.get().defaultSite().filter(reviewed::equals).isPresent());
|
||||||
|
});
|
||||||
|
}
|
||||||
// Shown, not edited: a server folder that receives every site's archives is the host's (settings-homes.yml).
|
// Shown, not edited: a server folder that receives every site's archives is the host's (settings-homes.yml).
|
||||||
String offsite = policy.getOffsiteDir();
|
String offsite = policy.getOffsiteDir();
|
||||||
model.addAttribute("offsiteDir", offsite == null || offsite.isBlank() ? null : offsite.trim());
|
model.addAttribute("offsiteDir", offsite == null || offsite.isBlank() ? null : offsite.trim());
|
||||||
@@ -136,6 +151,7 @@ public class AppBackupsController {
|
|||||||
backups.restore(siteId, in);
|
backups.restore(siteId, in);
|
||||||
activity.record(authentication.getName(), "site.restored", siteId + " (upload)");
|
activity.record(authentication.getName(), "site.restored", siteId + " (upload)");
|
||||||
redirect.addFlashAttribute("flash", message("op.appbackups.restored", "Site restored."));
|
redirect.addFlashAttribute("flash", message("op.appbackups.restored", "Site restored."));
|
||||||
|
redirect.addFlashAttribute(REVIEW_HOSTS, siteId);
|
||||||
} catch (UnsupportedBackupFormatException e) {
|
} catch (UnsupportedBackupFormatException e) {
|
||||||
redirect.addFlashAttribute("error", newerFormat(e));
|
redirect.addFlashAttribute("error", newerFormat(e));
|
||||||
} catch (IOException | RuntimeException e) {
|
} catch (IOException | RuntimeException e) {
|
||||||
@@ -154,6 +170,7 @@ public class AppBackupsController {
|
|||||||
backups.restoreStored(siteId, name);
|
backups.restoreStored(siteId, name);
|
||||||
activity.record(authentication.getName(), "site.restored", siteId + "/" + name);
|
activity.record(authentication.getName(), "site.restored", siteId + "/" + name);
|
||||||
redirect.addFlashAttribute("flash", message("op.appbackups.restored", "Site restored."));
|
redirect.addFlashAttribute("flash", message("op.appbackups.restored", "Site restored."));
|
||||||
|
redirect.addFlashAttribute(REVIEW_HOSTS, siteId);
|
||||||
} catch (UnsupportedBackupFormatException e) {
|
} catch (UnsupportedBackupFormatException e) {
|
||||||
redirect.addFlashAttribute("error", newerFormat(e));
|
redirect.addFlashAttribute("error", newerFormat(e));
|
||||||
} catch (IOException | RuntimeException e) {
|
} catch (IOException | RuntimeException e) {
|
||||||
@@ -196,6 +213,7 @@ public class AppBackupsController {
|
|||||||
backups.createFromBackup(newId.strip(), name, splitHosts(hosts), in);
|
backups.createFromBackup(newId.strip(), name, splitHosts(hosts), in);
|
||||||
activity.record(authentication.getName(), "site.created-from-backup", newId.strip());
|
activity.record(authentication.getName(), "site.created-from-backup", newId.strip());
|
||||||
redirect.addFlashAttribute("flash", message("op.appbackups.created", "Site created from backup."));
|
redirect.addFlashAttribute("flash", message("op.appbackups.created", "Site created from backup."));
|
||||||
|
redirect.addFlashAttribute(REVIEW_HOSTS, newId.strip());
|
||||||
} catch (UnsupportedBackupFormatException e) {
|
} catch (UnsupportedBackupFormatException e) {
|
||||||
redirect.addFlashAttribute("error", newerFormat(e));
|
redirect.addFlashAttribute("error", newerFormat(e));
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
|
|||||||
@@ -61,10 +61,13 @@ public class TenantBackupsController {
|
|||||||
private final TenantAuthority tenantAuthority;
|
private final TenantAuthority tenantAuthority;
|
||||||
private final MessageSource messages;
|
private final MessageSource messages;
|
||||||
private final mx.quest.runway.backup.BackupProperties policy;
|
private final mx.quest.runway.backup.BackupProperties policy;
|
||||||
|
private final mx.quest.runway.platform.PlatformSettingsStore platform;
|
||||||
|
|
||||||
public TenantBackupsController(SiteResolver siteResolver, BackupService backups, TenantAuthority tenantAuthority,
|
public TenantBackupsController(SiteResolver siteResolver, BackupService backups, TenantAuthority tenantAuthority,
|
||||||
@Qualifier("operatorAwareMessageSource") MessageSource messages,
|
@Qualifier("operatorAwareMessageSource") MessageSource messages,
|
||||||
mx.quest.runway.backup.BackupProperties policy) {
|
mx.quest.runway.backup.BackupProperties policy,
|
||||||
|
mx.quest.runway.platform.PlatformSettingsStore platform) {
|
||||||
|
this.platform = platform;
|
||||||
this.policy = policy;
|
this.policy = policy;
|
||||||
this.siteResolver = siteResolver;
|
this.siteResolver = siteResolver;
|
||||||
this.backups = backups;
|
this.backups = backups;
|
||||||
@@ -84,6 +87,12 @@ public class TenantBackupsController {
|
|||||||
model.addAttribute("backupPolicyKeepKey", "op.backups.policy.keep."
|
model.addAttribute("backupPolicyKeepKey", "op.backups.policy.keep."
|
||||||
+ (count > 0 ? "count" : "all") + (days > 0 ? "Days" : ""));
|
+ (count > 0 ? "count" : "all") + (days > 0 ? "Days" : ""));
|
||||||
model.addAttribute("transferOmissions", transferOmissions(site.id()));
|
model.addAttribute("transferOmissions", transferOmissions(site.id()));
|
||||||
|
// After a restore: how the site is reached, for review. A restore from this console keeps the hosts and base URL
|
||||||
|
// (only the application console changes them), so they are shown as they stand, without an editor.
|
||||||
|
if (Boolean.TRUE.equals(model.getAttribute(AppBackupsController.REVIEW_HOSTS))) {
|
||||||
|
model.addAttribute("reviewSite", site);
|
||||||
|
model.addAttribute("reviewIsDefault", platform.get().defaultSite().filter(site.id()::equals).isPresent());
|
||||||
|
}
|
||||||
// Restore is destructive + master-only; hide its affordances from a non-master (the controller still enforces).
|
// Restore is destructive + master-only; hide its affordances from a non-master (the controller still enforces).
|
||||||
boolean admin = tenantAuthority.isTenantAdmin(authentication, site.id());
|
boolean admin = tenantAuthority.isTenantAdmin(authentication, site.id());
|
||||||
model.addAttribute("canRestore", admin);
|
model.addAttribute("canRestore", admin);
|
||||||
@@ -196,6 +205,7 @@ public class TenantBackupsController {
|
|||||||
try {
|
try {
|
||||||
backups.restoreStored(site.id(), name, true); // a site manager never changes how the site is reached
|
backups.restoreStored(site.id(), name, true); // a site manager never changes how the site is reached
|
||||||
redirect.addFlashAttribute("flash", message("op.backups.restored", "Site restored from the backup."));
|
redirect.addFlashAttribute("flash", message("op.backups.restored", "Site restored from the backup."));
|
||||||
|
redirect.addFlashAttribute(AppBackupsController.REVIEW_HOSTS, Boolean.TRUE);
|
||||||
} catch (UnsupportedBackupFormatException e) {
|
} catch (UnsupportedBackupFormatException e) {
|
||||||
redirect.addFlashAttribute("error", newerFormat(e));
|
redirect.addFlashAttribute("error", newerFormat(e));
|
||||||
} catch (IOException | RuntimeException e) {
|
} catch (IOException | RuntimeException e) {
|
||||||
@@ -218,6 +228,7 @@ public class TenantBackupsController {
|
|||||||
try (InputStream in = file.getInputStream()) {
|
try (InputStream in = file.getInputStream()) {
|
||||||
backups.restore(site.id(), in, true); // a site manager never changes how the site is reached
|
backups.restore(site.id(), in, true); // a site manager never changes how the site is reached
|
||||||
redirect.addFlashAttribute("flash", message("op.backups.restored", "Site restored from the backup."));
|
redirect.addFlashAttribute("flash", message("op.backups.restored", "Site restored from the backup."));
|
||||||
|
redirect.addFlashAttribute(AppBackupsController.REVIEW_HOSTS, Boolean.TRUE);
|
||||||
} catch (UnsupportedBackupFormatException e) {
|
} catch (UnsupportedBackupFormatException e) {
|
||||||
redirect.addFlashAttribute("error", newerFormat(e));
|
redirect.addFlashAttribute("error", newerFormat(e));
|
||||||
} catch (IOException | RuntimeException e) {
|
} catch (IOException | RuntimeException e) {
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
package mx.quest.runway.web;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import org.eclipse.jetty.http.HttpException;
|
||||||
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
|
import org.eclipse.jetty.io.Content;
|
||||||
|
import org.eclipse.jetty.server.Handler;
|
||||||
|
import org.eclipse.jetty.server.Request;
|
||||||
|
import org.eclipse.jetty.server.Response;
|
||||||
|
import org.eclipse.jetty.util.Callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refuses a request body that arrives more slowly than a minimum rate, on <b>every</b> read of the body: the
|
||||||
|
* servlet input stream, form parameters and multipart parts alike.
|
||||||
|
*
|
||||||
|
* <p><b>Why a handler of our own.</b> Jetty 12's own minimum request data rate is checked only where a servlet reads
|
||||||
|
* the body through {@code getInputStream()}. Form parameters ({@code getParameter}, which Spring Security's login
|
||||||
|
* reads) and multipart parts are parsed through Jetty's core request instead, and that path never checks it, so a
|
||||||
|
* client could trickle a form for as long as it kept sending something inside each idle interval, holding a request
|
||||||
|
* thread all the while. Measured on 1.1.0: form and multipart posts dripped at 20 bytes a second were held until the
|
||||||
|
* 30-second idle timeout. This handler sits under the server and wraps the core request, so every body read passes
|
||||||
|
* through it.
|
||||||
|
*
|
||||||
|
* <p><b>What is measured.</b> Only the time spent <em>waiting for the client</em>: from a read that found no data to
|
||||||
|
* the next one that did. Time the application spends before or between reads does not count, so a server that is
|
||||||
|
* slow to read is never blamed. The check keeps a balance: every byte received earns one, every second of waiting
|
||||||
|
* costs the rate's worth, and the balance is capped at {@link #CREDIT_SECONDS} of the rate, so a body sent fast at
|
||||||
|
* first cannot buy an hour of dripping later. It runs when data arrives: once the waiting time reaches one second and
|
||||||
|
* the balance is negative, the read fails with {@code 408 Request Timeout} and so does every later read. A client
|
||||||
|
* pausing between packets is therefore cut when its next packet arrives, at most one idle timeout later. A chunk that completes the body is never refused: once the client has finished, no thread
|
||||||
|
* is waiting on it any more, and a small form whose only packet arrived late (a network stall) is not punished for
|
||||||
|
* it; the body counts as complete at its last chunk or, with a {@code Content-Length}, at its last byte. A client that
|
||||||
|
* sends nothing at all is left to the connection idle timeout.
|
||||||
|
*
|
||||||
|
* <p>The refusal is answered {@code 408} however the application handled the failed read: a form or multipart parser
|
||||||
|
* would report it as {@code 400}, as if the body were malformed, and code reading the stream itself could leave an
|
||||||
|
* empty {@code 200} (see {@link RefusalStatusResponse}).
|
||||||
|
*/
|
||||||
|
final class RequestBodyRateHandler extends Handler.Wrapper {
|
||||||
|
|
||||||
|
/** Waiting shorter than this is never judged: a single network stall must not look like a slow client. */
|
||||||
|
static final long GRACE_NANOS = 1_000_000_000L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The most waiting a body may have banked by arriving fast earlier: 30 seconds' worth of the rate, the connection
|
||||||
|
* idle timeout's default. Without a cap, a client that sent most of a large body at line speed and then dripped
|
||||||
|
* the rest could hold the thread for the body's size divided by the rate (16 MiB at 4 KiB/s: over an hour).
|
||||||
|
*/
|
||||||
|
static final long CREDIT_SECONDS = 30;
|
||||||
|
|
||||||
|
private final long bytesPerSecond;
|
||||||
|
private final long creditSeconds;
|
||||||
|
|
||||||
|
/** @param bytesPerSecond the slowest a body may arrive; must be positive (0 means "do not install") */
|
||||||
|
RequestBodyRateHandler(long bytesPerSecond) {
|
||||||
|
this(bytesPerSecond, CREDIT_SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** As {@link #RequestBodyRateHandler(long)}, with the credit cap in seconds (tests use a short one). */
|
||||||
|
RequestBodyRateHandler(long bytesPerSecond, long creditSeconds) {
|
||||||
|
if (bytesPerSecond <= 0 || creditSeconds <= 0) {
|
||||||
|
throw new IllegalArgumentException("rate and credit must be positive: " + bytesPerSecond + ", "
|
||||||
|
+ creditSeconds);
|
||||||
|
}
|
||||||
|
this.bytesPerSecond = bytesPerSecond;
|
||||||
|
this.creditSeconds = creditSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
long bytesPerSecond() {
|
||||||
|
return bytesPerSecond;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(Request request, Response response, Callback callback) throws Exception {
|
||||||
|
RateCheckedRequest checked = new RateCheckedRequest(request, bytesPerSecond, creditSeconds);
|
||||||
|
return super.handle(checked, new RefusalStatusResponse(checked, response), callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the refusal's status. A form or multipart parser reports any failed read as {@code 400 Bad Request}
|
||||||
|
* ("unable to parse form content"), which would tell the client its body was malformed when it was only slow; and
|
||||||
|
* code that reads the stream itself lets the failure escape as an {@code IOException}, which Jetty handles like a
|
||||||
|
* client that went away, completing the response with the status it already had ({@code 200}, empty). Once this
|
||||||
|
* request's body was refused, a client error status set on the response becomes {@code 408}, and so does whatever
|
||||||
|
* status the response is committed with.
|
||||||
|
*/
|
||||||
|
private static final class RefusalStatusResponse extends Response.Wrapper {
|
||||||
|
|
||||||
|
private final RateCheckedRequest request;
|
||||||
|
|
||||||
|
RefusalStatusResponse(RateCheckedRequest request, Response wrapped) {
|
||||||
|
super(request, wrapped);
|
||||||
|
this.request = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(boolean last, ByteBuffer content, Callback callback) {
|
||||||
|
if (request.refused != null && !isCommitted() && getStatus() != HttpStatus.REQUEST_TIMEOUT_408) {
|
||||||
|
super.setStatus(HttpStatus.REQUEST_TIMEOUT_408);
|
||||||
|
}
|
||||||
|
super.write(last, content, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStatus(int code) {
|
||||||
|
super.setStatus(request.refused != null && code >= 400 && code != HttpStatus.REQUEST_TIMEOUT_408
|
||||||
|
&& code < 500 ? HttpStatus.REQUEST_TIMEOUT_408 : code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The request whose body reads are measured. Reads of one request are serial, as Jetty's demand model makes them. */
|
||||||
|
private static final class RateCheckedRequest extends Request.Wrapper {
|
||||||
|
|
||||||
|
private final long bytesPerSecond;
|
||||||
|
private final long creditCap;
|
||||||
|
private long received;
|
||||||
|
private long waitedNanos;
|
||||||
|
private long waitingSince = -1;
|
||||||
|
/** Bytes received minus the rate times the time waited, capped at {@link #creditCap}; negative = too slow. */
|
||||||
|
private long credit;
|
||||||
|
private Content.Chunk refused;
|
||||||
|
|
||||||
|
RateCheckedRequest(Request wrapped, long bytesPerSecond, long creditSeconds) {
|
||||||
|
super(wrapped);
|
||||||
|
this.bytesPerSecond = bytesPerSecond;
|
||||||
|
this.creditCap = bytesPerSecond * creditSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Content.Chunk read() {
|
||||||
|
if (refused != null) {
|
||||||
|
return refused;
|
||||||
|
}
|
||||||
|
Content.Chunk chunk = super.read();
|
||||||
|
long now = System.nanoTime();
|
||||||
|
if (chunk == null) {
|
||||||
|
if (waitingSince < 0) {
|
||||||
|
waitingSince = now;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
long waited = 0;
|
||||||
|
if (waitingSince >= 0) {
|
||||||
|
waited = now - waitingSince;
|
||||||
|
waitedNanos += waited;
|
||||||
|
waitingSince = -1;
|
||||||
|
}
|
||||||
|
if (Content.Chunk.isFailure(chunk)) {
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
int bytes = chunk.remaining();
|
||||||
|
received += bytes;
|
||||||
|
// Each byte earns credit and each second of waiting costs the rate's worth; earning is capped, so a body
|
||||||
|
// sent fast at first cannot bank more than CREDIT_SECONDS of waiting for a drip later.
|
||||||
|
credit = Math.min(creditCap, credit + bytes - bytesPerSecond * (waited / 1_000_000) / 1000);
|
||||||
|
boolean complete = chunk.isLast() || (getLength() >= 0 && received >= getLength());
|
||||||
|
if (!complete && waitedNanos >= GRACE_NANOS && credit < 0) {
|
||||||
|
chunk.release();
|
||||||
|
refused = Content.Chunk.from(new HttpException.RuntimeException(HttpStatus.REQUEST_TIMEOUT_408,
|
||||||
|
"request body slower than " + bytesPerSecond + " bytes/s"), true);
|
||||||
|
return refused;
|
||||||
|
}
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,15 +16,22 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
/**
|
/**
|
||||||
* Keeps slow clients from holding request threads: a minimum rate for request bodies ({@code
|
* Keeps slow clients from holding request threads: a minimum rate for request bodies ({@code
|
||||||
* runway.http.min-request-data-rate}, bytes per second; Settings → Server settings → Request limits), applied to every
|
* runway.http.min-request-data-rate}, bytes per second; Settings → Server settings → Request limits), applied to every
|
||||||
* connector Jetty has when the server is built.
|
* read of a request body by {@link RequestBodyRateHandler}, installed when the server is built.
|
||||||
*
|
*
|
||||||
* <p><b>Why.</b> A servlet reads a request body on a request thread and blocks while it waits. Jetty's idle timeout
|
* <p><b>Why.</b> A servlet reads a request body on a request thread and blocks while it waits. Jetty's idle timeout
|
||||||
* limits one stalled read, not the whole body, so a client that sends a byte inside every idle interval kept a thread
|
* limits one stalled read, not the whole body, so a client that sends a byte inside every idle interval kept a thread
|
||||||
* for as long as it liked, and a few of them (with uploads allowed up to 256 MB) could take the pool. With a minimum
|
* for as long as it liked, and a few of them (with uploads allowed up to 256 MB) could take the pool. With a minimum
|
||||||
* rate Jetty answers {@code 408 Request Timeout} as soon as the body has arrived more slowly than the rate since its
|
* rate the request is answered {@code 408 Request Timeout} once the body arrives more slowly than the rate; time the
|
||||||
* first byte; time the application spends before reading does not count, because the rate is measured on what has
|
* application spends before reading does not count. Measured on Jetty 12.1.8 with Runway 1.1.1: form, multipart and
|
||||||
* arrived. Measured on Jetty 12.1.8: a client sending one byte a second against 1 KiB/s was cut after about two
|
* stream bodies dripped at 20 bytes a second against 4 KiB/s were answered {@code 408} after two seconds, on both
|
||||||
* seconds, and a server pausing three seconds before reading a body that arrived at once still answered {@code 200}.
|
* login pages and a plugin's form route, and a server pausing three seconds before reading a body that arrived at
|
||||||
|
* once still answered {@code 200}.
|
||||||
|
*
|
||||||
|
* <p><b>One check, under every read.</b> Jetty's own minimum rate is checked only where the body is read through
|
||||||
|
* {@code getInputStream()}; form parameters and multipart parts are parsed through Jetty's core request and escaped
|
||||||
|
* it (1.1.0 shipped with that gap: a dripped login form was held until the idle timeout). {@link
|
||||||
|
* RequestBodyRateHandler} wraps the core request under the server, so every read passes it, and Jetty's own check
|
||||||
|
* is turned off so that the two cannot race ({@link #apply}).
|
||||||
*
|
*
|
||||||
* <p><b>What it does not cover.</b> Slow header senders cost a connection, not a thread (Jetty parses headers without
|
* <p><b>What it does not cover.</b> Slow header senders cost a connection, not a thread (Jetty parses headers without
|
||||||
* one); a proxy's connection cap is the limit there. A client that reads a response slowly is bounded by the
|
* one); a proxy's connection cap is the limit there. A client that reads a response slowly is bounded by the
|
||||||
@@ -45,21 +52,34 @@ public class SlowClientConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the minimum request data rate on every HTTP configuration of {@code server}'s connectors.
|
* Installs the body-rate check on {@code server}: a {@link RequestBodyRateHandler} directly under the server, and
|
||||||
|
* Jetty's own minimum request data rate set to {@code 0} on every HTTP configuration of its connectors.
|
||||||
|
*
|
||||||
|
* <p>Jetty's own check covers {@code getInputStream()} only, and fires above this handler, so the two raced on
|
||||||
|
* the stream path: when Jetty's won, the failure escaped as an {@code IOException} that the application chain
|
||||||
|
* turned into an empty {@code 200} (measured on a plugin route that reads its form from the stream). One check,
|
||||||
|
* under every read, answers {@code 408} on every path. Boot has set the server's handler before its customizers
|
||||||
|
* run, and wraps the result in its own statistics handler afterwards.
|
||||||
*
|
*
|
||||||
* @param bytesPerSecond the rate; 0 turns the check off
|
* @param bytesPerSecond the rate; 0 turns the check off
|
||||||
* @return how many HTTP configurations were changed
|
* @return how many HTTP configurations had Jetty's own check set to 0
|
||||||
*/
|
*/
|
||||||
static int apply(Server server, long bytesPerSecond) {
|
static int apply(Server server, long bytesPerSecond) {
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
for (Connector connector : server.getConnectors()) {
|
for (Connector connector : server.getConnectors()) {
|
||||||
for (ConnectionFactory factory : connector.getConnectionFactories()) {
|
for (ConnectionFactory factory : connector.getConnectionFactories()) {
|
||||||
if (factory instanceof HttpConfiguration.ConnectionFactory http) {
|
if (factory instanceof HttpConfiguration.ConnectionFactory http) {
|
||||||
http.getHttpConfiguration().setMinRequestDataRate(bytesPerSecond);
|
http.getHttpConfiguration().setMinRequestDataRate(0);
|
||||||
changed++;
|
changed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (bytesPerSecond > 0 && server.getHandler() != null
|
||||||
|
&& !(server.getHandler() instanceof RequestBodyRateHandler)) {
|
||||||
|
RequestBodyRateHandler rate = new RequestBodyRateHandler(bytesPerSecond);
|
||||||
|
rate.setHandler(server.getHandler());
|
||||||
|
server.setHandler(rate);
|
||||||
|
}
|
||||||
if (bytesPerSecond > 0) {
|
if (bytesPerSecond > 0) {
|
||||||
log.info("request bodies slower than {} bytes/s are refused (runway.http.min-request-data-rate)",
|
log.info("request bodies slower than {} bytes/s are refused (runway.http.min-request-data-rate)",
|
||||||
bytesPerSecond);
|
bytesPerSecond);
|
||||||
|
|||||||
@@ -320,10 +320,11 @@ runway:
|
|||||||
trusted-cidrs:
|
trusted-cidrs:
|
||||||
- "127.0.0.1/32"
|
- "127.0.0.1/32"
|
||||||
- "::1/128"
|
- "::1/128"
|
||||||
# How slowly a client may send a request body, in bytes per second, before Jetty answers 408 and frees the
|
# How slowly a client may send a request body (any: forms, uploads, raw), in bytes per second, before Runway
|
||||||
# request thread (SlowClientConfig). Measured from the body's first byte on what has arrived, so a server that is
|
# answers 408 and frees the request thread (SlowClientConfig, RequestBodyRateHandler). Only time spent waiting for
|
||||||
# slow to read is never blamed. 4096 is below any real connection; 0 turns the check off. Also on Settings ->
|
# the client counts, so a server that is slow to read is never blamed, and a body that has arrived complete is never
|
||||||
# Server settings -> Request limits.
|
# refused. 4096 is below any real connection; 0 turns the check off. Also on Settings -> Server settings -> Request
|
||||||
|
# limits.
|
||||||
http:
|
http:
|
||||||
min-request-data-rate: 4096
|
min-request-data-rate: 4096
|
||||||
# Stored-backup retention (app-level, not tenant-editable). After a site backup is written, its own
|
# Stored-backup retention (app-level, not tenant-editable). After a site backup is written, its own
|
||||||
|
|||||||
@@ -633,6 +633,15 @@ op.sites.hosts.hint=Comma-separated. Leave empty to make this site reachable onl
|
|||||||
op.sites.base=Base URL
|
op.sites.base=Base URL
|
||||||
op.sites.base.hint=The origin every absolute link of the site is built on: canonical links, the sitemap, structured data, social cards. Leave it empty to use https:// and the first host. Set it when the site is served over http, on another port, or under another of its hosts (www). No path.
|
op.sites.base.hint=The origin every absolute link of the site is built on: canonical links, the sitemap, structured data, social cards. Leave it empty to use https:// and the first host. Set it when the site is served over http, on another port, or under another of its hosts (www). No path.
|
||||||
op.sites.base.row=Links: {0}
|
op.sites.base.row=Links: {0}
|
||||||
|
op.sites.hosts.short=Hosts
|
||||||
|
op.restore.review.title=Review how site {0} is reached
|
||||||
|
op.restore.review.hint=The restore applied the hosts and base URL saved in the backup. Check them, and correct them here if this installation reaches the site differently; saving does what Sites → Edit hosts does.
|
||||||
|
op.restore.review.noHosts=none: the site is reached only as the catch-all default site
|
||||||
|
op.restore.review.unreachable=none: no address reaches this site until you give it a host
|
||||||
|
op.restore.review.noBase=none: there is no host to build it from
|
||||||
|
op.restore.review.derived=not set, so {0} (https:// and the first host)
|
||||||
|
op.restore.review.kept.title=How the site is reached
|
||||||
|
op.restore.review.kept.hint=A restore made here keeps the site's hosts and base URL. Check them: only a platform administrator can change them, on the application console.
|
||||||
op.sites.edit=Edit
|
op.sites.edit=Edit
|
||||||
op.sites.edit.title=Edit site
|
op.sites.edit.title=Edit site
|
||||||
op.sites.edit.locales=Available languages
|
op.sites.edit.locales=Available languages
|
||||||
@@ -1488,7 +1497,7 @@ op.ks.runway.csp.frame-ancestors.help=Which sites may show these pages in a fram
|
|||||||
op.ks.runway.endpoints.max-form-bytes=Largest request before sign-in (bytes)
|
op.ks.runway.endpoints.max-form-bytes=Largest request before sign-in (bytes)
|
||||||
op.ks.runway.endpoints.max-form-bytes.help=The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB).
|
op.ks.runway.endpoints.max-form-bytes.help=The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB).
|
||||||
op.ks.runway.http.min-request-data-rate=Slowest request body (bytes per second)
|
op.ks.runway.http.min-request-data-rate=Slowest request body (bytes per second)
|
||||||
op.ks.runway.http.min-request-data-rate.help=A request body arriving more slowly is answered 408 Request Timeout, so a client sending a byte now and then cannot hold a request thread. Measured on what has arrived since the body's first byte. Default 4096; 0 turns the check off.
|
op.ks.runway.http.min-request-data-rate.help=A request body arriving more slowly is answered 408 Request Timeout: login and other forms, uploads and raw bodies alike, so a client sending a byte now and then cannot keep a request thread. Only time spent waiting for the client counts, and a body that has arrived complete is never refused. Sending part of a body fast earns at most 30 seconds of waiting. Default 4096; 0 turns the check off.
|
||||||
op.ks.runway.endpoints.max-body-bytes=Largest request to a plugin (bytes)
|
op.ks.runway.endpoints.max-body-bytes=Largest request to a plugin (bytes)
|
||||||
op.ks.runway.endpoints.max-body-bytes.help=The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB).
|
op.ks.runway.endpoints.max-body-bytes.help=The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB).
|
||||||
op.ks.spring.servlet.multipart.max-file-size=Largest uploaded file
|
op.ks.spring.servlet.multipart.max-file-size=Largest uploaded file
|
||||||
|
|||||||
@@ -634,6 +634,15 @@ op.sites.hosts.hint=Separados por comas. Déjelo vacío para que el sitio solo s
|
|||||||
op.sites.base=URL base
|
op.sites.base=URL base
|
||||||
op.sites.base.hint=El origen sobre el que se construyen todos los enlaces absolutos del sitio: enlaces canónicos, el mapa del sitio, los datos estructurados y las tarjetas para redes sociales. Déjelo vacío para usar https:// y el primer host. Fíjelo cuando el sitio se sirva por http, en otro puerto o con otro de sus hosts (www). Sin ruta.
|
op.sites.base.hint=El origen sobre el que se construyen todos los enlaces absolutos del sitio: enlaces canónicos, el mapa del sitio, los datos estructurados y las tarjetas para redes sociales. Déjelo vacío para usar https:// y el primer host. Fíjelo cuando el sitio se sirva por http, en otro puerto o con otro de sus hosts (www). Sin ruta.
|
||||||
op.sites.base.row=Enlaces: {0}
|
op.sites.base.row=Enlaces: {0}
|
||||||
|
op.sites.hosts.short=Hosts
|
||||||
|
op.restore.review.title=Revise cómo se llega al sitio {0}
|
||||||
|
op.restore.review.hint=La restauración aplicó los hosts y la URL base guardados en la copia. Revíselos y corríjalos aquí si esta instalación llega al sitio de otra forma; guardar hace lo mismo que Sitios → Editar hosts.
|
||||||
|
op.restore.review.noHosts=ninguno: al sitio solo se llega como sitio predeterminado (catch-all)
|
||||||
|
op.restore.review.unreachable=ninguno: ninguna dirección llega a este sitio hasta que le dé un host
|
||||||
|
op.restore.review.noBase=ninguna: no hay host con el que construirla
|
||||||
|
op.restore.review.derived=sin fijar, así que {0} (https:// y el primer host)
|
||||||
|
op.restore.review.kept.title=Cómo se llega al sitio
|
||||||
|
op.restore.review.kept.hint=Una restauración hecha aquí conserva los hosts y la URL base del sitio. Revíselos: solo un administrador de la plataforma puede cambiarlos, en la consola de la aplicación.
|
||||||
op.sites.edit=Editar
|
op.sites.edit=Editar
|
||||||
op.sites.edit.title=Editar sitio
|
op.sites.edit.title=Editar sitio
|
||||||
op.sites.edit.locales=Idiomas disponibles
|
op.sites.edit.locales=Idiomas disponibles
|
||||||
@@ -1489,7 +1498,7 @@ op.ks.runway.csp.frame-ancestors.help=Qué sitios pueden mostrar estas páginas
|
|||||||
op.ks.runway.endpoints.max-form-bytes=Solicitud máxima sin sesión (bytes)
|
op.ks.runway.endpoints.max-form-bytes=Solicitud máxima sin sesión (bytes)
|
||||||
op.ks.runway.endpoints.max-form-bytes.help=Lo máximo que un visitante sin sesión puede enviar en una solicitud, en cualquier ruta. Por omisión 262144 (256 KiB).
|
op.ks.runway.endpoints.max-form-bytes.help=Lo máximo que un visitante sin sesión puede enviar en una solicitud, en cualquier ruta. Por omisión 262144 (256 KiB).
|
||||||
op.ks.runway.http.min-request-data-rate=Cuerpo de solicitud más lento (bytes por segundo)
|
op.ks.runway.http.min-request-data-rate=Cuerpo de solicitud más lento (bytes por segundo)
|
||||||
op.ks.runway.http.min-request-data-rate.help=Un cuerpo de solicitud que llega más despacio recibe 408 Request Timeout, así que un cliente que envía un byte de vez en cuando no puede ocupar un hilo de solicitud. Se mide sobre lo recibido desde el primer byte del cuerpo. Por omisión 4096; 0 desactiva la comprobación.
|
op.ks.runway.http.min-request-data-rate.help=Un cuerpo de solicitud que llega más despacio recibe 408 Request Timeout: formularios (también el de inicio de sesión), subidas y cuerpos sin formato por igual, así que un cliente que envía un byte de vez en cuando no puede retener un hilo de solicitud. Solo cuenta el tiempo de espera por el cliente, y un cuerpo que ya llegó completo nunca se rechaza. Enviar rápido parte del cuerpo da como máximo 30 segundos de espera. Por omisión 4096; 0 desactiva la comprobación.
|
||||||
op.ks.runway.endpoints.max-body-bytes=Solicitud máxima a un complemento (bytes)
|
op.ks.runway.endpoints.max-body-bytes=Solicitud máxima a un complemento (bytes)
|
||||||
op.ks.runway.endpoints.max-body-bytes.help=Lo máximo que un usuario con sesión puede enviar a una ruta de un complemento. Por omisión 10485760 (10 MiB).
|
op.ks.runway.endpoints.max-body-bytes.help=Lo máximo que un usuario con sesión puede enviar a una ruta de un complemento. Por omisión 10485760 (10 MiB).
|
||||||
op.ks.spring.servlet.multipart.max-file-size=Archivo subido máximo
|
op.ks.spring.servlet.multipart.max-file-size=Archivo subido máximo
|
||||||
|
|||||||
@@ -12,6 +12,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card mb-3 border-primary" id="bk-review">
|
||||||
|
<div class="card-header"><h3 class="card-title" id="bk-review-title">How the site is reached</h3></div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p class="text-secondary" id="bk-review-hint">A restore made here keeps the site's hosts and base URL.
|
||||||
|
Check them; only a platform administrator can change them.</p>
|
||||||
|
<dl class="row mb-0">
|
||||||
|
<dt class="col-sm-2" id="bk-review-l-hosts">Hosts</dt>
|
||||||
|
<dd class="col-sm-10 font-monospace" id="bk-review-hosts">example.com</dd>
|
||||||
|
<dt class="col-sm-2" id="bk-review-l-base">Base URL</dt>
|
||||||
|
<dd class="col-sm-10 font-monospace mb-0" id="bk-review-base">https://example.com</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
|
|||||||
@@ -7,6 +7,15 @@
|
|||||||
<attr sel="#bk-pretitle" th:text="#{op.realm.tenant}"/>
|
<attr sel="#bk-pretitle" th:text="#{op.realm.tenant}"/>
|
||||||
<attr sel="#bk-heading" th:text="#{op.backups.heading}"/>
|
<attr sel="#bk-heading" th:text="#{op.backups.heading}"/>
|
||||||
|
|
||||||
|
<!-- After a restore (${reviewSite}): how the site is reached, read-only — a restore here keeps them. -->
|
||||||
|
<attr sel="#bk-review" th:if="${reviewSite != null}"/>
|
||||||
|
<attr sel="#bk-review-title" th:text="#{op.restore.review.kept.title}"/>
|
||||||
|
<attr sel="#bk-review-hint" th:text="#{op.restore.review.kept.hint}"/>
|
||||||
|
<attr sel="#bk-review-l-hosts" th:text="#{op.sites.hosts.short}"/>
|
||||||
|
<attr sel="#bk-review-hosts" th:text="${reviewSite == null or reviewSite.hosts().isEmpty()} ? (${reviewIsDefault} ? #{op.restore.review.noHosts} : #{op.restore.review.unreachable}) : ${#strings.listJoin(reviewSite.hosts(), ', ')}"/>
|
||||||
|
<attr sel="#bk-review-l-base" th:text="#{op.sites.base}"/>
|
||||||
|
<attr sel="#bk-review-base" th:text="${reviewSite?.baseUrl() != null} ? ${reviewSite.baseUrl()} : (${reviewSite == null or reviewSite.hosts().isEmpty()} ? #{op.restore.review.noBase} : #{op.restore.review.derived('https://' + ${reviewSite.hosts().get(0)})})"/>
|
||||||
|
|
||||||
<attr sel="#bk-l-make" th:text="#{op.backups.make}"/>
|
<attr sel="#bk-l-make" th:text="#{op.backups.make}"/>
|
||||||
<attr sel="#bk-make-hint" th:text="#{op.backups.make.hint}"/>
|
<attr sel="#bk-make-hint" th:text="#{op.backups.make.hint}"/>
|
||||||
<attr sel="#bk-download-now" th:if="${canDownloadFull}" th:text="#{op.backups.downloadNow}"/>
|
<attr sel="#bk-download-now" th:if="${canDownloadFull}" th:text="#{op.backups.downloadNow}"/>
|
||||||
|
|||||||
@@ -16,6 +16,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card mb-3 border-primary" id="ab-review">
|
||||||
|
<div class="card-header"><h3 class="card-title" id="ab-review-title">Review how the site is reached</h3></div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p class="text-secondary" id="ab-review-hint">The restore applied the hosts and base URL saved in the
|
||||||
|
backup. Check them, and correct them here if this installation reaches the site differently.</p>
|
||||||
|
<dl class="row mb-3">
|
||||||
|
<dt class="col-sm-2" id="ab-review-l-hosts">Hosts</dt>
|
||||||
|
<dd class="col-sm-10 font-monospace" id="ab-review-hosts">example.com</dd>
|
||||||
|
<dt class="col-sm-2" id="ab-review-l-base">Base URL</dt>
|
||||||
|
<dd class="col-sm-10 font-monospace" id="ab-review-base">https://example.com</dd>
|
||||||
|
</dl>
|
||||||
|
<form id="ab-review-form" method="post" action="#">
|
||||||
|
<input id="ab-review-csrf" type="hidden" name="_csrf" value="">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<label class="form-label" id="ab-review-l-hosts-input" for="ab-review-hosts-input">Hosts</label>
|
||||||
|
<input class="form-control" id="ab-review-hosts-input" name="hosts" autocomplete="off"
|
||||||
|
placeholder="example.com, www.example.com">
|
||||||
|
<small class="form-hint" id="ab-review-hosts-hint">Comma-separated.</small>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-2">
|
||||||
|
<label class="form-label" id="ab-review-l-base-input" for="ab-review-base-input">Base URL</label>
|
||||||
|
<input class="form-control" id="ab-review-base-input" name="baseUrl" type="url" maxlength="300"
|
||||||
|
autocomplete="off" spellcheck="false">
|
||||||
|
<small class="form-hint" id="ab-review-base-hint">The origin of the site's absolute links.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary" id="ab-review-save">Save hosts</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<div class="card-header"><h3 class="card-title" id="cs-l">Create a site from a backup</h3></div>
|
<div class="card-header"><h3 class="card-title" id="cs-l">Create a site from a backup</h3></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|||||||
@@ -5,6 +5,27 @@
|
|||||||
<attr sel="#ab-pretitle" th:text="#{op.realm.application}"/>
|
<attr sel="#ab-pretitle" th:text="#{op.realm.application}"/>
|
||||||
<attr sel="#ab-heading" th:text="#{op.appbackups.heading}"/>
|
<attr sel="#ab-heading" th:text="#{op.appbackups.heading}"/>
|
||||||
|
|
||||||
|
<!-- After a restore or a site created from a backup (${reviewSite}): the site's hosts and base URL as they stand,
|
||||||
|
with the same editor as Sites -> Edit hosts (it posts there, so that route's checks and activity line apply).
|
||||||
|
Restoring here already required a platform administrator, who may edit any site's hosts. -->
|
||||||
|
<attr sel="#ab-review" th:if="${reviewSite != null}"/>
|
||||||
|
<attr sel="#ab-review-title" th:text="#{op.restore.review.title(${reviewSite?.id()})}"/>
|
||||||
|
<attr sel="#ab-review-hint" th:text="#{op.restore.review.hint}"/>
|
||||||
|
<attr sel="#ab-review-l-hosts" th:text="#{op.sites.hosts.short}"/>
|
||||||
|
<attr sel="#ab-review-hosts" th:text="${reviewSite == null or reviewSite.hosts().isEmpty()} ? (${reviewIsDefault} ? #{op.restore.review.noHosts} : #{op.restore.review.unreachable}) : ${#strings.listJoin(reviewSite.hosts(), ', ')}"/>
|
||||||
|
<attr sel="#ab-review-l-base" th:text="#{op.sites.base}"/>
|
||||||
|
<attr sel="#ab-review-base" th:text="${reviewSite?.baseUrl() != null} ? ${reviewSite.baseUrl()} : (${reviewSite == null or reviewSite.hosts().isEmpty()} ? #{op.restore.review.noBase} : #{op.restore.review.derived('https://' + ${reviewSite.hosts().get(0)})})"/>
|
||||||
|
<attr sel="#ab-review-form" th:attr="action='/__app/sites/' + ${reviewSite?.id()} + '/hosts'"/>
|
||||||
|
<attr sel="#ab-review-csrf"
|
||||||
|
th:attr="name=${_csrf != null ? _csrf.parameterName : '_csrf'},value=${_csrf != null ? _csrf.token : ''}"/>
|
||||||
|
<attr sel="#ab-review-l-hosts-input" th:text="#{op.sites.hosts}"/>
|
||||||
|
<attr sel="#ab-review-hosts-input" th:attr="value=${reviewSite == null ? '' : #strings.listJoin(reviewSite.hosts(), ', ')}"/>
|
||||||
|
<attr sel="#ab-review-hosts-hint" th:text="#{op.sites.hosts.hint}"/>
|
||||||
|
<attr sel="#ab-review-l-base-input" th:text="#{op.sites.base}"/>
|
||||||
|
<attr sel="#ab-review-base-input" th:attr="value=${reviewSite?.baseUrl()},placeholder=${reviewSite == null or reviewSite.hosts().isEmpty() ? '' : 'https://' + reviewSite.hosts().get(0)}"/>
|
||||||
|
<attr sel="#ab-review-base-hint" th:text="#{op.sites.base.hint}"/>
|
||||||
|
<attr sel="#ab-review-save" th:text="#{op.sites.hosts.save}"/>
|
||||||
|
|
||||||
<attr sel="#cs-l" th:text="#{op.appbackups.create}"/>
|
<attr sel="#cs-l" th:text="#{op.appbackups.create}"/>
|
||||||
<attr sel="#cs-hint" th:text="#{op.appbackups.create.hint}"/>
|
<attr sel="#cs-hint" th:text="#{op.appbackups.create.hint}"/>
|
||||||
<attr sel="#cs-csrf"
|
<attr sel="#cs-csrf"
|
||||||
|
|||||||
@@ -131,6 +131,64 @@ class AppBackupsScreenTest {
|
|||||||
assertTrue(sites.exists("acme"), "the source site is untouched");
|
assertTrue(sites.exists("acme"), "the source site is untouched");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A restore applies the hosts and base URL saved in the backup, so the screen then shows them for review with the
|
||||||
|
* hosts editor; saving it goes through Sites -> Edit hosts and changes the site.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void aRestoreIsFollowedByTheRestoredHostsWithTheirEditor() throws Exception {
|
||||||
|
Site original = sites.find("acme").orElseThrow();
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
backups.backup("acme", baos); // carries acme.test and https://acme.test
|
||||||
|
try {
|
||||||
|
sites.save(new Site("acme", "Acme", List.of("acme.live"), Locale.ENGLISH, List.of(Locale.ENGLISH), null,
|
||||||
|
SiteStatus.ACTIVE));
|
||||||
|
MockHttpSession admin = sessionFor("admin");
|
||||||
|
MockMultipartFile file = new MockMultipartFile("file", "acme.zip", "application/zip", baos.toByteArray());
|
||||||
|
mvc.perform(multipart("/__app/backups/acme/restore").file(file).session(admin)
|
||||||
|
.with(csrf()))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(flash().attribute(AppBackupsController.REVIEW_HOSTS, "acme"));
|
||||||
|
|
||||||
|
String page = mvc.perform(get("/__app/backups").session(admin))
|
||||||
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||||
|
assertTrue(page.contains("Review how site acme is reached"), "the review card is shown");
|
||||||
|
assertTrue(page.contains(">acme.test<"), "the hosts as restored from the backup, not acme.live");
|
||||||
|
assertTrue(page.contains(">https://acme.test<"), "the restored base URL");
|
||||||
|
assertTrue(page.contains("action=\"/__app/sites/acme/hosts\""), "the editor posts to Sites -> Edit hosts");
|
||||||
|
assertTrue(page.contains("value=\"acme.test\""), "the editor starts from the hosts as they stand");
|
||||||
|
|
||||||
|
String plain = mvc.perform(get("/__app/backups").session(admin))
|
||||||
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||||
|
assertFalse(plain.contains("Review how site"), "no review card without a restore");
|
||||||
|
|
||||||
|
mvc.perform(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post("/__app/sites/acme/hosts")
|
||||||
|
.session(admin).with(csrf()).param("hosts", "acme.fixed").param("baseUrl", ""))
|
||||||
|
.andExpect(status().is3xxRedirection());
|
||||||
|
assertEquals(List.of("acme.fixed"), sites.find("acme").orElseThrow().hosts(), "corrected from the review");
|
||||||
|
} finally {
|
||||||
|
sites.save(original);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A site created from a backup without hosts is not the default site: the review says nothing reaches it. */
|
||||||
|
@Test
|
||||||
|
void aSiteCreatedWithoutHostsIsReportedUnreachableNotAsTheDefault() throws Exception {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
backups.backup("acme", baos);
|
||||||
|
MockHttpSession admin = sessionFor("admin");
|
||||||
|
MockMultipartFile file = new MockMultipartFile("file", "acme.zip", "application/zip", baos.toByteArray());
|
||||||
|
mvc.perform(multipart("/__app/backups/create-site").file(file).session(admin).with(csrf())
|
||||||
|
.param("newId", "hostless").param("name", "Hostless").param("hosts", ""))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(flash().attribute(AppBackupsController.REVIEW_HOSTS, "hostless"));
|
||||||
|
String page = mvc.perform(get("/__app/backups").session(admin))
|
||||||
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||||
|
assertTrue(page.contains("Review how site hostless is reached"));
|
||||||
|
assertTrue(page.contains("none: no address reaches this site until you give it a host"), "not the default");
|
||||||
|
assertFalse(page.contains("catch-all default site"), "it is not the default site");
|
||||||
|
}
|
||||||
|
|
||||||
/** An archive from a newer Runway: the operator is told to upgrade, and nothing is replaced or created. */
|
/** An archive from a newer Runway: the operator is told to upgrade, and nothing is replaced or created. */
|
||||||
@Test
|
@Test
|
||||||
void aNewerFormatBackupIsRefusedWithTheUpgradeMessage() throws Exception {
|
void aNewerFormatBackupIsRefusedWithTheUpgradeMessage() throws Exception {
|
||||||
|
|||||||
@@ -284,6 +284,31 @@ class TenantBackupsScreenTest {
|
|||||||
assertEquals("ORIGINAL_CONTENT", Files.readString(home, StandardCharsets.UTF_8), "the page was restored");
|
assertEquals("ORIGINAL_CONTENT", Files.readString(home, StandardCharsets.UTF_8), "the page was restored");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** After a restore the screen shows how the site is reached, read-only: a restore here keeps the hosts. */
|
||||||
|
@Test
|
||||||
|
void aRestoreIsFollowedByTheSitesHostsForReview() throws Exception {
|
||||||
|
MockHttpSession admin = sessionFor("admin");
|
||||||
|
mvc.perform(post("/__admin/backups/create").session(admin).with(csrf())).andExpect(status().is3xxRedirection());
|
||||||
|
mvc.perform(get("/__admin/backups").session(admin)).andExpect(status().isOk()); // the create's redirect
|
||||||
|
String name = backups.list("acme").get(0).name();
|
||||||
|
mvc.perform(post("/__admin/backups/" + name + "/restore").session(admin).with(csrf()))
|
||||||
|
.andExpect(status().is3xxRedirection())
|
||||||
|
.andExpect(flash().attribute(AppBackupsController.REVIEW_HOSTS, Boolean.TRUE));
|
||||||
|
|
||||||
|
MvcResult shown = mvc.perform(get("/__admin/backups").session(admin)).andExpect(status().isOk()).andReturn();
|
||||||
|
String page = shown.getResponse().getContentAsString();
|
||||||
|
assertTrue(page.contains("id=\"bk-review\""), "the review card is shown");
|
||||||
|
assertTrue(page.contains("How the site is reached"));
|
||||||
|
assertTrue(page.contains("only a platform administrator can change them"));
|
||||||
|
assertTrue(page.contains(">localhost<"), "the site's host");
|
||||||
|
assertTrue(page.contains("not set, so https://localhost (https:// and the first host)"), "the derived base URL");
|
||||||
|
assertTrue(!page.contains("/__app/sites/acme/hosts"), "no editor on the site console");
|
||||||
|
|
||||||
|
String plain = mvc.perform(get("/__admin/backups").session(admin))
|
||||||
|
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
|
||||||
|
assertTrue(!plain.contains("id=\"bk-review\""), "no review card without a restore");
|
||||||
|
}
|
||||||
|
|
||||||
/** An archive from a newer Runway is refused on both restore paths, with the upgrade message. */
|
/** An archive from a newer Runway is refused on both restore paths, with the upgrade message. */
|
||||||
@Test
|
@Test
|
||||||
void aNewerFormatBackupIsRefusedWithTheUpgradeMessage() throws Exception {
|
void aNewerFormatBackupIsRefusedWithTheUpgradeMessage() throws Exception {
|
||||||
|
|||||||
@@ -26,16 +26,18 @@ import org.springframework.boot.web.server.WebServer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum request data rate, against a real Jetty: a body trickled in is cut with {@code 408} instead of holding a
|
* The minimum request data rate, against a real Jetty: a body trickled in is cut with {@code 408} instead of holding a
|
||||||
* request thread, and a server that is slow to start reading is not blamed for it. Guards the behaviour across Jetty
|
* request thread, whether the servlet reads the stream, form parameters or multipart parts, and a server that is slow
|
||||||
* upgrades, since the rate check is Jetty's.
|
* to start reading is not blamed for it. The check is {@link RequestBodyRateHandler}'s; Jetty's own is turned off.
|
||||||
*/
|
*/
|
||||||
class SlowClientConfigTest {
|
class SlowClientConfigTest {
|
||||||
|
|
||||||
/** The bean, as Spring binds and applies it: the property, the clamp, and every connector of Boot's own Jetty. */
|
/** The bean, as Spring binds and applies it: the property, the clamp, and every connector of Boot's own Jetty. */
|
||||||
@Test
|
@Test
|
||||||
void theBoundPropertyReachesEveryConnectorOfTheServerBootBuilds() throws Exception {
|
void theBoundPropertyReachesEveryConnectorOfTheServerBootBuilds() throws Exception {
|
||||||
assertThat(rateOnBootsServer("1024")).containsOnly(1024L).isNotEmpty();
|
assertThat(rateOnBootsServer("1024")).as("Jetty's own check off on every connector; ours in Boot's chain")
|
||||||
assertThat(rateOnBootsServer("-5")).as("a negative value is clamped to off").containsOnly(0L);
|
.containsOnly(0L, 1024L * 1_000_000).contains(0L, 1024L * 1_000_000);
|
||||||
|
assertThat(rateOnBootsServer("-5")).as("a negative value is clamped to off, and no handler is installed")
|
||||||
|
.containsOnly(0L).isNotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private java.util.List<Long> rateOnBootsServer(String configured) throws Exception {
|
private java.util.List<Long> rateOnBootsServer(String configured) throws Exception {
|
||||||
@@ -55,6 +57,13 @@ class SlowClientConfigTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The handler chain, outermost first: a RequestBodyRateHandler is reported as its rate x 1_000_000.
|
||||||
|
for (org.eclipse.jetty.server.Handler h = ((JettyWebServer) web).getServer().getHandler(); h != null;
|
||||||
|
h = h instanceof org.eclipse.jetty.server.Handler.Wrapper w ? w.getHandler() : null) {
|
||||||
|
if (h instanceof RequestBodyRateHandler rate) {
|
||||||
|
rates.add(rate.bytesPerSecond() * 1_000_000);
|
||||||
|
}
|
||||||
|
}
|
||||||
return rates;
|
return rates;
|
||||||
} finally {
|
} finally {
|
||||||
web.stop();
|
web.stop();
|
||||||
@@ -70,27 +79,66 @@ class SlowClientConfigTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** How the servlet reads the body: the input stream (Jetty's own check), form parameters, or multipart parts. */
|
||||||
|
private enum Body { STREAM, FORM, MULTIPART, SWALLOWED, ESCAPED }
|
||||||
|
|
||||||
/** A server whose servlet reads the whole body after {@code pauseMillis}, with the rate applied by the config. */
|
/** A server whose servlet reads the whole body after {@code pauseMillis}, with the rate applied by the config. */
|
||||||
private int start(long bytesPerSecond, long pauseMillis) throws Exception {
|
private int start(long bytesPerSecond, long pauseMillis) throws Exception {
|
||||||
|
return start(bytesPerSecond, pauseMillis, Body.STREAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int start(long bytesPerSecond, long pauseMillis, Body body) throws Exception {
|
||||||
|
return start(bytesPerSecond, pauseMillis, body, RequestBodyRateHandler.CREDIT_SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int start(long bytesPerSecond, long pauseMillis, Body body, long creditSeconds) throws Exception {
|
||||||
server = new Server();
|
server = new Server();
|
||||||
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
|
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
|
||||||
connector.setPort(0);
|
connector.setPort(0);
|
||||||
connector.setIdleTimeout(30_000);
|
connector.setIdleTimeout(30_000);
|
||||||
server.addConnector(connector);
|
server.addConnector(connector);
|
||||||
ServletContextHandler context = new ServletContextHandler();
|
ServletContextHandler context = new ServletContextHandler();
|
||||||
context.addServlet(new ServletHolder(new HttpServlet() {
|
ServletHolder holder = new ServletHolder(new HttpServlet() {
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws IOException, jakarta.servlet.ServletException {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(pauseMillis);
|
Thread.sleep(pauseMillis);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
response.getWriter().write("read " + request.getInputStream().readAllBytes().length);
|
String read = switch (body) {
|
||||||
|
case STREAM -> "read " + request.getInputStream().readAllBytes().length;
|
||||||
|
case FORM -> "a=" + request.getParameter("a").length();
|
||||||
|
case MULTIPART -> "parts " + request.getParts().size();
|
||||||
|
case SWALLOWED -> { // the read fails and the code carries on as if nothing happened
|
||||||
|
try {
|
||||||
|
request.getInputStream().readAllBytes();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
// swallowed on purpose
|
||||||
|
}
|
||||||
|
yield "fine";
|
||||||
|
}
|
||||||
|
case ESCAPED -> { // the failure escapes, as from a filter that reads the stream itself
|
||||||
|
request.getInputStream().readAllBytes();
|
||||||
|
yield "unreachable";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
response.getWriter().write(read);
|
||||||
}
|
}
|
||||||
}), "/*");
|
});
|
||||||
|
if (body == Body.MULTIPART) {
|
||||||
|
holder.getRegistration().setMultipartConfig(new jakarta.servlet.MultipartConfigElement(""));
|
||||||
|
}
|
||||||
|
context.addServlet(holder, "/*");
|
||||||
server.setHandler(context);
|
server.setHandler(context);
|
||||||
assertThat(SlowClientConfig.apply(server, bytesPerSecond)).isEqualTo(1);
|
assertThat(SlowClientConfig.apply(server, bytesPerSecond)).isEqualTo(1);
|
||||||
|
if (creditSeconds != RequestBodyRateHandler.CREDIT_SECONDS
|
||||||
|
&& server.getHandler() instanceof RequestBodyRateHandler installed) {
|
||||||
|
RequestBodyRateHandler shortCredit = new RequestBodyRateHandler(bytesPerSecond, creditSeconds);
|
||||||
|
shortCredit.setHandler(installed.getHandler());
|
||||||
|
server.setHandler(shortCredit);
|
||||||
|
}
|
||||||
server.start();
|
server.start();
|
||||||
return connector.getLocalPort();
|
return connector.getLocalPort();
|
||||||
}
|
}
|
||||||
@@ -136,6 +184,133 @@ class SlowClientConfigTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Sends {@code head}, then {@code drip} one byte a second until the server answers or 20 bytes are sent. */
|
||||||
|
private static String drip(int port, String head) throws Exception {
|
||||||
|
long started = System.nanoTime();
|
||||||
|
try (Socket socket = new Socket("127.0.0.1", port)) {
|
||||||
|
OutputStream out = socket.getOutputStream();
|
||||||
|
out.write(head.getBytes(StandardCharsets.US_ASCII));
|
||||||
|
out.flush();
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
out.write('a');
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
} catch (IOException closedByServer) {
|
||||||
|
// expected: answered and closed while the client was still trickling
|
||||||
|
}
|
||||||
|
String status = statusLine(socket);
|
||||||
|
assertThat(Duration.ofNanos(System.nanoTime() - started)).as("cut long before the idle timeout")
|
||||||
|
.isLessThan(Duration.ofSeconds(15));
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aTrickledFormIsCutToo() throws Exception {
|
||||||
|
// 1.1.0: form parameters were read past Jetty's own check, and this request was held for the idle timeout.
|
||||||
|
int port = start(1024, 0, Body.FORM);
|
||||||
|
assertThat(drip(port, "POST / HTTP/1.1\r\nHost: x\r\nContent-Type: application/x-www-form-urlencoded\r\n"
|
||||||
|
+ "Content-Length: 1000\r\nConnection: close\r\n\r\na=")).isEqualTo("HTTP/1.1 408 Request Timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aTrickledMultipartBodyIsCutToo() throws Exception {
|
||||||
|
int port = start(1024, 0, Body.MULTIPART);
|
||||||
|
assertThat(drip(port, "POST / HTTP/1.1\r\nHost: x\r\nContent-Type: multipart/form-data; boundary=XyZ\r\n"
|
||||||
|
+ "Content-Length: 1000\r\nConnection: close\r\n\r\n--XyZ\r\n"
|
||||||
|
+ "Content-Disposition: form-data; name=\"a\"\r\n\r\n")).isEqualTo("HTTP/1.1 408 Request Timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aRefusedBodyIsAnswered408HoweverTheCodeHandledTheFailedRead() throws Exception {
|
||||||
|
// Measured on 1.1.1-SNAPSHOT before this guard: a route reading the stream itself answered an empty 200.
|
||||||
|
for (Body body : new Body[] {Body.SWALLOWED, Body.ESCAPED}) {
|
||||||
|
int port = start(4096, 0, body);
|
||||||
|
assertThat(drip(port, "POST / HTTP/1.1\r\nHost: x\r\nContent-Type: application/octet-stream\r\n"
|
||||||
|
+ "Content-Length: 1000\r\nConnection: close\r\n\r\n")).as(body.name())
|
||||||
|
.isEqualTo("HTTP/1.1 408 Request Timeout");
|
||||||
|
server.stop();
|
||||||
|
server = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aBodySentFastAtFirstCannotBuyALongDripLater() throws Exception {
|
||||||
|
// 32 KiB at line speed, then a byte a second: averaged over the whole body (1.1.0, and this fix's first form)
|
||||||
|
// that bought 32 s of dripping at 1 KiB/s, and with 16 MiB over an hour. The credit is capped (2 s here).
|
||||||
|
int port = start(1024, 0, Body.FORM, 2);
|
||||||
|
long started = System.nanoTime();
|
||||||
|
try (Socket socket = new Socket("127.0.0.1", port)) {
|
||||||
|
OutputStream out = socket.getOutputStream();
|
||||||
|
out.write(("POST / HTTP/1.1\r\nHost: x\r\nContent-Type: application/x-www-form-urlencoded\r\n"
|
||||||
|
+ "Content-Length: 65536\r\nConnection: close\r\n\r\na=" + "b".repeat(32 * 1024))
|
||||||
|
.getBytes(StandardCharsets.US_ASCII));
|
||||||
|
out.flush();
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
out.write('c');
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
} catch (IOException closedByServer) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
assertThat(statusLine(socket)).isEqualTo("HTTP/1.1 408 Request Timeout");
|
||||||
|
}
|
||||||
|
assertThat(Duration.ofNanos(System.nanoTime() - started)).isLessThan(Duration.ofSeconds(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aSmallFormWhoseOnlyPacketArrivesLateIsAccepted() throws Exception {
|
||||||
|
// A network stall before the body: the body then arrives whole, so no thread is held by a slow client.
|
||||||
|
int port = start(1024, 0, Body.FORM);
|
||||||
|
try (Socket socket = new Socket("127.0.0.1", port)) {
|
||||||
|
OutputStream out = socket.getOutputStream();
|
||||||
|
out.write(("POST / HTTP/1.1\r\nHost: x\r\nContent-Type: application/x-www-form-urlencoded\r\n"
|
||||||
|
+ "Content-Length: 12\r\nConnection: close\r\n\r\n").getBytes(StandardCharsets.US_ASCII));
|
||||||
|
out.flush();
|
||||||
|
Thread.sleep(2500);
|
||||||
|
out.write("a=1234567890".getBytes(StandardCharsets.US_ASCII));
|
||||||
|
out.flush();
|
||||||
|
assertThat(statusLine(socket)).isEqualTo("HTTP/1.1 200 OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aLargeFormAtAGoodRateIsAccepted() throws Exception {
|
||||||
|
int port = start(4096, 0, Body.FORM);
|
||||||
|
int size = 64 * 1024;
|
||||||
|
try (Socket socket = new Socket("127.0.0.1", port)) {
|
||||||
|
OutputStream out = socket.getOutputStream();
|
||||||
|
out.write(("POST / HTTP/1.1\r\nHost: x\r\nContent-Type: application/x-www-form-urlencoded\r\n"
|
||||||
|
+ "Content-Length: " + (size + 2) + "\r\nConnection: close\r\n\r\na=")
|
||||||
|
.getBytes(StandardCharsets.US_ASCII));
|
||||||
|
for (int i = 0; i < size / 4096; i++) { // 4 KiB every 100 ms: 40 KiB/s, ten times the minimum
|
||||||
|
out.write("b".repeat(4096).getBytes(StandardCharsets.US_ASCII));
|
||||||
|
out.flush();
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
socket.setSoTimeout(10_000);
|
||||||
|
String response = new String(socket.getInputStream().readAllBytes(), StandardCharsets.US_ASCII);
|
||||||
|
assertThat(response).startsWith("HTTP/1.1 200 OK").endsWith("a=" + size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aFormServerSlowToReadIsNotBlamed() throws Exception {
|
||||||
|
int port = start(1024, 3000, Body.FORM);
|
||||||
|
try (Socket socket = new Socket("127.0.0.1", port)) {
|
||||||
|
OutputStream out = socket.getOutputStream();
|
||||||
|
out.write(("POST / HTTP/1.1\r\nHost: x\r\nContent-Type: application/x-www-form-urlencoded\r\n"
|
||||||
|
+ "Content-Length: 102\r\nConnection: close\r\n\r\na=" + "c".repeat(100))
|
||||||
|
.getBytes(StandardCharsets.US_ASCII));
|
||||||
|
out.flush();
|
||||||
|
assertThat(statusLine(socket)).isEqualTo("HTTP/1.1 200 OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void theDefaultIsFourKilobytesPerSecond() {
|
void theDefaultIsFourKilobytesPerSecond() {
|
||||||
assertThat(new SlowClientConfig.HttpLimitProperties().getMinRequestDataRate()).isEqualTo(4096);
|
assertThat(new SlowClientConfig.HttpLimitProperties().getMinRequestDataRate()).isEqualTo(4096);
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package mx.quest.runway.web;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
import mx.quest.runway.security.PasswordEncoders;
|
||||||
|
import mx.quest.runway.security.PasswordStrength;
|
||||||
|
import mx.quest.runway.security.Roles;
|
||||||
|
import mx.quest.runway.security.User;
|
||||||
|
import mx.quest.runway.security.UserStore;
|
||||||
|
import mx.quest.runway.site.Site;
|
||||||
|
import mx.quest.runway.site.SiteStatus;
|
||||||
|
import mx.quest.runway.site.SiteStore;
|
||||||
|
import mx.quest.runway.spi.model.Realm;
|
||||||
|
import mx.quest.runway.storage.StorageLayout;
|
||||||
|
import mx.quest.runway.storage.StorageProperties;
|
||||||
|
import mx.quest.runway.storage.YamlStore;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||||
|
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||||
|
import org.springframework.test.context.DynamicPropertySource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The slow-body limit on the running application, where it was missing in 1.1.0: the login forms of both realms and a
|
||||||
|
* multipart post, trickled in, are answered {@code 408} within seconds instead of holding a request thread until the
|
||||||
|
* idle timeout. Through the whole chain (Spring Security reads the login form), which a bare Jetty cannot stand in
|
||||||
|
* for: there, a refused read that the chain treats as a client gone away was answered an empty {@code 200}.
|
||||||
|
*/
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
class SlowRequestBodyEndToEndTest {
|
||||||
|
|
||||||
|
private static final String HOST = "localhost";
|
||||||
|
/** The console is never served on a site's host; this one is no site's. */
|
||||||
|
private static final String CONSOLE_HOST = "127.0.0.1";
|
||||||
|
|
||||||
|
@DynamicPropertySource
|
||||||
|
static void config(DynamicPropertyRegistry registry) throws IOException {
|
||||||
|
Path external = Files.createTempDirectory("runway-slow-body");
|
||||||
|
StorageProperties props = new StorageProperties();
|
||||||
|
props.setExternal(external);
|
||||||
|
YamlStore yaml = new YamlStore();
|
||||||
|
new SiteStore(StorageLayout.from(props), yaml).save(new Site("acme", "Acme", List.of(HOST), Locale.ENGLISH,
|
||||||
|
List.of(Locale.ENGLISH), null, SiteStatus.ACTIVE, false, null));
|
||||||
|
String hash = PasswordEncoders.argon2id(PasswordStrength.STANDARD).encode("Slow-Body-7x");
|
||||||
|
new UserStore(yaml).save(external.resolve("app-users.yml"),
|
||||||
|
new User("app-master", "root", hash, "Root", "", true, true, Realm.APPLICATION,
|
||||||
|
Set.of(Roles.SYSTEM_SUPERADMIN), List.of()));
|
||||||
|
registry.add("runway.storage.external", () -> external.toString());
|
||||||
|
registry.add("runway.security.app-master-id", () -> "app-master");
|
||||||
|
registry.add("runway.health.content-check", () -> "false");
|
||||||
|
registry.add("runway.http.min-request-data-rate", () -> "1024");
|
||||||
|
}
|
||||||
|
|
||||||
|
@LocalServerPort
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
/** Sends the head of a 1000-byte body, then one byte a second; returns the status line and how long it took. */
|
||||||
|
private String drip(String path, String contentType, String bodyStart) throws Exception {
|
||||||
|
String host = path.startsWith("/app/") ? CONSOLE_HOST : HOST;
|
||||||
|
long started = System.nanoTime();
|
||||||
|
try (Socket socket = new Socket("127.0.0.1", port)) {
|
||||||
|
OutputStream out = socket.getOutputStream();
|
||||||
|
out.write(("POST " + path + " HTTP/1.1\r\nHost: " + host + "\r\nContent-Type: " + contentType
|
||||||
|
+ "\r\nContent-Length: 1000\r\nConnection: close\r\n\r\n" + bodyStart)
|
||||||
|
.getBytes(StandardCharsets.US_ASCII));
|
||||||
|
out.flush();
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < 20; i++) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
out.write('a');
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
} catch (IOException closedByServer) {
|
||||||
|
// expected: answered and closed while the client was still trickling
|
||||||
|
}
|
||||||
|
socket.setSoTimeout(40_000);
|
||||||
|
String response = new String(socket.getInputStream().readAllBytes(), StandardCharsets.US_ASCII);
|
||||||
|
assertThat(Duration.ofNanos(System.nanoTime() - started)).as(path + ": cut long before the idle timeout")
|
||||||
|
.isLessThan(Duration.ofSeconds(15));
|
||||||
|
return response.isEmpty() ? "" : response.substring(0, response.indexOf("\r\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aTrickledSiteLoginIsAnswered408() throws Exception {
|
||||||
|
assertThat(drip("/login", "application/x-www-form-urlencoded", "username="))
|
||||||
|
.isEqualTo("HTTP/1.1 408 Request Timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aTrickledConsoleLoginIsAnswered408() throws Exception {
|
||||||
|
assertThat(drip("/app/login", "application/x-www-form-urlencoded", "username="))
|
||||||
|
.isEqualTo("HTTP/1.1 408 Request Timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aTrickledMultipartPostIsAnswered408() throws Exception {
|
||||||
|
assertThat(drip("/app/login", "multipart/form-data; boundary=XyZ",
|
||||||
|
"--XyZ\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\n"))
|
||||||
|
.isEqualTo("HTTP/1.1 408 Request Timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aLoginSentAtOnceIsNotTouched() throws Exception {
|
||||||
|
try (Socket socket = new Socket("127.0.0.1", port)) {
|
||||||
|
String body = "username=root&password=wrong";
|
||||||
|
socket.getOutputStream().write(("POST /app/login HTTP/1.1\r\nHost: " + CONSOLE_HOST
|
||||||
|
+ "\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: " + body.length()
|
||||||
|
+ "\r\nConnection: close\r\n\r\n" + body).getBytes(StandardCharsets.US_ASCII));
|
||||||
|
socket.setSoTimeout(10_000);
|
||||||
|
String response = new String(socket.getInputStream().readAllBytes(), StandardCharsets.US_ASCII);
|
||||||
|
assertThat(response).as("refused for its missing CSRF token, as before: not a slow body")
|
||||||
|
.startsWith("HTTP/1.1 403");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>mx.quest</groupId>
|
<groupId>mx.quest</groupId>
|
||||||
<artifactId>runway</artifactId>
|
<artifactId>runway</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>runway-dist</artifactId>
|
<artifactId>runway-dist</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ name: Essential Protection
|
|||||||
# The essential plugin ships with the kernel, in the same release, on the kernel's version line (docs/SPI-STABILITY.md,
|
# The essential plugin ships with the kernel, in the same release, on the kernel's version line (docs/SPI-STABILITY.md,
|
||||||
# "The essential-plugin exception"): its version is the kernel's plain MAJOR.MINOR.PATCH. Seeding compares SHA-256
|
# "The essential-plugin exception"): its version is the kernel's plain MAJOR.MINOR.PATCH. Seeding compares SHA-256
|
||||||
# hashes, not versions, and no plugin may `requires:` an essential plugin, so nothing keys on it.
|
# hashes, not versions, and no plugin may `requires:` an essential plugin, so nothing keys on it.
|
||||||
version: 1.1.0
|
version: 1.1.1
|
||||||
essential: true
|
essential: true
|
||||||
# The mandatory floor (SPI 1.0.0): every plugin with a mainClass declares one; the kernel's own plugin declares the
|
# The mandatory floor (SPI 1.0.0): every plugin with a mainClass declares one; the kernel's own plugin declares the
|
||||||
# SPI major's floor (>=1.0.0, met by every 1.x kernel; raised only when it uses a newer SPI member), so the floor rule
|
# SPI major's floor (>=1.0.0, met by every 1.x kernel; raised only when it uses a newer SPI member), so the floor rule
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>mx.quest</groupId>
|
<groupId>mx.quest</groupId>
|
||||||
<artifactId>runway</artifactId>
|
<artifactId>runway</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>runway-plugin-protection</artifactId>
|
<artifactId>runway-plugin-protection</artifactId>
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ class ProtectionDescriptorK4Test {
|
|||||||
PluginDescriptor descriptor = shipped();
|
PluginDescriptor descriptor = shipped();
|
||||||
assertEquals("protection", descriptor.id());
|
assertEquals("protection", descriptor.id());
|
||||||
assertTrue(descriptor.isEssential());
|
assertTrue(descriptor.isEssential());
|
||||||
assertEquals("1.1.0", descriptor.version(), "versioned on the kernel's line");
|
assertEquals("1.1.1", descriptor.version(), "versioned on the kernel's line");
|
||||||
assertEquals(PluginVersion.parse("1.0.0"), descriptor.spiFloor());
|
assertEquals(PluginVersion.parse("1.0.0"), descriptor.spiFloor());
|
||||||
assertEquals(PluginVersion.parse(RunwaySpi.VERSION).major(), descriptor.spiFloor().major(),
|
assertEquals(PluginVersion.parse(RunwaySpi.VERSION).major(), descriptor.spiFloor().major(),
|
||||||
"the floor names the kernel's own SPI major line");
|
"the floor names the kernel's own SPI major line");
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>mx.quest</groupId>
|
<groupId>mx.quest</groupId>
|
||||||
<artifactId>runway</artifactId>
|
<artifactId>runway</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>runway-spi-testkit</artifactId>
|
<artifactId>runway-spi-testkit</artifactId>
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>mx.quest</groupId>
|
<groupId>mx.quest</groupId>
|
||||||
<artifactId>runway</artifactId>
|
<artifactId>runway</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>runway-spi</artifactId>
|
<artifactId>runway-spi</artifactId>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ S = [
|
|||||||
("runway.csp.form-action","string","'self'",None,"server.csp",True,None,"form-action","Where forms may submit.","form-action","A dónde pueden enviarse los formularios."),
|
("runway.csp.form-action","string","'self'",None,"server.csp",True,None,"form-action","Where forms may submit.","form-action","A dónde pueden enviarse los formularios."),
|
||||||
("runway.csp.frame-ancestors","string","'self'",None,"server.csp",True,None,"frame-ancestors","Which sites may show these pages in a frame. 'none' forbids all.","frame-ancestors","Qué sitios pueden mostrar estas páginas en un marco. 'none' lo prohíbe."),
|
("runway.csp.frame-ancestors","string","'self'",None,"server.csp",True,None,"frame-ancestors","Which sites may show these pages in a frame. 'none' forbids all.","frame-ancestors","Qué sitios pueden mostrar estas páginas en un marco. 'none' lo prohíbe."),
|
||||||
("runway.endpoints.max-form-bytes","int","262144","1024..104857600","server.limits",False,None,"Largest request before sign-in (bytes)","The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB).","Solicitud máxima sin sesión (bytes)","Lo máximo que un visitante sin sesión puede enviar en una solicitud, en cualquier ruta. Por omisión 262144 (256 KiB)."),
|
("runway.endpoints.max-form-bytes","int","262144","1024..104857600","server.limits",False,None,"Largest request before sign-in (bytes)","The most a visitor who is not signed in may send in one request, on any path. Default 262144 (256 KiB).","Solicitud máxima sin sesión (bytes)","Lo máximo que un visitante sin sesión puede enviar en una solicitud, en cualquier ruta. Por omisión 262144 (256 KiB)."),
|
||||||
("runway.http.min-request-data-rate","int","4096","0..1048576","server.limits",True,None,"Slowest request body (bytes per second)","A request body arriving more slowly is answered 408 Request Timeout, so a client sending a byte now and then cannot hold a request thread. Measured on what has arrived since the body's first byte. Default 4096; 0 turns the check off.","Cuerpo de solicitud más lento (bytes por segundo)","Un cuerpo de solicitud que llega más despacio recibe 408 Request Timeout, así que un cliente que envía un byte de vez en cuando no puede ocupar un hilo de solicitud. Se mide sobre lo recibido desde el primer byte del cuerpo. Por omisión 4096; 0 desactiva la comprobación."),
|
("runway.http.min-request-data-rate","int","4096","0..1048576","server.limits",True,None,"Slowest request body (bytes per second)","A request body arriving more slowly is answered 408 Request Timeout: login and other forms, uploads and raw bodies alike, so a client sending a byte now and then cannot keep a request thread. Only time spent waiting for the client counts, and a body that has arrived complete is never refused. Sending part of a body fast earns at most 30 seconds of waiting. Default 4096; 0 turns the check off.","Cuerpo de solicitud más lento (bytes por segundo)","Un cuerpo de solicitud que llega más despacio recibe 408 Request Timeout: formularios (también el de inicio de sesión), subidas y cuerpos sin formato por igual, así que un cliente que envía un byte de vez en cuando no puede retener un hilo de solicitud. Solo cuenta el tiempo de espera por el cliente, y un cuerpo que ya llegó completo nunca se rechaza. Enviar rápido parte del cuerpo da como máximo 30 segundos de espera. Por omisión 4096; 0 desactiva la comprobación."),
|
||||||
("runway.endpoints.max-body-bytes","int","10485760","1024..1073741824","server.limits",False,None,"Largest request to a plugin (bytes)","The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB).","Solicitud máxima a un complemento (bytes)","Lo máximo que un usuario con sesión puede enviar a una ruta de un complemento. Por omisión 10485760 (10 MiB)."),
|
("runway.endpoints.max-body-bytes","int","10485760","1024..1073741824","server.limits",False,None,"Largest request to a plugin (bytes)","The most a signed-in user may send to a plugin's route. Default 10485760 (10 MiB).","Solicitud máxima a un complemento (bytes)","Lo máximo que un usuario con sesión puede enviar a una ruta de un complemento. Por omisión 10485760 (10 MiB)."),
|
||||||
("spring.servlet.multipart.max-file-size","string","256MB",None,"server.limits",False,None,"Largest uploaded file","For uploads such as a backup to restore. A size like 256MB or 1GB. Default 256MB.","Archivo subido máximo","Para subidas como una copia a restaurar. Un tamaño como 256MB o 1GB. Por omisión 256MB."),
|
("spring.servlet.multipart.max-file-size","string","256MB",None,"server.limits",False,None,"Largest uploaded file","For uploads such as a backup to restore. A size like 256MB or 1GB. Default 256MB.","Archivo subido máximo","Para subidas como una copia a restaurar. Un tamaño como 256MB o 1GB. Por omisión 256MB."),
|
||||||
("spring.servlet.multipart.max-request-size","string","256MB",None,"server.limits",False,None,"Largest upload request","All the files of one upload together. A size like 256MB. Default 256MB.","Solicitud de subida máxima","Todos los archivos de una subida juntos. Un tamaño como 256MB. Por omisión 256MB."),
|
("spring.servlet.multipart.max-request-size","string","256MB",None,"server.limits",False,None,"Largest upload request","All the files of one upload together. A size like 256MB. Default 256MB.","Solicitud de subida máxima","Todos los archivos de una subida juntos. Un tamaño como 256MB. Por omisión 256MB."),
|
||||||
|
|||||||
Reference in new issue
Block a user