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
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

View file

@ -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::<ReleaseChannel>()

View file

@ -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);

View file

@ -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<Arc<str>>,
session_id: Option<Arc<str>>,
is_staff: Option<bool>,
@ -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(),

View file

@ -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<Arc<str>>,
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)

View file

@ -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")?;

View file

@ -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);
}