less secret (#4221)

- Remove ZED_SECRET_CLIENT_TOKEN
- Remove ZED_CLIENT_SECRET_TOKEN

Neither of these were ever actually a secret.

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-01-23 10:43:15 -07:00 committed by GitHub
commit 3d5da2f4d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 70 additions and 84 deletions

View file

@ -3,36 +3,35 @@ name: Randomized Tests
concurrency: randomized-tests concurrency: randomized-tests
on: on:
push: push:
branches: branches:
- randomized-tests-runner - randomized-tests-runner
# schedule: # schedule:
# - cron: '0 * * * *' # - cron: '0 * * * *'
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0 CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
ZED_SERVER_URL: https://zed.dev ZED_SERVER_URL: https://zed.dev
ZED_CLIENT_SECRET_TOKEN: ${{ secrets.ZED_CLIENT_SECRET_TOKEN }}
jobs: jobs:
tests: tests:
name: Run randomized tests name: Run randomized tests
runs-on: runs-on:
- self-hosted - self-hosted
- randomized-tests - randomized-tests
steps: steps:
- name: Install Node - name: Install Node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: "18" node-version: "18"
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
clean: false clean: false
submodules: "recursive" submodules: "recursive"
- name: Run randomized tests - name: Run randomized tests
run: script/randomized-test-ci run: script/randomized-test-ci

View file

@ -1,7 +1,7 @@
mod update_notification; mod update_notification;
use anyhow::{anyhow, Context, Result}; 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::kvp::KEY_VALUE_STORE;
use db::RELEASE_CHANNEL; use db::RELEASE_CHANNEL;
use gpui::{ use gpui::{
@ -248,9 +248,7 @@ impl AutoUpdater {
) )
})?; })?;
let mut url_string = format!( let mut url_string = format!("{server_url}/api/releases/latest?asset=Zed.dmg");
"{server_url}/api/releases/latest?token={ZED_SECRET_CLIENT_TOKEN}&asset=Zed.dmg"
);
cx.update(|cx| { cx.update(|cx| {
if let Some(param) = cx if let Some(param) = cx
.try_global::<ReleaseChannel>() .try_global::<ReleaseChannel>()

View file

@ -68,7 +68,6 @@ lazy_static! {
std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| e.len() > 0); 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 INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(100);
pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5); pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5);

View file

@ -1,6 +1,6 @@
mod event_coalescer; mod event_coalescer;
use crate::{TelemetrySettings, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL}; use crate::{TelemetrySettings, ZED_SERVER_URL};
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use futures::Future; use futures::Future;
use gpui::{AppContext, AppMetadata, BackgroundExecutor, Task}; use gpui::{AppContext, AppMetadata, BackgroundExecutor, Task};
@ -51,7 +51,6 @@ lazy_static! {
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
struct EventRequestBody { struct EventRequestBody {
token: &'static str,
installation_id: Option<Arc<str>>, installation_id: Option<Arc<str>>,
session_id: Option<Arc<str>>, session_id: Option<Arc<str>>,
is_staff: Option<bool>, is_staff: Option<bool>,
@ -527,7 +526,6 @@ impl Telemetry {
{ {
let state = this.state.lock(); let state = this.state.lock();
let request_body = EventRequestBody { let request_body = EventRequestBody {
token: ZED_SECRET_CLIENT_TOKEN,
installation_id: state.installation_id.clone(), installation_id: state.installation_id.clone(),
session_id: state.session_id.clone(), session_id: state.session_id.clone(),
is_staff: state.is_staff.clone(), is_staff: state.is_staff.clone(),

View file

@ -2,7 +2,7 @@ use std::{ops::RangeInclusive, sync::Arc, time::Duration};
use anyhow::{anyhow, bail}; use anyhow::{anyhow, bail};
use bitflags::bitflags; 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 db::kvp::KEY_VALUE_STORE;
use editor::{Editor, EditorEvent}; use editor::{Editor, EditorEvent};
use futures::AsyncReadExt; use futures::AsyncReadExt;
@ -46,7 +46,6 @@ struct FeedbackRequestBody<'a> {
installation_id: Option<Arc<str>>, installation_id: Option<Arc<str>>,
system_specs: SystemSpecs, system_specs: SystemSpecs,
is_staff: bool, is_staff: bool,
token: &'a str,
} }
bitflags! { bitflags! {
@ -305,7 +304,6 @@ impl FeedbackModal {
installation_id, installation_id,
system_specs, system_specs,
is_staff: is_staff.unwrap_or(false), is_staff: is_staff.unwrap_or(false),
token: ZED_SECRET_CLIENT_TOKEN,
}; };
let json_bytes = serde_json::to_vec(&request)?; let json_bytes = serde_json::to_vec(&request)?;
let request = Request::post(feedback_endpoint) let request = Request::post(feedback_endpoint)

View file

@ -493,7 +493,6 @@ struct Panic {
#[derive(Serialize)] #[derive(Serialize)]
struct PanicRequest { struct PanicRequest {
panic: Panic, panic: Panic,
token: String,
} }
static PANIC_COUNT: AtomicU32 = AtomicU32::new(0); static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
@ -657,11 +656,7 @@ async fn upload_previous_panics(
}); });
if let Some(panic) = panic { if let Some(panic) = panic {
let body = serde_json::to_string(&PanicRequest { let body = serde_json::to_string(&PanicRequest { panic }).unwrap();
panic,
token: client::ZED_SECRET_CLIENT_TOKEN.into(),
})
.unwrap();
let request = Request::post(&panic_report_url) let request = Request::post(&panic_report_url)
.redirect_policy(isahc::config::RedirectPolicy::Follow) .redirect_policy(isahc::config::RedirectPolicy::Follow)
@ -727,10 +722,6 @@ async fn upload_previous_crashes(
let request = Request::post(&crash_report_url) let request = Request::post(&crash_report_url)
.redirect_policy(isahc::config::RedirectPolicy::Follow) .redirect_policy(isahc::config::RedirectPolicy::Follow)
.header("Content-Type", "text/plain") .header("Content-Type", "text/plain")
.header(
"Authorization",
format!("token {}", client::ZED_SECRET_CLIENT_TOKEN),
)
.body(body.into())?; .body(body.into())?;
let response = http.send(request).await.context("error sending crash")?; let response = http.send(request).await.context("error sending crash")?;

View file

@ -1,67 +1,70 @@
#!/usr/bin/env node --redirect-warnings=/dev/null #!/usr/bin/env node --redirect-warnings=/dev/null
const fs = require('fs') const fs = require("fs");
const {randomBytes} = require('crypto') const { randomBytes } = require("crypto");
const {execFileSync} = require('child_process') const { execFileSync } = require("child_process");
const {minimizeTestPlan, buildTests, runTests} = require('./randomized-test-minimize'); const {
minimizeTestPlan,
buildTests,
runTests,
} = require("./randomized-test-minimize");
const {ZED_SERVER_URL, ZED_CLIENT_SECRET_TOKEN} = process.env const { ZED_SERVER_URL } = process.env;
if (!ZED_SERVER_URL) throw new Error('Missing env var `ZED_SERVER_URL`') 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`')
main() main();
async function main() { async function main() {
buildTests() buildTests();
const seed = randomU64(); const seed = randomU64();
const commit = execFileSync( const commit = execFileSync("git", ["rev-parse", "HEAD"], {
'git', encoding: "utf8",
['rev-parse', 'HEAD'], }).trim();
{encoding: 'utf8'}
).trim()
console.log("commit:", commit) console.log("commit:", commit);
console.log("starting seed:", seed) console.log("starting seed:", seed);
const planPath = 'target/test-plan.json' const planPath = "target/test-plan.json";
const minPlanPath = 'target/test-plan.min.json' const minPlanPath = "target/test-plan.min.json";
const failingSeed = runTests({ const failingSeed = runTests({
SEED: seed, SEED: seed,
SAVE_PLAN: planPath, SAVE_PLAN: planPath,
ITERATIONS: 50000, ITERATIONS: 50000,
OPERATIONS: 200, OPERATIONS: 200,
}) });
if (!failingSeed) { if (!failingSeed) {
console.log("tests passed") console.log("tests passed");
return return;
} }
console.log("found failure at seed", failingSeed) console.log("found failure at seed", failingSeed);
const minimizedSeed = minimizeTestPlan(planPath, minPlanPath) const minimizedSeed = minimizeTestPlan(planPath, minPlanPath);
const minimizedPlan = fs.readFileSync(minPlanPath, 'utf8') 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 = { const body = {
seed: minimizedSeed, seed: minimizedSeed,
token: ZED_CLIENT_SECRET_TOKEN,
plan: JSON.parse(minimizedPlan), plan: JSON.parse(minimizedPlan),
commit: commit, commit: commit,
} };
await fetch(url, { await fetch(url, {
method: 'POST', method: "POST",
headers: {"Content-Type": "application/json"}, headers: { "Content-Type": "application/json" },
body: JSON.stringify(body) body: JSON.stringify(body),
}) });
process.exit(1) process.exit(1);
} }
function randomU64() { function randomU64() {
const bytes = randomBytes(8) const bytes = randomBytes(8);
const hexString = bytes.reduce(((string, byte) => string + byte.toString(16)), '') const hexString = bytes.reduce(
return BigInt('0x' + hexString).toString(10) (string, byte) => string + byte.toString(16),
"",
);
return BigInt("0x" + hexString).toString(10);
} }