You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Template pipes and script functions that write a value inside a document, whatever the value: xml_text (text of an XML element), xml_attr (attribute value, tab and line breaks as references), cdata (inside a CDATA section, ]]> split in two sections), the three writing U+FFFD for a character XML 1.0 forbids, json_string (inside a JSON string, control characters included) and json_value (out of any string: a text that is exactly a JSON number, true, false or null as it is, any other as a JSON string).
The calls of an observed service can be read one by one, failed relays included. The observation panel lists the calls kept, the most recent first, and opens one in place: its request (method, path, query, headers, body) and the backend's response, or why no response came (target refused by PROXY_ALLOWED_TARGETS, backend unreachable, no answer in time, response cut off), in plain words. A relay that fails is now kept with its request, where observation kept nothing and the request log only a line: in a list of its own, bounded across all observed services by TRAFFIC_OBSERVATION_MAX_FAILED_CALLS (new setting, 100 by default), so that a backend that stays down never pushes a good sample out, and never read by suggestions (a 502 written by Mimicway is not an answer of the backend). A call can be copied as a curl command, which sends it again through Mimicway, and its request body downloaded as kept; a body cut at TRAFFIC_OBSERVATION_MAX_BODY_SIZE is shown as cut, with its real size, and a body that was not UTF-8 is said not to be the original byte for byte. Nothing refreshes by itself. New routes: GET …/{name}/observed-calls and GET …/{name}/observed-calls/{id}, with and without a group, under the same right as the suggestions.
Suggested responses that repeat what the request sent. When the responses of a route or of a SOAP operation differ only where they repeat values of their own request (path, query, header, field of an XML or JSON body, several at once), one rule without condition is suggested, whose response reads each value from the request ({{xpath.…}}, {{body./…}}, each escaped for where it stands in the document, whatever value comes: text of an element, attribute, CDATA section, JSON string; out of any JSON string, where a whole value stands, json_value when every value observed was a number, true, false or null, so that {"id":7} for /orders/7 and "active":true for ?active=true are still one rule, as in 0.5.0), where one rule per value seen answered a request never seen with the values of another. When the request holds a repeated element and the response a block per item, the rule comes with a script that reads the items and writes one block per item, each value escaped for where it stands (out of a JSON string, the JSON value of the request itself), and the response reads {{script.items}}. Such a rule is suggested only if Mimicway itself, rendering it for every observed request, gives back every observed response byte for byte; text from the traffic stays literal, in the response or in string literals of the script. GET …/suggestions gains repeats, list (with max_items, the most items its script writes, also said in the panel) and script on each rule; echo stays filled when the response repeats exactly one field. The panel names the repeated fields and the list, and "Use this suggestion" passes the script to the form.
GET …/suggestions keeps Unconditional, Echo and Conditional exactly as in 0.5.0, where a rule said everything with condition and echo, and gives a new outcome, Rules, to every suggestion that says more (an operation, calls set aside, a rule of several conditions or of any_of, a response that repeats several values or a list with its script), its rules read by conditions, response and script. A client written for 0.5.0, which read condition: null as "no condition", ignores that outcome instead of creating rules without their conditions.
Suggestions for SOAP services and for the fields of a request body. A route whose calls each name one SOAP operation (the element its Body holds) gets one suggestion per operation, each of its rules carrying the condition Envelope/Body/<operation> exists, where the operations of one address were answered "no field explains the responses"; observation keeps the calls of each operation apart (32 operations per path at most, the least recently called giving its place to a new one), as it does for each path, so that one busy operation no longer pushes the calls of the others out of the 8 an endpoint keeps. The texts of the elements of an XML body, read as XPath conditions read them (CDATA sections included, namespace prefixes ignored, the first element of a path), and the strings, numbers and booleans of a JSON body at any depth (as JSON pointers), are tried like the other fields of the request, where only the top-level fields of a JSON object were. Reading a body costs its length, whatever its shape, and is bounded: 64 fields, 16 levels, 256 bytes per path and per value. A request body cut at TRAFFIC_OBSERVATION_MAX_BODY_SIZE gives no field, and the suggestion says how many were cut; so does a request body in another encoding than UTF-8 (ISO-8859-1), whose bytes, which the rules read, are not the text observation keeps (non_utf8_request_bodies). The request's Content-Length header is no longer a field that tells answers apart: the length of a body is not a decision of the backend, and it explained the server error a longer body got. GET …/suggestions gains operation, truncated_request_bodies and non_utf8_request_bodies on each suggestion; the panel names the operation of a suggestion and the bodies cut.
PROXY_ALLOWED_TARGETS: the hosts, subdomains, addresses and ranges the proxies may connect to. Each relay (a service in proxy mode, an observed service, a rule whose action is proxy) and each availability check connects only to addresses the list admits, judged after DNS resolution on the addresses really connected, so that a name resolving elsewhere, or an address in another spelling (2130706433, [::ffff:127.0.0.1]), stays outside; a refused relay answers 502 with the reason. Saving refuses a new or changed target outside the list. Link-local addresses and the cloud metadata endpoints are admitted only by an entry of their own, never by a broad range. Unset, nothing changes (decision 3).
Changed
Suggestions from observed traffic explain more answers. A response reached by several values of a field, such as a service directory giving the same address for two names of one service, gets one rule that accepts any of them (an any_of condition per value), where nothing was suggested. Among the fields that explain the responses, the one with the fewest values is kept, so that an identifier changing at every call never wins over the name that decides; a field explains the responses only when each of its values was seen twice at least, always with the same response, since an identifier unique to each call fits any sample; a path parameter, a query parameter or a field at the top of a JSON object still may with values seen once when each response has its own value, as in 0.5.0. Calls answered with a 5xx status that no field explains are set aside when enough calls remain, and more of them than of errors, and the suggestion says how many were left out and with which status: five identical answers and one 500 now give the rule of the five, where the error hid it. GET …/suggestions gains conditions on each rule (all its conditions, all_of and any_of) and left_out on each suggestion (status, count); condition stays, set when a rule has exactly one condition. The panel says the values a rule accepts and the calls left out, and "Use this suggestion" fills the rule form with every condition.
CI also changes the JSON functions of scripts (src/engine/script_json.rs: parse_json, to_json) and the relay to a real backend (src/engine/proxy.rs) one mutation at a time. Of their 89 mutations, 9 went unseen, none a defect: the time of a reachability check, the read timeout setting, the caller's address kept by an observed relay, and the x-forwarded-* headers, which the relay's judge takes from the same function as the relay. serde_json's own reading now judges generated documents and every prefix of some of them, both what parse_json gives and what to_json writes back, and the limits of a parsed document are judged at their last item, entry and byte, wherever in the document they fall. A check of floats that serde_json already makes and a branch that no error reaches are removed. A relay that never connects now fails the test of what it sends after 30 seconds instead of hanging it.
CI also changes the detection of rules that another rule hides (src/engine/shadowing.rs, the conflict warning of the rule form) one mutation at a time. Of its 55 mutations, 3 went unseen, all in cases the drawn pairs of rules rarely reach: every pair of rules with one condition, out of every operator, every rule with two conditions against those, and every pair of sub-paths, odd ones included ({x, x}, {}), is now judged against the matcher itself. A regular expression without special characters is read as a plain text only when it compiles, as the matcher does: one too large to compile, never matched, could make the warning call a rule hidden behind a rule that never answers (such a rule cannot be saved). Two checks that changed no result are removed: the length of a {parameter} segment, and two different Eq values of one field, which the test of each condition against the value already refuses.
CI also changes the date pipes of templates (src/engine/template_dates.rs: epoch_ms, epoch_seconds, epoch_minutes, date("pattern")) one mutation at a time. Of its 86 mutations, 9 went unseen: no test had a date with one wrong separator, an offset with minutes, or an hour or a minute just past its range. Judges now read every month and day of two digits in fifteen years chosen for the leap year rules, every hour and minute of two digits in a time and in each form of offset, and 4,096 generated date-times in every form the pipes take, against a calendar written in the test; each separator of a date-time is replaced by every other printable character. Two checks of the month and the day that the calendar already made are removed.
CI also changes the rendering of responses (src/engine/renderer.rs: fake data, UUIDs, chaos mode) one mutation at a time. Of its 93 mutations, 27 went unseen: the tests of fake data checked that a value was not empty. A judge now draws every kind of fake data 512 times and checks the form its name promises (a French phone number, a postcode, a date in the past or the future within five years, an address…) and that the values vary; UUIDs are checked as random version 4 UUIDs over 1,024 draws, and the delay of chaos mode is checked to take every value between its bounds without waiting for it. A condition of chaos mode that changed no result is removed, and three mutations are explained as unable to change one.
CI also changes the limits of a script run (src/engine/script_budget.rs) one mutation at a time, with the files already covered: the checked replace is now judged against Rust's own str::replace on results within 3 bytes of the text limit, on both sides, and the checked split, split_rev and to_chars against Rhai's own functions on generated calls (zero and negative segment counts, empty delimiters), which they must answer the same way, a text without its delimiter coming back whole rather than copied. No defect was found.
Fixed
The availability check of a target written as an IPv6 address (http://[::1]:8080) always said it was unreachable: it looked the address up as a name, brackets included.
The date pipes of templates read an offset only as +02:00, +0200 or +02: an offset with letters or a space for minutes (+02ab, +02: 0), a colon in the wrong place (+0:200, +:02) or nothing after the colon (+02:) was read as +02:00, so a malformed date gave a number instead of coming out unchanged, where it shows in the response. Found by the judge of offsets below.
Fake SIREN, SIRET and French IBAN numbers ({{fake.Siren}}, {{fake.Siret}}, {{fake.IbanFR}}) pass the check that forms and banking libraries run on them. Their last digits were random: a SIREN or a SIRET was refused 9 times in 10 (they end in a Luhn check digit), and an IBAN 99 times in 100 (10,000 drawn: 107 valid), so an application that validates what a mock sends refused data that the real service never sends. A SIRET now also starts with a valid SIREN, and the key of the bank details is computed, which makes the check digits of the IBAN right. A test draws 4,096 of each and checks them with the published algorithms (Luhn, ISO 13616 modulo 97, key of French bank details), written apart from the generators.
A fake email address ({{fake.Email}}) no longer keeps the accent of the first name it is made from: about 1 address in 24 came out as françois.…@…, which the email field of a web form refuses, since it takes ASCII only before the @. Found by the judge of fake data below.
XPath conditions, the {{xpath.…}} variable and parse_xml_items read the text of a CDATA section: <Siret><![CDATA[123]]></Siret> gave them an empty value, so a SOAP client that wraps a value in CDATA got no match and no error. A CDATA section is read as text without decoding what it holds (<![CDATA[A&<B>]]> gives A&<B>), its line breaks read as XML reads them. The judges of those readers now generate CDATA sections, with markup, references, line breaks and ]]> split across two sections, and line breaks written \r\n or \r in the texts.
Security
The calls an observed service keeps, failed relays included, stay within what observation promised: turned on per service, in memory only, bounded, forgotten when observation stops, whenever the identity of the service changes (renamed, moved, deleted, its group renamed or deleted) and when the whole configuration is replaced (import, restore, reset), whatever route makes the change, a relay still running then keeping nothing; each call holds 16 KiB at most outside its bodies, the failures of one service never push out another's, and the identifier of a call tells nothing of other services; credential headers replaced by [redacted] before anything is kept, so that a copied curl command holds [redacted], never the secret. The command never lets a value of the traffic name a file for curl to read, and holds no control character a terminal acts on when it is pasted. The server log no longer writes the query of a relayed URL, where credentials may be (this predates observed calls). Reading them asks for the right to read the service's suggestions. Not redacted, as before for observation and the request log: a credential carried in the query string or in a body.
parse_xml_items no longer copies a text whole before checking it against the limit of a text: a field holding 10 MiB of text was copied, then refused, while the script held what it had already built: with 8 MiB of texts held, the peak memory of the request rose 10 to 12 MiB above the same request with a trivial script, and 1 to 4 MiB now (debug build). Its length is now counted where it lies in the body, line breaks included (\r\n counts as one), and nothing larger than the limit is copied.
parse_xml_items no longer copies the name of every element it reads before comparing it with its path. An element name may be as long as the body, and the XML reader already keeps a copy of it to check end tags: a 10 MiB body made of one element name was then held three times while the function ran. A script that held half the memory budget of a run (8 MiB of texts) and called parse_xml_items on such a body raised the peak memory of the request by 18 MiB (release build), within 2 MiB of what the memory test allows a run. Names are now compared where they lie in the body, and only the name of a field is copied, after it is counted against the limit of a text: the same call adds 8 to 9 MiB, the texts the script holds. A field name longer than the limit of a text is refused as soon as its start tag is read, even when the body is cut short after it, where the items read before it used to be returned.
Suggestions from observed traffic no longer hold hundreds to thousands of times the size of an XML body to describe it. To tell whether two paths answer the same kind of document, they gather the paths of its elements (Envelope/Body/getUrlResponse), each as long as the names of all its ancestors, and cut the list to 4 KiB only once it was whole: a body of long parent names over many short self-closing children, sent by a backend or by a client through an observed service, raised the peak memory of a suggestion request by about 9 MiB at the default size of an observed body (16 KiB, release build), a body of 538 KB held 1.46 GB, and one of 10 MiB, observed with a larger TRAFFIC_OBSERVATION_MAX_BODY_SIZE, would have asked for about 42 GB (the server died under a limit of 4 GiB). The description now stops at the first path that would not fit in its 4 KiB, before copying a name into it. A test sends such bodies, 16 KiB and 10 MiB, through an observed service: they add less than 1 MiB to the peak of the request, and a body made of one 10 MiB element name adds its own size, the copy that the XML reader keeps of the name of an open element. Bodies whose paths fit in 4 KiB are described as before; for larger ones, the paths kept are the first ones in the document rather than the first ones in alphabetical order, and an element more than 90 levels deep is never read (before, the paths of elements deeper than 64 levels were left out and the reading went on past them).