From ff60d886f6dab470942813ccb300ee7f95e3455d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 23 Jan 2024 10:34:00 -0700 Subject: [PATCH 1/2] Remove ZED_SECRET_CLIENT_TOKEN --- crates/auto_update/src/auto_update.rs | 6 ++---- crates/client/src/client.rs | 1 - crates/client/src/telemetry.rs | 4 +--- crates/feedback/src/feedback_modal.rs | 4 +--- crates/zed/src/main.rs | 11 +---------- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rs index 61fa8dcb75..67ca15e295 100644 --- a/crates/auto_update/src/auto_update.rs +++ b/crates/auto_update/src/auto_update.rs @@ -1,7 +1,7 @@ mod update_notification; use anyhow::{anyhow, Context, Result}; -use client::{Client, TelemetrySettings, ZED_APP_PATH, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN}; +use client::{Client, TelemetrySettings, ZED_APP_PATH, ZED_APP_VERSION}; use db::kvp::KEY_VALUE_STORE; use db::RELEASE_CHANNEL; use gpui::{ @@ -248,9 +248,7 @@ impl AutoUpdater { ) })?; - let mut url_string = format!( - "{server_url}/api/releases/latest?token={ZED_SECRET_CLIENT_TOKEN}&asset=Zed.dmg" - ); + let mut url_string = format!("{server_url}/api/releases/latest?asset=Zed.dmg"); cx.update(|cx| { if let Some(param) = cx .try_global::() diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 3a48fdba86..844c9a5eb6 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -68,7 +68,6 @@ lazy_static! { std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| e.len() > 0); } -pub const ZED_SECRET_CLIENT_TOKEN: &str = "618033988749894"; pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(100); pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5); diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 3412910705..824ac3f9ea 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -1,6 +1,6 @@ mod event_coalescer; -use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL}; +use crate::{TelemetrySettings, ZED_SERVER_URL}; use chrono::{DateTime, Utc}; use futures::Future; use gpui::{AppContext, AppMetadata, BackgroundExecutor, Task}; @@ -51,7 +51,6 @@ lazy_static! { #[derive(Serialize, Debug)] struct EventRequestBody { - token: &'static str, installation_id: Option>, session_id: Option>, is_staff: Option, @@ -527,7 +526,6 @@ impl Telemetry { { let state = this.state.lock(); let request_body = EventRequestBody { - token: ZED_SECRET_CLIENT_TOKEN, installation_id: state.installation_id.clone(), session_id: state.session_id.clone(), is_staff: state.is_staff.clone(), diff --git a/crates/feedback/src/feedback_modal.rs b/crates/feedback/src/feedback_modal.rs index 80722580b7..99c96fe880 100644 --- a/crates/feedback/src/feedback_modal.rs +++ b/crates/feedback/src/feedback_modal.rs @@ -2,7 +2,7 @@ use std::{ops::RangeInclusive, sync::Arc, time::Duration}; use anyhow::{anyhow, bail}; use bitflags::bitflags; -use client::{Client, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL}; +use client::{Client, ZED_SERVER_URL}; use db::kvp::KEY_VALUE_STORE; use editor::{Editor, EditorEvent}; use futures::AsyncReadExt; @@ -46,7 +46,6 @@ struct FeedbackRequestBody<'a> { installation_id: Option>, system_specs: SystemSpecs, is_staff: bool, - token: &'a str, } bitflags! { @@ -305,7 +304,6 @@ impl FeedbackModal { installation_id, system_specs, is_staff: is_staff.unwrap_or(false), - token: ZED_SECRET_CLIENT_TOKEN, }; let json_bytes = serde_json::to_vec(&request)?; let request = Request::post(feedback_endpoint) diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index b251453670..6486fc5db4 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -493,7 +493,6 @@ struct Panic { #[derive(Serialize)] struct PanicRequest { panic: Panic, - token: String, } static PANIC_COUNT: AtomicU32 = AtomicU32::new(0); @@ -657,11 +656,7 @@ async fn upload_previous_panics( }); if let Some(panic) = panic { - let body = serde_json::to_string(&PanicRequest { - panic, - token: client::ZED_SECRET_CLIENT_TOKEN.into(), - }) - .unwrap(); + let body = serde_json::to_string(&PanicRequest { panic }).unwrap(); let request = Request::post(&panic_report_url) .redirect_policy(isahc::config::RedirectPolicy::Follow) @@ -727,10 +722,6 @@ async fn upload_previous_crashes( let request = Request::post(&crash_report_url) .redirect_policy(isahc::config::RedirectPolicy::Follow) .header("Content-Type", "text/plain") - .header( - "Authorization", - format!("token {}", client::ZED_SECRET_CLIENT_TOKEN), - ) .body(body.into())?; let response = http.send(request).await.context("error sending crash")?; From b5ee7f8f2eebcf229a554932d28b9745082b5cad Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 23 Jan 2024 10:34:43 -0700 Subject: [PATCH 2/2] Remove ZED_CLIENT_SECRET_TOKEN --- .github/workflows/randomized_tests.yml | 53 +++++++++--------- script/randomized-test-ci | 75 +++++++++++++------------- 2 files changed, 65 insertions(+), 63 deletions(-) diff --git a/.github/workflows/randomized_tests.yml b/.github/workflows/randomized_tests.yml index a1704d58bd..a5e2d983ed 100644 --- a/.github/workflows/randomized_tests.yml +++ b/.github/workflows/randomized_tests.yml @@ -3,36 +3,35 @@ name: Randomized Tests concurrency: randomized-tests on: - push: - branches: - - randomized-tests-runner - # schedule: - # - cron: '0 * * * *' + push: + branches: + - randomized-tests-runner + # schedule: + # - cron: '0 * * * *' env: - CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: 0 - RUST_BACKTRACE: 1 - ZED_SERVER_URL: https://zed.dev - ZED_CLIENT_SECRET_TOKEN: ${{ secrets.ZED_CLIENT_SECRET_TOKEN }} + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + RUST_BACKTRACE: 1 + ZED_SERVER_URL: https://zed.dev jobs: - tests: - name: Run randomized tests - runs-on: - - self-hosted - - randomized-tests - steps: - - name: Install Node - uses: actions/setup-node@v3 - with: - node-version: "18" + tests: + name: Run randomized tests + runs-on: + - self-hosted + - randomized-tests + steps: + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: "18" - - name: Checkout repo - uses: actions/checkout@v3 - with: - clean: false - submodules: "recursive" + - name: Checkout repo + uses: actions/checkout@v3 + with: + clean: false + submodules: "recursive" - - name: Run randomized tests - run: script/randomized-test-ci + - name: Run randomized tests + run: script/randomized-test-ci diff --git a/script/randomized-test-ci b/script/randomized-test-ci index 4d3f85aef4..36eab40a7a 100755 --- a/script/randomized-test-ci +++ b/script/randomized-test-ci @@ -1,67 +1,70 @@ #!/usr/bin/env node --redirect-warnings=/dev/null -const fs = require('fs') -const {randomBytes} = require('crypto') -const {execFileSync} = require('child_process') -const {minimizeTestPlan, buildTests, runTests} = require('./randomized-test-minimize'); +const fs = require("fs"); +const { randomBytes } = require("crypto"); +const { execFileSync } = require("child_process"); +const { + minimizeTestPlan, + buildTests, + runTests, +} = require("./randomized-test-minimize"); -const {ZED_SERVER_URL, ZED_CLIENT_SECRET_TOKEN} = process.env -if (!ZED_SERVER_URL) throw new Error('Missing env var `ZED_SERVER_URL`') -if (!ZED_CLIENT_SECRET_TOKEN) throw new Error('Missing env var `ZED_CLIENT_SECRET_TOKEN`') +const { ZED_SERVER_URL } = process.env; +if (!ZED_SERVER_URL) throw new Error("Missing env var `ZED_SERVER_URL`"); -main() +main(); async function main() { - buildTests() + buildTests(); const seed = randomU64(); - const commit = execFileSync( - 'git', - ['rev-parse', 'HEAD'], - {encoding: 'utf8'} - ).trim() + const commit = execFileSync("git", ["rev-parse", "HEAD"], { + encoding: "utf8", + }).trim(); - console.log("commit:", commit) - console.log("starting seed:", seed) + console.log("commit:", commit); + console.log("starting seed:", seed); - const planPath = 'target/test-plan.json' - const minPlanPath = 'target/test-plan.min.json' + const planPath = "target/test-plan.json"; + const minPlanPath = "target/test-plan.min.json"; const failingSeed = runTests({ SEED: seed, SAVE_PLAN: planPath, ITERATIONS: 50000, OPERATIONS: 200, - }) + }); if (!failingSeed) { - console.log("tests passed") - return + console.log("tests passed"); + return; } - console.log("found failure at seed", failingSeed) - const minimizedSeed = minimizeTestPlan(planPath, minPlanPath) - const minimizedPlan = fs.readFileSync(minPlanPath, 'utf8') + console.log("found failure at seed", failingSeed); + const minimizedSeed = minimizeTestPlan(planPath, minPlanPath); + const minimizedPlan = fs.readFileSync(minPlanPath, "utf8"); - console.log("minimized plan:\n", minimizedPlan) + console.log("minimized plan:\n", minimizedPlan); - const url = `${ZED_SERVER_URL}/api/randomized_test_failure` + const url = `${ZED_SERVER_URL}/api/randomized_test_failure`; const body = { seed: minimizedSeed, - token: ZED_CLIENT_SECRET_TOKEN, plan: JSON.parse(minimizedPlan), commit: commit, - } + }; await fetch(url, { - method: 'POST', - headers: {"Content-Type": "application/json"}, - body: JSON.stringify(body) - }) + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(body), + }); - process.exit(1) + process.exit(1); } function randomU64() { - const bytes = randomBytes(8) - const hexString = bytes.reduce(((string, byte) => string + byte.toString(16)), '') - return BigInt('0x' + hexString).toString(10) + const bytes = randomBytes(8); + const hexString = bytes.reduce( + (string, byte) => string + byte.toString(16), + "", + ); + return BigInt("0x" + hexString).toString(10); }