mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-12-06 06:46:23 +01:00
Yaak Proxy: prose pass over the UI copy
Apply the approved wording table: labels stay short, explanations are one full sentence about the user's traffic, and detail moves behind an info icon on the first-run card, the body banners, the Settings Helper row and the rejected card. One word per thing: traffic and flows, recorded, truncated, domains, searches, the CLI, Retry. Backend messages that reach the window change with them, with the tests and harness fixtures that assert on the old text. The two working files for the pass are removed from the branch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
1f0541f379
commit
35058cc3be
70 files changed
+419
-1312
No files matched your search
@@ -12,8 +12,7 @@ use yaak_models::blob_manager::BlobManager;
|
||||
const MESSAGE_PAGE: usize = 500;
|
||||
|
||||
/// What a WebSocket's response body reads as: it has none.
|
||||
pub const WEBSOCKET_BODY_NOTE: &str =
|
||||
"A WebSocket has no body after its 101 response. Its frames are its messages.";
|
||||
pub const WEBSOCKET_BODY_NOTE: &str = "A WebSocket has no body";
|
||||
|
||||
/// Whether a flow's body is its stream's messages rather than bytes stored on their own: an
|
||||
/// event stream's response, a gRPC call's request, and its response when the server answered
|
||||
|
||||
@@ -395,7 +395,7 @@ pub(crate) fn already_owned(owner: &ControlInfo) -> String {
|
||||
pub(crate) fn owner_name(owner: Owner) -> &'static str {
|
||||
match owner {
|
||||
Owner::App => "Yaak Proxy",
|
||||
Owner::Cli => "the yaak CLI",
|
||||
Owner::Cli => "the CLI",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,14 +65,11 @@ pub fn flow_to_request(flow: &Flow, body: &DecodedBody) -> Conversion {
|
||||
let (headers, dropped_headers) = split_headers(flow, body);
|
||||
let has_authorization = headers.iter().any(|h| h.name.eq_ignore_ascii_case("authorization"));
|
||||
if has_authorization {
|
||||
warnings.push("The Authorization header is saved as captured, in plain text.".into());
|
||||
warnings.push("The Authorization header is saved in plain text.".into());
|
||||
}
|
||||
let (body_type, body_fields) = request_body(flow, body, &mut warnings);
|
||||
if body.truncated {
|
||||
warnings.push(format!(
|
||||
"The body was cut at the capture limit, so only its first {} bytes are saved.",
|
||||
body.data.len()
|
||||
));
|
||||
warnings.push(format!("Only the first {} bytes of the body are saved.", body.data.len()));
|
||||
}
|
||||
|
||||
// No name, as in Yaak, which then shows the URL.
|
||||
@@ -169,10 +166,7 @@ fn request_body(
|
||||
let content_type = find_header(&flow.request_headers, "content-type").unwrap_or_default();
|
||||
let mime = content_type.split(';').next().unwrap_or_default().trim().to_ascii_lowercase();
|
||||
let Ok(text) = std::str::from_utf8(&body.data) else {
|
||||
warnings.push(
|
||||
"The body is binary and is saved as text, so bytes that are not UTF-8 are replaced."
|
||||
.into(),
|
||||
);
|
||||
warnings.push("The body is binary and may be altered when saved.".into());
|
||||
return text_body(BODY_TYPE_OTHER, &String::from_utf8_lossy(&body.data));
|
||||
};
|
||||
|
||||
@@ -195,9 +189,7 @@ fn request_body(
|
||||
);
|
||||
}
|
||||
if mime == "multipart/form-data" {
|
||||
warnings.push(
|
||||
"The multipart body is saved as text with its Content-Type, not as form fields.".into(),
|
||||
);
|
||||
warnings.push("The multipart body is saved as text, not form fields.".into());
|
||||
}
|
||||
text_body(BODY_TYPE_OTHER, text)
|
||||
}
|
||||
@@ -300,10 +292,7 @@ mod tests {
|
||||
("Proxy-Authorization", DropReason::HopByHop),
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
c.warnings,
|
||||
vec!["The Authorization header is saved as captured, in plain text."]
|
||||
);
|
||||
assert_eq!(c.warnings, vec!["The Authorization header is saved in plain text."]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -463,9 +452,6 @@ mod tests {
|
||||
let c = flow_to_request(&f, &data);
|
||||
assert_eq!(names(&c.request), vec!["Content-Type"]);
|
||||
assert_eq!(c.dropped_headers[0].reason, DropReason::BodyDecoded);
|
||||
assert_eq!(
|
||||
c.warnings,
|
||||
vec!["The body was cut at the capture limit, so only its first 4 bytes are saved."]
|
||||
);
|
||||
assert_eq!(c.warnings, vec!["Only the first 4 bytes of the body are saved."]);
|
||||
}
|
||||
}
|
||||
@@ -154,10 +154,7 @@ fn any_encrypted(data_dir: &Path) -> bool {
|
||||
}
|
||||
|
||||
fn missing_data_key(data_dir: &Path) -> String {
|
||||
format!(
|
||||
"The proxy's captured traffic is encrypted, but its key is missing from {}",
|
||||
data_dir.display()
|
||||
)
|
||||
format!("The encryption key is missing from {}.", data_dir.display())
|
||||
}
|
||||
|
||||
/// Both databases, opened together.
|
||||
@@ -324,12 +321,11 @@ pub fn encrypt_existing(
|
||||
Ok(converted)
|
||||
}
|
||||
|
||||
const KEY_UNAVAILABLE: &str =
|
||||
"Yaak Proxy stores traffic encrypted and couldn't read its key from the keychain";
|
||||
const KEY_UNAVAILABLE: &str = "Failed to read the encryption key from the keychain";
|
||||
|
||||
/// Why the databases cannot be opened, or the CA made, without the data key.
|
||||
pub fn key_unavailable(reason: &str) -> String {
|
||||
format!("{KEY_UNAVAILABLE}: {reason}. Allow it access, then retry.")
|
||||
format!("{KEY_UNAVAILABLE}: {reason}")
|
||||
}
|
||||
|
||||
/// `reason` is [`key_unavailable`]'s: the keychain would not give up the key.
|
||||
|
||||
@@ -18,7 +18,7 @@ pub struct FilterHistoryEntry {
|
||||
}
|
||||
|
||||
fn failed(what: &str, e: impl std::fmt::Display) -> String {
|
||||
format!("Failed to {what} the filter history: {e}")
|
||||
format!("Failed to {what} the search history: {e}")
|
||||
}
|
||||
|
||||
/// Every filter kept, most recently applied first. Empty for a database from before the
|
||||
|
||||
@@ -719,7 +719,7 @@ pub fn delete_all(db: &ProxyQueryManager) -> Result<(), String> {
|
||||
}
|
||||
Ok::<_, yaak_database::Error>(())
|
||||
})
|
||||
.map_err(|e| format!("Failed to delete captured traffic: {e}"))
|
||||
.map_err(|e| format!("Failed to delete recorded traffic: {e}"))
|
||||
}
|
||||
|
||||
/// Flows deleted per transaction while deleting cleared ones, so a flow being written never
|
||||
|
||||
@@ -387,7 +387,7 @@ async fn find_schema(
|
||||
}
|
||||
Err(_) => Ok((None, Some(format!("No schema for {service} on {authority}")))),
|
||||
},
|
||||
Err(e) => Ok((None, Some(format!("No schema for {service}; reflection failed: {e}")))),
|
||||
Err(e) => Ok((None, Some(format!("No schema for {service}. Reflection failed: {e}")))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,11 +448,15 @@ fn decode_with(
|
||||
json: yaak_grpc::message_to_json(&decoded)?,
|
||||
message_type: Some(message_type),
|
||||
schema: Some(schema),
|
||||
note: message.truncated.then(|| "The message is cut at the capture limit".into()),
|
||||
note: message
|
||||
.truncated
|
||||
.then(|| "The message was truncated at the capture limit".into()),
|
||||
}),
|
||||
Err(e) => {
|
||||
Ok(schemaless(payload, message, Some(format!("Did not decode as {message_type}: {e}"))))
|
||||
}
|
||||
Err(e) => Ok(schemaless(
|
||||
payload,
|
||||
message,
|
||||
Some(format!("Failed to decode as {message_type}: {e}")),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +464,7 @@ fn schemaless(payload: &[u8], message: &FlowMessage, reason: Option<String>) ->
|
||||
let mut notes: Vec<String> = reason.into_iter().collect();
|
||||
notes.push("Decoded without a schema: field names and types are guesses".into());
|
||||
if message.truncated {
|
||||
notes.push("The message is cut at the capture limit".into());
|
||||
notes.push("The message was truncated at the capture limit".into());
|
||||
}
|
||||
let fields = decode_fields(payload, 0).unwrap_or_else(|| {
|
||||
notes.push("Not a valid protobuf message: shown as bytes".into());
|
||||
|
||||
@@ -153,12 +153,12 @@ mod imp {
|
||||
}
|
||||
// SAFETY: unregisters the plist bundled with this app.
|
||||
unsafe { service.unregisterAndReturnError() }
|
||||
.map_err(|e| format!("Failed to remove the helper: {}", e.localizedDescription()))?;
|
||||
.map_err(|e| format!("Failed to uninstall the helper: {}", e.localizedDescription()))?;
|
||||
Ok(state_of(&service))
|
||||
}
|
||||
|
||||
fn unavailable() -> String {
|
||||
"The helper is only available in the installed app, not a dev build".to_string()
|
||||
"The helper is not available in dev builds".to_string()
|
||||
}
|
||||
|
||||
/// Sends one request and reads its response.
|
||||
@@ -181,13 +181,15 @@ mod imp {
|
||||
let _ = stream.set_write_timeout(Some(IO_TIMEOUT));
|
||||
let mut line = serde_json::to_string(request).map_err(|e| e.to_string())?;
|
||||
line.push('\n');
|
||||
(&stream).write_all(line.as_bytes()).map_err(|e| format!("The helper hung up: {e}"))?;
|
||||
(&stream)
|
||||
.write_all(line.as_bytes())
|
||||
.map_err(|e| format!("The helper disconnected: {e}"))?;
|
||||
let mut reply = String::new();
|
||||
BufReader::new(&stream)
|
||||
.read_line(&mut reply)
|
||||
.map_err(|e| format!("The helper did not answer: {e}"))?;
|
||||
.map_err(|e| format!("The helper did not respond: {e}"))?;
|
||||
let response: Response = serde_json::from_str(&reply)
|
||||
.map_err(|e| format!("The helper's answer was not understood: {e}"))?;
|
||||
.map_err(|e| format!("The helper sent an invalid response: {e}"))?;
|
||||
response.into_result()
|
||||
}
|
||||
|
||||
@@ -214,12 +216,12 @@ pub fn state() -> HelperState {
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn diagnose() -> String {
|
||||
"The helper is only available on macOS".to_string()
|
||||
"The helper is only supported on macOS".to_string()
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn register() -> Result<HelperState, String> {
|
||||
Err("The helper is only available on macOS".to_string())
|
||||
Err("The helper is only supported on macOS".to_string())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
|
||||
@@ -233,7 +233,7 @@ impl ProxyCtx {
|
||||
|
||||
fn lock_reason(&self) -> String {
|
||||
if self.encrypting().is_some() {
|
||||
return "traffic captured before this version is being encrypted.".to_string();
|
||||
return "traffic recorded before this version is being encrypted.".to_string();
|
||||
}
|
||||
let reason = self.lock_reason.lock().unwrap_or_else(PoisonError::into_inner).clone();
|
||||
reason.unwrap_or_else(|| "its key has not been read yet.".to_string())
|
||||
@@ -275,8 +275,7 @@ impl ProxyCtx {
|
||||
&& owner.pid != std::process::id()
|
||||
{
|
||||
return Err(format!(
|
||||
"{}, so the traffic it stored can't be encrypted yet. Take over or quit it, then \
|
||||
retry.",
|
||||
"{}. Take over or quit it, then retry.",
|
||||
control::already_owned(&owner)
|
||||
));
|
||||
}
|
||||
@@ -720,7 +719,7 @@ impl ProxyCtx {
|
||||
.map_err(|e| e.to_string())?;
|
||||
if !released {
|
||||
return Err(format!(
|
||||
"The proxy in {} (pid {}) stopped but did not let go of it",
|
||||
"Failed to take over from {} (pid {})",
|
||||
control::owner_name(owner.owner),
|
||||
owner.pid
|
||||
));
|
||||
@@ -808,7 +807,7 @@ impl ProxyCtx {
|
||||
pub fn set_system_proxy(&self, enabled: bool) -> Result<SystemProxyStatus, String> {
|
||||
let Some(port) = self.port() else {
|
||||
if enabled {
|
||||
return Err("The proxy is not running, so there is nothing to route to".into());
|
||||
return Err("The proxy is not running".into());
|
||||
}
|
||||
// Clears one left pointing at the configured port; asks for nothing otherwise.
|
||||
self.change_system_proxy(false, self.settings()?.port, false)?;
|
||||
@@ -2246,7 +2245,7 @@ pub struct SavePreview {
|
||||
/// Headers saved as captured, Authorization among them.
|
||||
#[ts(type = "number")]
|
||||
pub kept_headers: usize,
|
||||
/// The body as it is saved: "JSON", "form URL-encoded with 7 fields". None without a body.
|
||||
/// The body as it is saved: "JSON", "a URL-encoded form with 7 fields". None without a body.
|
||||
pub body: Option<String>,
|
||||
/// What does not carry over exactly, one sentence each.
|
||||
pub warnings: Vec<String>,
|
||||
@@ -2784,8 +2783,8 @@ async fn preview_save(ctx: ProxyCtx, req: PreviewSaveRequest) -> Result<SavePrev
|
||||
"application/x-www-form-urlencoded" => {
|
||||
let fields = request.body.get("form").and_then(|f| f.as_array()).map_or(0, Vec::len);
|
||||
match fields {
|
||||
1 => "form URL-encoded with 1 field".to_string(),
|
||||
n => format!("form URL-encoded with {n} fields"),
|
||||
1 => "a URL-encoded form with 1 field".to_string(),
|
||||
n => format!("a URL-encoded form with {n} fields"),
|
||||
}
|
||||
}
|
||||
_ => "text".to_string(),
|
||||
@@ -3184,8 +3183,7 @@ async fn count_saved_queries(
|
||||
// -- Event loop --
|
||||
|
||||
/// Why the engine cannot be taken over from another app.
|
||||
pub const ANOTHER_APP_OWNS: &str =
|
||||
"Another Yaak Proxy window owns the engine. Quit it to use this one.";
|
||||
pub const ANOTHER_APP_OWNS: &str = "Quit the other Yaak Proxy to use this one.";
|
||||
|
||||
/// How long taking over waits for the owner to let go of the engine.
|
||||
const TAKE_OVER_WAIT: Duration = Duration::from_secs(10);
|
||||
@@ -3229,11 +3227,10 @@ const STOPPED_MID_STREAM: &str = "Yaak Proxy stopped before the stream ended";
|
||||
const STOPPED_MID_TUNNEL: &str = "Yaak Proxy stopped before the connection closed";
|
||||
|
||||
/// Why a failed handshake's flow can't be saved as a request.
|
||||
pub(crate) const NOT_A_REQUEST: &str =
|
||||
"Not a request: the client's TLS handshake failed before it sent one";
|
||||
pub(crate) const NOT_A_REQUEST: &str = "The TLS handshake failed before any request was sent";
|
||||
|
||||
/// The error of a flow recording a client's refusal of the proxy's certificate.
|
||||
const REJECTED_CERTIFICATE: &str = "Rejected the proxy's certificate";
|
||||
const REJECTED_CERTIFICATE: &str = "Certificate rejected by the app";
|
||||
|
||||
/// A flow between its `RequestStart` and its end, with its bodies being written as they
|
||||
/// stream.
|
||||
|
||||
@@ -287,7 +287,7 @@ mod imp {
|
||||
.map_err(|e| format!("Failed to run osascript: {e}"))?;
|
||||
// -128 is the dialog's Cancel button.
|
||||
if String::from_utf8_lossy(&output.stderr).contains("(-128)") {
|
||||
return Err("Cancelled in the password dialog".to_string());
|
||||
return Err("The password prompt was cancelled.".to_string());
|
||||
}
|
||||
check(&output, "osascript")
|
||||
}
|
||||
@@ -647,7 +647,7 @@ mod tests {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join(SNAPSHOT_FILE);
|
||||
let ns = fake();
|
||||
let cancel = |_: &[Vec<String>]| Err("Cancelled in the password dialog".to_string());
|
||||
let cancel = |_: &[Vec<String>]| Err("The password prompt was cancelled.".to_string());
|
||||
assert!(set_scripted(&ns, cancel, true, 9090, &path).is_err());
|
||||
assert!(!path.exists());
|
||||
assert!(ns.changes.lock().unwrap().is_empty());
|
||||
@@ -663,7 +663,7 @@ mod tests {
|
||||
set_scripted(&ns, runner(&ns, &prompts), true, 9090, &path).unwrap();
|
||||
// A second enable, the engine on a new port, must not save ours as the user's.
|
||||
set_scripted(&ns, runner(&ns, &prompts), true, 9191, &path).unwrap();
|
||||
let cancel = |_: &[Vec<String>]| Err("Cancelled in the password dialog".to_string());
|
||||
let cancel = |_: &[Vec<String>]| Err("The password prompt was cancelled.".to_string());
|
||||
assert!(set_scripted(&ns, cancel, true, 9191, &path).is_err());
|
||||
assert!(path.exists(), "a cancelled re-enable keeps the original snapshot");
|
||||
set_scripted(&ns, runner(&ns, &prompts), false, 9191, &path).unwrap();
|
||||
|
||||
@@ -88,14 +88,14 @@ pub fn schema() -> &'static Schema {
|
||||
field("method", text(), "GET, POST, …", "@method:post"),
|
||||
field("status", number(), "Response status", "@status:4xx @status:>=400"),
|
||||
field("type", text(), "Content type", "@type:json"),
|
||||
field("app", text(), "App or program", "@app:Slack"),
|
||||
field("app", text(), "App", "@app:Slack"),
|
||||
field(
|
||||
"is",
|
||||
text(),
|
||||
"error, pending, system, encrypted, rejected, …",
|
||||
"@is:error -@is:system @is:encrypted",
|
||||
),
|
||||
map("header", "A header on either side", "@header.content-type:json"),
|
||||
map("header", "A request or response header", "@header.content-type:json"),
|
||||
map("req.header", "A request header", "@req.header.accept:*"),
|
||||
map("res.header", "A response header", "@res.header.x-cache:hit"),
|
||||
field("size", bytes(), "Response body size", "@size:>100kb"),
|
||||
@@ -109,8 +109,8 @@ pub fn schema() -> &'static Schema {
|
||||
field("port", number(), "Port", "@port:8080"),
|
||||
field("proto", text(), "h1, h2, ws, sse, grpc", "@proto:h2"),
|
||||
field("id", number(), "Flow number", "@id:>1200"),
|
||||
field("cwd", text(), "Working folder", "@cwd:myapp"),
|
||||
field("pid", number(), "Process id", "@pid:4121"),
|
||||
field("cwd", text(), "Working directory", "@cwd:myapp"),
|
||||
field("pid", number(), "Process ID", "@pid:4121"),
|
||||
field(
|
||||
"graphql.operation",
|
||||
text(),
|
||||
@@ -119,9 +119,9 @@ pub fn schema() -> &'static Schema {
|
||||
),
|
||||
field("grpc.service", text(), "gRPC service", "@grpc.service:pkg.Greeter"),
|
||||
field("grpc.method", text(), "gRPC method", "@grpc.method:SayHello"),
|
||||
field("body", text(), "Not yet", ""),
|
||||
field("req.body", text(), "Not yet", ""),
|
||||
field("res.body", text(), "Not yet", ""),
|
||||
field("body", text(), "Not supported", ""),
|
||||
field("req.body", text(), "Not supported", ""),
|
||||
field("res.body", text(), "Not supported", ""),
|
||||
],
|
||||
FreeText::Substring,
|
||||
)
|
||||
|
||||
@@ -391,7 +391,7 @@ fn encrypted_and_rejected() {
|
||||
url: "https://my.1password.com".into(),
|
||||
client_http_version: "HTTP/1.1".into(),
|
||||
tls_rejected: Some("unknown_ca".into()),
|
||||
error: Some("Rejected the proxy's certificate".into()),
|
||||
error: Some("Certificate rejected by the app".into()),
|
||||
elapsed_ms: Some(3),
|
||||
started_at: (now() - Duration::minutes(5)).naive_utc(),
|
||||
..Default::default()
|
||||
|
||||
@@ -44,7 +44,7 @@ pub fn open(vars: &[(String, String)]) -> Result<(), String> {
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn open(_vars: &[(String, String)]) -> Result<(), String> {
|
||||
Err("Opening a terminal with the proxy set is only supported on macOS so far".to_string())
|
||||
Err("Opening a terminal is only supported on macOS".to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in new issue
Block a user