Repository navigation
Mimicway 0.3.0
·
231 commits
to develop
since this release
Added
- Dates in another unit, without converting them by hand: in a response template,
{{"2026-12-31T10:00:00Z" | epoch_seconds}}gives1798711200, and the pipesepoch_ms,epoch_minutesanddate("dd/MM/yyyy HH:mm")give the other units and any format. The date is an ISO 8601 text written in the template between double quotes, or any variable that holds one (now_iso,body.created…); a value that is not such a date comes out unchanged. The builders offer these pipes in their list. - The script editor completes the keywords of the language (
let,if,else,for,while,switch,fn,return,try…) before Mimicway's functions, and inserts each as a skeleton with the part to replace selected. - Traffic suggestions group the paths of a service into routes: calls that differ by an identifier (
/orders/1,/orders/2), or by words answered with documents of the same structure (the services a directory knows), pool their samples under a pattern such as/orders/{id}, and the pattern's parameters are the first fields tried to explain the responses. Three calls to a route are enough, where each path needed three of its own. When the responses differ only by the value that tells them apart, because the backend repeats it, one rule repeats it ({{path.name}}) instead of one rule per value, and also answers the values never observed. Each suggestion names its pattern and the paths it groups; a literal path is suggested before a pattern that would also match it. - Traffic suggestions follow the services a response points to. After a refresh, the observation panel lists the backends that the observed responses name (in their bodies and their
Location,Content-LocationandLinkheaders, XML namespace and schema addresses and Mimicway's own address left out), with the routes that named them; for one that no service reaches, it opens the service form filled with a proxy in front of it. Once such a service exists, the suggested rules write its address in Mimicway instead of the backend's, built from the request the rule answers ({{header.x-forwarded-proto | default("http")}}://{{header.host}}), so that an application served by a mocked directory calls Mimicway. Only the suggested rules are rewritten, never the relayed traffic. New endpointGET …/{name}/linked-backends. - A fuzz target for the suggestions (
fuzz/fuzz_targets/suggestions.rs): like the property tests, it replays the suggested rules on the calls they come from and fails unless each gets back exactly what the backend answered.
Fixed
- Opening a response in the JSON or XML builder no longer drops the expressions the builder has no source for:
{{now_epoch}},{{pre_script.total}},{{post_script}}or a quoted text with a pipe became their bare name, written as plain text at the next save. - Raw TCP mocks: two changes made at the same time are both kept, or one is refused with its reason. Each was checked against the same copy of the configuration, then replaced it whole, so the second erased the first although both had been accepted (eight creations at once kept one). A service name is now stored trimmed, as it is checked:
svccould sit next tosvc. - Two services can no longer share a name within a group (or both be ungrouped) through any change of the configuration. An import (
PUT /api/config) accepted them, as it accepted two groups whose names differ only by case, two groups with one URL code, a malformed code, and an ungrouped service named like a group code; it now applies the rules of creating each group and service one at a time, and refuses the whole file with the first conflict. Deleting a group refuses to ungroup a service whose name an ungrouped service or a group code already has. A name with spaces around it is stored trimmed, as it was already validated:userswas accepted next tousers. Routing only ever reached the first of two such services, and the interface failed to render the list that held them. A configuration file or a backup saved by a version that allowed them (0.1.0 did, on a double submission) loads with the second one renamedname-2(then-3...), logged as a warning, instead of breaking the interface. - Removing a service from a group, or adding an ungrouped one to it, from the group page now acts on the service clicked: it acted on the first service of that name found, which could belong to another group.
- The service page no longer shows "Directory URL rewriting", and the README no longer lists it among the features: no code ever rewrote anything from the
rewrite_directory_urlskey, so a user relying on it got the real addresses. The key stays accepted in imported and stored configurations, ignored, and may now be left out. Rules suggested from observed traffic are what rewrites such addresses now (see Added). - A rule whose sub-path names a parameter (
/orders/{id}) and that has a condition on that parameter now matches the requests it was written for: path parameter conditions were judged on the parameters of the service's listen path only, so such a rule passed in the rule tester and never matched a real request. - Stopping the observation of a service, deleting, renaming or moving it, or resetting the configuration now forgets the calls observed for it: they used to stay, so observing again mixed old and new traffic, and a service created again under the same name was suggested rules from the traffic of the deleted one, maybe in front of another backend.
- A rule suggested from observed traffic with a condition on a JSON field whose name holds
/or~now matches: the name went into the JSON pointer unescaped, so the pointer named another field. - A rule suggested from observed traffic on a service with a listen path (
/v1/*) now matches the calls it comes from: its sub-path kept the listen path's part (/v1/ordersinstead of/orders), which rules never see.
Security
- A rule script run also stops when it holds more than 16 MiB of memory, however it holds it. Rhai bounds each value, not their sum, and a few lines of script held 1.7 GB in the arguments of one call, 1 GB in what
mapgathers, 850 MiB in curried function pointers, 330 MiB in map keys and 265 MiB in nested calls. The global allocator now counts the bytes each thread holds (alloc/, the one crate of the project withunsafecode: four methods that call the system allocator unchanged, tested under Miri), and a run reads its thread's count between operations. - A rule script can no longer take the server down from inside its limits. One
replaceof a 1 MiB text by a 1 MiB substitute, 94 bytes of script that any signed-in user can send to the rule tester, asked for a terabyte at once and aborted the process;xml_elementgiven the request body as its tag built 40 GB;parse_jsonandparse_xml_itemsheld up to 390 MiB for one 10 MiB request body, andsplit640 MiB; a loop of slow operations on a large body kept a worker thread busy for over a minute. Now a run stops after 500 ms and at 64 variables at once, andreplace, thesplitfamily,to_chars,parse_json,parse_xml_items,to_jsonandxml_elementstop as soon as their result would break the size limits of a value (1 MiB of text, 1,000 items, 500 entries), instead of building it first; the same 10 MiB requests now cost no more memory than with a trivial script. Every limit reached is named, with its value, in the error the rule tester shows and the log records. Scripts that relied on the old reading ofparse_jsonmay now fail where they did not: it counts every key it reads, repeated or not, and the text of keys with the text of values; and a map returned by a script is checked like any other value (500 entries at most). - A browser that sends no
Sec-Fetch-Siteheader (Safari before 16.4, older Firefox) can no longer make a page of another site change the configuration: a state-changing management API request is now refused when itsOriginis neither the address called nor listed inCORS_ALLOWED_ORIGINS,nullincluded. Such a browser sends a formPOSTor a body-lessPOSTwithout a CORS preflight, soPOST /api/config/restore/{filename}replaced the configuration andPOST /api/services/{name}/pingmade Mimicway connect. Clients that send noOrigin, which are not browsers, are unaffected. - Every client is bounded in time and memory. Request headers must arrive within 10 seconds (hyper's own limit never applied: the server ran it without a timer, so a client sending its headers a byte at a time held a connection forever), which also closes keep-alive connections idle that long; request bodies must arrive at 16 KiB/s on average after 10 seconds of grace, or get 408. At most
MAX_REQUESTS_IN_FLIGHTrequests (1,024) are handled at once, and at mostMAX_BUFFERED_BODY_SIZEbytes (48 MiB) of request bodies are held in memory by mocked services and the management API; past either, the request gets 503 withRetry-After: 1at once, before its body is read when it announces its length./api/healthis never refused, and requests streamed to a proxied backend hold no budget. Ten 10 MiB requests at once to a rule with a JSON condition, a script and a{{body.…}}variable now peak at 130 MB, within the 256 MiB of the Kubernetes manifests, instead of 2.5 GB. A body over 10 MiB sent to a mocked service now gets 413 instead of 400. - JSON conditions and
{{body.…}}template variables read the value their pointer names without building the whole document: one 10 MiB JSON body evaluated against one condition took 250 MB of memory, about the whole memory the Kubernetes manifests give the pod, and now takes 22 MB. They find exactly what they found before. - Breaking for the Kubernetes manifests: the base turns authentication on, both routing overlays serve their host over TLS (secret
mimicway-tls), and aNetworkPolicyrefuses every outbound connection of the pod but name resolution.kubectl apply -k k8s/ingressused to publish the management API to whoever reached the ingress, in plain HTTP and without authentication, with a proxy able to reach any service of the cluster. Set the Keycloak settings and create the secret before applying, and allow Keycloak and your backends with a policy of your own (k8s/README.md). The newk8s/localoverlay keeps the former behavior without any routing, for a cluster of one's own, reached throughkubectl port-forward. The pod also runs without a service account token and under the runtime's default seccomp profile, and the CI refuses an overlay that would route to Mimicway without authentication or TLS, let it connect beyond name resolution, or drop those pod settings. - The interface keeps the session in memory only. It used to save the access token and the refresh token in the browser's
localStorage, where any script of its origin could read them, and where they stayed after use; the refresh token served nothing, since no session was ever renewed. Reloading the page now asks to sign in again, and the sessions that earlier versions saved are deleted when the interface loads.POST /api/auth/loginstill returns both tokens to API clients. - Responses of mocked and proxied services carry
Content-Security-Policy: sandbox, withoutallow-same-origin: opened in a browser, such a page runs in an opaque origin of its own. They share the interface's origin, so a page that an editor wrote, that a proxied backend sent, or that a template filled with a value of the request ({{query.x}}in atext/htmlanswer, reachable through a simple link) used to run its scripts as the interface: it read the token of whoever opened it, an administrator included, and called the management API with their rights, or without authentication reset the configuration; the browser guard saw same-origin calls and refused nothing. Its scripts still run, its calls to the API are now refused as cross-site. A proxied web application that relies on its own origin (cookies, storage) no longer works when browsed through Mimicway; serving the services on their own port is planned for that case. The policy is added next to any the rule or the backend sets. See decision 1. - Breaking for a Mimicway without authentication reached through a host name from other machines: the management API now answers only requests addressed to
localhost, an IP address or a name listed in the newALLOWED_HOSTS(*for any name), on every interface. The check used to apply only when listening on loopback, so the container image, which listens on0.0.0.0, let any web page its users opened drive the API through DNS rebinding (a domain name of the page's that resolves to Mimicway's address), and with it the proxy towards any host Mimicway reaches. With authentication on and listening beyond loopback, any name is still answered unlessALLOWED_HOSTSlists them, a rebound page having no token to send. HTTP/2's:authorityis checked likeHost, a request that names no host is refused, and the startup log says which names are answered. The documenteddocker runnow publishes the port on the host's loopback only (-p 127.0.0.1:7342:7342). - With authentication enabled, reading the raw TCP mocks (
GET /api/tcp/services,GET /api/tcp/status) is reserved to super-admins, who alone could already change them. TCP mocks belong to no group, yet every signed-in user could read their matchers, the bytes they answer, their ports and the address they listen on, where an ungrouped HTTP service is hidden from everyone but super-admins. Other users now get a 403, and the interface, which asks for the status when it loads, no longer shows them the TCP page, whose buttons all ended in a 403 for them. - rustls 0.23.46, past four advisories of 0.23.45 (RUSTSEC-2026-0346 to -0349). None reached Mimicway's outbound connections (the proxy, the identity provider): they need a custom session store, Encrypted Client Hello, rustls's Brotli certificate decompression or a post-quantum key exchange, and Mimicway uses none of them (rustls's own session store, on its ring provider, which offers only classical groups). The lock file changes on that package alone.
- rustls-webpki 0.103.16 and webpki-roots 1.0.10, past RUSTSEC-2026-0381 and -0382: the private keys of some emSign intermediate certificates are public, and the previous versions still trusted certificates issued through them. Mimicway was exposed on every outbound HTTPS connection, which verifies the server with these roots: someone holding one of those keys and on the path could have impersonated a proxied backend or the identity provider, and so signed tokens that Mimicway accepts. The lock file changes on these two packages alone.
- tokio 1.53.3, past RUSTSEC-2026-0386: the safe constructors of
AsyncFdaccept a file descriptor that the caller does not own, which may then be closed or reused under it. Neither Mimicway nor any of its dependencies, Kafka and raw TCP mocks included, constructs anAsyncFd, so nothing reached it. The lock file changes on that package alone.