OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(dashboard): frame terminal input and skip unused activity (#1511)
mldangelo-oaia894386927e2
diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.tsindex 132ba6c57..dae47bf0b 100644--- a/sdk/typescript/src/cli.ts+++ b/sdk/typescript/src/cli.ts@@ -8544,13 +8544,15 @@ async function executeScan(progress?.stage(message);progress?.startTimer(runningMessage());},- onActivity: (activity) => {- if (dashboard === null) return;- dashboard.record(activity);- if (activity.paths.length > 0 && phase === "preflight") {- dashboard.setStage("inspecting repository files");- }- },+ onActivity:+ dashboard === null+ ? undefined+ : (activity) => {+ dashboard?.record(activity);+ if (activity.paths.length > 0 && phase === "preflight") {+ dashboard?.setStage("inspecting repository files");+ }+ },onSessionEvent:scanInput.isTTY === true? dashboard?.recordDetails.bind(dashboard)diff --git a/sdk/typescript/src/cost.ts b/sdk/typescript/src/cost.tsindex 851883500..27554b27f 100644--- a/sdk/typescript/src/cost.ts+++ b/sdk/typescript/src/cost.ts@@ -215,6 +215,10 @@ export class ScanCostTracker {async #readSessions(): Promise<void> {if (this.#threadId === null) return;+ const repository =+ this.#options.onActivity === undefined+ ? undefined+ : this.#options.repository;const unreadable: Array<{ session: SessionUsage; error: unknown }> = [];for await (const path of sessionFiles(join(this.#options.codexHome, "sessions"),@@ -225,7 +229,7 @@ export class ScanCostTracker {this.#sessions.set(path, session);}try {- await readSessionUsage(path, session, this.#options.repository);+ await readSessionUsage(path, session, repository);} catch (error) {if (session.threadId === null) throw error;unreadable.push({ session, error });@@ -288,7 +292,7 @@ export class ScanCostTracker {// Replay only newly associated sessions, including their early events.session = createSessionUsage();session.events = [];- await readSessionUsage(path, session, this.#options.repository);+ await readSessionUsage(path, session, repository);this.#sessions.set(path, session);}let worker: number | undefined;diff --git a/sdk/typescript/src/scan-dashboard.ts b/sdk/typescript/src/scan-dashboard.tsindex 8bce9fcef..4e4a80aea 100644--- a/sdk/typescript/src/scan-dashboard.ts+++ b/sdk/typescript/src/scan-dashboard.ts@@ -1,4 +1,6 @@import { basename, isAbsolute } from "node:path";+import { emitKeypressEvents } from "node:readline";+import { PassThrough } from "node:stream";import { pathToFileURL } from "node:url";import { stripVTControlCharacters } from "node:util";import { isRecord } from "./record.js";@@ -150,12 +152,112 @@ export class ScanDashboard {#noteCount = 0;#observingStreamErrors = false;readonly #onStreamError = (): void => {};+ #keyInput: PassThrough | null = null;+ #inputKeys: {+ keys: string[];+ continued: boolean;+ replay: boolean | string;+ text: string;+ } | null = null;readonly #onInput = (chunk: string | Uint8Array): void => {- const input =- typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");+ const batch = {+ keys: [] as string[],+ continued: false,+ replay: false as boolean | string,+ text: "",+ };+ let current = chunk;+ do {+ batch.replay = false;+ this.#inputKeys = batch;+ try {+ this.#keyInput?.write(current);+ } finally {+ this.#inputKeys = null;+ }+ if (typeof batch.replay === "string") current = batch.replay;+ } while (batch.replay);+ this.#handleKeys(batch.keys);+ };++ #setKeyInput(input: PassThrough | null): void {+ const previous = this.#keyInput;+ if (previous !== null) {+ previous.removeAllListeners("keypress");+ previous.on("keypress", () => {});+ // Readline clears its Escape timer on input, after the active keypress returns.+ queueMicrotask(() => {+ previous.write(" ");+ previous.removeAllListeners();+ previous.destroy();+ });+ }+ this.#keyInput = input;+ if (input === null) return;+ let pending = 0;+ input.setEncoding("utf8");+ input.on("data", (text: string) => {+ if (this.#inputKeys !== null) {+ this.#inputKeys.continued = pending > 0;+ this.#inputKeys.text = text;+ }+ pending += text.length;+ });+ emitKeypressEvents(input);+ input.on(+ "keypress",+ (+ _text: unknown,+ key: { sequence: string; meta?: boolean; code?: string },+ ) => {+ pending -= key.sequence.length;+ const escapes =+ key.code === undefined+ ? undefined+ : key.sequence.match(/^\u001B+(?=\u001B)/u)?.[0];+ const keys =+ (key.meta && key.code === undefined) ||+ key.sequence.includes("\u0003")+ ? Array.from(key.sequence)+ : escapes !== undefined+ ? [...escapes, key.sequence.slice(escapes.length)]+ : [key.sequence];+ const batch = this.#inputKeys;+ const continued = batch?.continued === true;+ if (batch !== null) batch.continued = false;+ if (batch === null) this.#handleKeys(keys);+ else if (+ this.#budget === null &&+ keys.length > 1 &&+ keys.every((key) => key === "\u001B")+ ) {+ // Readline can consume a following key's Escape as a repeated Escape.+ // Keep that introducer with the remaining decoded text for replay.+ const remaining =+ key.sequence + (pending ? batch.text.slice(-pending) : "");+ const prefix = remaining.match(/^\u001B+/u)![0];+ for (const escape of prefix.slice(0, -1)) batch.keys.push(escape);+ this.#setKeyInput(new PassThrough());+ batch.replay = remaining.slice(prefix.length - 1);+ } else if (+ this.#budget !== null &&+ batch.keys.length === 0 &&+ keys.length > 1 &&+ keys[0] === "\u001B" &&+ continued+ ) {+ // The buffered Escape belongs to the prior chunk's budget dismissal.+ // Decode this chunk again after that transition, retaining its own keys.+ this.#handleKeys(["\u001B"]);+ batch.replay = true;+ } else batch.keys.push(...keys);+ },+ );+ }++ #handleKeys(keys: string[]): void {if (this.#budget !== null) {- for (const key of input.match(/\u001B\[[0-?]*[ -/]*[@-~]|[\s\S]/gu) ??- []) {+ for (const key of keys) {const budget = this.#budget;if (budget === null) break;if (key === "\u0003" || key === "\u0004") {@@ -187,13 +289,11 @@ export class ScanDashboard {return;}if (this.#options.presentation === "components") {- this.#componentInput(input);+ this.#componentInput(keys);return;}let lines = 0;- for (const key of input.match(- /[\u0003\u0004\u0015dam1-9]|\u001B\[(?:[ABHF]|[1456]~)/gu,- ) ?? []) {+ for (const key of keys) {if (key === "\u0003") {if (lines !== 0) this.scroll(lines);this.#options.onInterrupt?.();@@ -227,7 +327,9 @@ export class ScanDashboard {lines += this.#activityRows();} else if (key === "\u001B[6~") {lines -= this.#activityRows();- } else {+ } else if (+ ["\u001B[H", "\u001B[F", "\u001B[1~", "\u001B[4~"].includes(key)+ ) {if (lines !== 0) this.scroll(lines);this.scroll(key === "\u001B[H" || key === "\u001B[1~"@@ -238,7 +340,7 @@ export class ScanDashboard {}}if (lines !== 0) this.scroll(lines);- };+ }public constructor(stream: DashboardStream, options: ScanDashboardOptions) {this.#stream = stream;@@ -260,6 +362,7 @@ export class ScanDashboard {}this.#stream.write(`${ENTER_ALTERNATE_SCREEN}${HIDE_CURSOR}`);if (input?.isTTY === true) {+ this.#setKeyInput(new PassThrough());input.setRawMode?.(true);input.resume?.();input.on("data", this.#onInput);@@ -289,6 +392,7 @@ export class ScanDashboard {try {if (input?.isTTY === true) {input.off("data", this.#onInput);+ this.#setKeyInput(null);input.setRawMode?.(this.#inputWasRaw);input.pause?.();}@@ -434,11 +538,13 @@ export class ScanDashboard {) {return Promise.resolve(undefined);}+ this.#setKeyInput(new PassThrough());return new Promise((resolve) => {const abort = () => finish();const finish = (limit?: number) => {request.signal.removeEventListener("abort", abort);this.#budget = null;+ if (this.#timer !== null) this.#setKeyInput(new PassThrough());this.#refresh();resolve(limit);};@@ -660,15 +766,16 @@ export class ScanDashboard {);}- #componentInput(input: string): void {- for (const key of input.match(- /\u001B\[(?:[ABHF]|[1456]~)|[\u0003\u0004\u0015\r\n\u001Bbdam1-9]/gu,- ) ?? []) {+ #componentInput(keys: string[]): void {+ for (const key of keys) {if (key === "\u0003") {this.#options.onInterrupt?.();} else if (this.#showComponent) {if (key === "\u001B" || key === "b") this.#showComponent = false;- else this.#components[this.#selectedComponent]!.dashboard.#onInput(key);+ else+ this.#components[this.#selectedComponent]!.dashboard.#handleKeys([+ key,+ ]);} else if ((key === "\r" || key === "\n") &&this.#components.length > 0diff --git a/sdk/typescript/tests-ts/cli.test.ts b/sdk/typescript/tests-ts/cli.test.tsindex 317922721..7acb9bda9 100644--- a/sdk/typescript/tests-ts/cli.test.ts+++ b/sdk/typescript/tests-ts/cli.test.ts@@ -1886,6 +1886,7 @@ describe("CLI", () => {environment,result,costUpdates: [result.cost!],+ onTurn: (_repository, scan) => expect(scan?.onActivity).toBeUndefined(),scanProgress: [{ phase: "discovery", filesCompleted: 3, filesTotal: 8 },],diff --git a/sdk/typescript/tests-ts/scan-dashboard.test.ts b/sdk/typescript/tests-ts/scan-dashboard.test.tsindex f2bb7ac88..3a0487c3c 100644--- a/sdk/typescript/tests-ts/scan-dashboard.test.ts+++ b/sdk/typescript/tests-ts/scan-dashboard.test.ts@@ -2,11 +2,13 @@ import { EventEmitter } from "node:events";import { Writable } from "node:stream";import { pathToFileURL } from "node:url";import { stripVTControlCharacters } from "node:util";-import { describe, expect, test, mock } from "bun:test";+import { afterEach, describe, expect, test, mock, jest } from "bun:test";import type { ComponentReceipt } from "../src/component-scan.js";import { ScanDashboard } from "../src/scan-dashboard.js";import { capture, fakeResult } from "./cli-fixtures.js";+afterEach(() => jest.useRealTimers());+const STARTED_AT = new Date(2026, 6, 29, 9, 41, 0).getTime();function fakeClock(now: () => number = () => STARTED_AT) {@@ -120,7 +122,10 @@ describe("live scan dashboard", () => {cost,signal: controller.signal,});- input.emit("data", "-30\r");+ for (const byte of Buffer.from("é🙂"))+ input.emit("data", Uint8Array.of(byte));+ expect(stderr.text()).toContain("é🙂_");+ input.emit("data", "\u0015-30\r");expect(stderr.text()).toContain("Enter a finite total above");input.emit("data", "\u00150\r");input.emit("data", "\u0015Infinity\r");@@ -148,6 +153,394 @@ describe("live scan dashboard", () => {expect(input.listenerCount("data")).toBe(0);});+ test.each([+ "\u001B[A",+ "\u001B[B",+ "\u001B[H",+ "\u001B[F",+ "\u001B[1~",+ "\u001B[4~",+ "\u001B[5~",+ "\u001B[6~",+ ])(+ "keeps the budget prompt open across every split of %j",+ async (sequence) => {+ const input = new DashboardTestInput();+ const dashboard = createDashboard(capture(true).stream, {+ input,+ maxCostUsd: 20,+ });+ dashboard.start();+ try {+ for (let split = 0; split <= sequence.length; split++) {+ const answer = dashboard.requestBudgetIncrease({+ maxCostUsd: 20,+ cost: {+ ...fakeResult([], "complete", {+ input_tokens: 100,+ output_tokens: 1,+ }).cost!,+ estimatedUsd: 16,+ },+ signal: new AbortController().signal,+ });+ input.emit("data", sequence.slice(0, split));+ input.emit("data", sequence.slice(split) + "30\r");+ await expect(answer).resolves.toBe(30);+ }+ } finally {+ dashboard.stop();+ }+ },+ );++ test.each(+ [false, true].flatMap((coalesced) =>+ [1, 2, 3].map((escapes) => ({ coalesced, escapes })),+ ),+ )(+ "cancels the budget before navigation coalesced=$coalesced escapes=$escapes",+ async ({ coalesced, escapes }) => {+ jest.useFakeTimers();+ for (const navigation of [+ "\u001B[A",+ "\u001B[B",+ "\u001B[H",+ "\u001B[F",+ "\u001B[1~",+ "\u001B[4~",+ "\u001B[5~",+ "\u001B[6~",+ "\u001BOA",+ "\u001BOB",+ "\u001B[1;3A",+ "\u001B[1;5A",+ ]) {+ const input = new DashboardTestInput();+ const dashboard = createDashboard(capture(true).stream, { input });+ dashboard.start();+ try {+ const answer = dashboard.requestBudgetIncrease({+ maxCostUsd: 20,+ cost: fakeResult([], "complete", {+ input_tokens: 100,+ output_tokens: 1,+ }).cost!,+ signal: new AbortController().signal,+ });+ input.emit("data", "30");+ const prefix = "\u001B".repeat(escapes);+ const chunks = coalesced+ ? [prefix + navigation]+ : [prefix, navigation];+ for (const chunk of chunks) input.emit("data", Buffer.from(chunk));+ input.emit("data", "\r");+ await expect(answer).resolves.toBeUndefined();+ } finally {+ dashboard.stop();+ await Promise.resolve();+ }+ expect(jest.getTimerCount()).toBe(0);+ }+ },+ );++ test.each(+ [false, true].flatMap((coalesced) =>+ [1, 2, 3].map((escapes) => ({ coalesced, escapes })),+ ),+ )(+ "returns from a component before navigation coalesced=$coalesced escapes=$escapes",+ async ({ coalesced, escapes }) => {+ jest.useFakeTimers();+ const stderr = capture(true);+ const input = new DashboardTestInput();+ const dashboard = createDashboard(stderr.stream, {+ input,+ presentation: "components",+ });+ const components: ComponentReceipt[] = ["API", "Web"].map(+ (name, index) => ({+ id: `component-${index}`,+ name,+ paths: [`src/${name}`],+ status: "started",+ outputDir: `/synthetic/results/${index}`,+ }),+ );+ dashboard.start();+ try {+ dashboard.setComponents(components);+ for (const component of components)+ dashboard.recordComponentEvent({+ componentId: component.id,+ type: "activity",+ value: {+ id: component.id,+ kind: "message",+ status: "completed",+ description: `${component.name} activity`,+ paths: [],+ },+ });+ input.emit("data", "\r");+ expect(lastFrame(stderr)).toContain("API activity");+ const prefix = "\u001B".repeat(escapes);+ const chunks = coalesced ? [prefix + "\u001B[B"] : [prefix, "\u001B[B"];+ for (const chunk of chunks) input.emit("data", Buffer.from(chunk));+ input.emit("data", "\r");+ expect(lastFrame(stderr)).toContain("Web activity");+ expect(lastFrame(stderr)).not.toContain("API activity");+ } finally {+ dashboard.stop();+ await Promise.resolve();+ }+ expect(jest.getTimerCount()).toBe(0);+ },+ );++ test("discards pasted keys and partial sequences after a budget answer", async () => {+ const stderr = capture(true);+ const input = new DashboardTestInput();+ const onInterrupt = mock();+ const dashboard = createDashboard(+ { ...stderr.stream, rows: 14 },+ { input, onInterrupt, maxCostUsd: 20 },+ );+ dashboard.start();+ try {+ for (let index = 0; index < 20; index++)+ dashboard.note(`Activity ${index}`);+ const answer = dashboard.requestBudgetIncrease({+ maxCostUsd: 20,+ cost: {+ ...fakeResult([], "complete", { input_tokens: 100, output_tokens: 1 })+ .cost!,+ estimatedUsd: 16,+ },+ signal: new AbortController().signal,+ });+ input.emit("data", "30\rd\u0003\u001B[");+ await expect(answer).resolves.toBe(30);+ input.emit("data", "A");+ expect(lastFrame(stderr)).not.toContain("above live");+ expect(lastFrame(stderr)).not.toContain("DETAILS");+ expect(onInterrupt).not.toHaveBeenCalled();+ input.emit("data", "d");+ expect(lastFrame(stderr)).toContain("DETAILS");+ } finally {+ dashboard.stop();+ }+ });++ test.each(["\u001B", "\u001B["])(+ "discards a pending %j when entering a budget prompt",+ async (sequence) => {+ jest.useFakeTimers();+ const input = new DashboardTestInput();+ const dashboard = createDashboard(capture(true).stream, { input });+ dashboard.start();+ try {+ input.emit("data", sequence);+ const answer = dashboard.requestBudgetIncrease({+ maxCostUsd: 20,+ cost: fakeResult([], "complete", {+ input_tokens: 100,+ output_tokens: 1,+ }).cost!,+ signal: new AbortController().signal,+ });+ await Promise.resolve();+ expect(jest.getTimerCount()).toBe(0);+ jest.runAllTimers();+ input.emit("data", "30\r");+ await expect(answer).resolves.toBe(30);+ } finally {+ dashboard.stop();+ }+ },+ );++ test("discards a partial key when a budget request aborts externally", async () => {+ jest.useFakeTimers();+ const stderr = capture(true);+ const input = new DashboardTestInput();+ const dashboard = createDashboard(+ { ...stderr.stream, rows: 14 },+ { input },+ );+ const controller = new AbortController();+ dashboard.start();+ try {+ for (let index = 0; index < 20; index++)+ dashboard.note(`Activity ${index}`);+ const answer = dashboard.requestBudgetIncrease({+ maxCostUsd: 20,+ cost: fakeResult([], "complete", {+ input_tokens: 100,+ output_tokens: 1,+ }).cost!,+ signal: controller.signal,+ });+ input.emit("data", "\u001B[");+ controller.abort();+ await expect(answer).resolves.toBeUndefined();+ input.emit("data", "A");+ expect(lastFrame(stderr)).not.toContain("above live");+ expect(jest.getTimerCount()).toBe(0);+ } finally {+ dashboard.stop();+ }+ });++ test("owns only its input listeners and drops pending Escape on stop and restart", async () => {+ jest.useFakeTimers();+ const stderr = capture(true);+ const input = new DashboardTestInput();+ input.isRaw = true;+ const observer = mock();+ input.on("data", observer);+ input.on("keypress", observer);+ const onInterrupt = mock();+ const dashboard = createDashboard(stderr.stream, { input, onInterrupt });+ dashboard.start();+ input.emit("data", "\u001B");+ expect(jest.getTimerCount()).toBe(1);+ dashboard.stop();+ await Promise.resolve();+ expect(jest.getTimerCount()).toBe(0);+ const stopped = stderr.text();+ jest.runAllTimers();+ expect(stderr.text()).toBe(stopped);+ expect(onInterrupt).not.toHaveBeenCalled();+ expect(input.isRaw).toBe(true);+ expect(input.listenerCount("data")).toBe(1);+ expect(input.listenerCount("keypress")).toBe(1);+ dashboard.start();+ input.emit("data", "d");+ expect(lastFrame(stderr)).toContain("DETAILS");+ dashboard.stop();+ expect(observer).toHaveBeenCalledTimes(2);+ });++ test.each(["scan", "budget", "components", "component detail"] as const)(+ "preserves Escape-prefixed cancellation and chunk ownership in %s",+ async (mode) => {+ jest.useFakeTimers();+ for (const chunks of [+ ["\u001B", "\u0003"],+ ["\u001B\u0003"],+ ["\u001B", "\u001B"],+ ["\u001B\u001B"],+ ["\u001B[", "\u0003"],+ ["\u001B[\u0003"],+ ["\u001BO", "\u0003"],+ ["\u001BO\u0003"],+ ["\u001B", "\u0003d"],+ ["\u001B\u0003d"],+ ["\u001B", "\u001B\u0003"],+ ["\u001B\u001B", "\u0003"],+ ["\u001B\u001B\u0003"],+ ["\u001B", "\u001B\u0003d"],+ ["\u001B\u001B[\u0003"],+ ["\u001B", "\u001B[\u0003"],+ ["\u001B\u001B", "[\u0003"],+ ["\u001B\u001B[", "\u0003"],+ ["\u001B", "\u001B", "[\u0003"],+ ["\u001B", "\u001B[", "\u0003"],+ ["\u001B\u001B", "[", "\u0003"],+ ["\u001B", "\u001B", "[", "\u0003"],+ ...Array.from({ length: 8 }, (_, index) => {+ const escapes = "\u001B".repeat(index + 1);+ return [+ ["\u001B", `${escapes}\u0003`],+ [escapes, "\u001B\u0003"],+ [escapes, "\u0003"],+ [`${escapes}\u0003`],+ ];+ }).flat(),+ ]) {+ const stderr = capture(true);+ const input = new DashboardTestInput();+ input.isRaw = true;+ const observer = mock();+ input.on("data", observer);+ input.on("keypress", observer);+ const controller = new AbortController();+ const onInterrupt = mock(() => controller.abort("SIGINT"));+ const dashboard = createDashboard(stderr.stream, {+ input,+ presentation: mode.startsWith("component") ? "components" : "scan",+ onInterrupt,+ });+ let answer: number | undefined | "pending" = "pending";+ const pasted =+ mode === "budget"+ ? Array.from(Buffer.from("é🙂界"), (byte) => Uint8Array.of(byte))+ : [];+ dashboard.start();+ try {+ if (mode === "component detail") {+ dashboard.setComponents([+ {+ id: "component",+ name: "Component",+ paths: ["src"],+ status: "started",+ outputDir: "/synthetic/results",+ },+ ]);+ input.emit("data", "\r");+ }+ if (mode === "budget")+ void dashboard+ .requestBudgetIncrease({+ maxCostUsd: 20,+ cost: fakeResult([], "complete", {+ input_tokens: 100,+ output_tokens: 1,+ }).cost!,+ signal: controller.signal,+ })+ .then((value) => {+ answer = value;+ });+ for (const chunk of pasted) input.emit("data", chunk);+ if (mode === "budget") {+ expect(lastFrame(stderr)).toContain("é🙂界");+ expect(lastFrame(stderr)).not.toContain("\uFFFD");+ }+ for (const chunk of chunks) input.emit("data", Buffer.from(chunk));+ await Promise.resolve();+ jest.runAllTimers();+ await Promise.resolve();+ const interrupted =+ chunks.some((chunk) => chunk.includes("\u0003")) &&+ (mode !== "budget" || chunks.length > 1);+ expect(onInterrupt).toHaveBeenCalledTimes(interrupted ? 1 : 0);+ expect(controller.signal.aborted).toBe(interrupted);+ if (mode === "budget") {+ expect(answer).toBeUndefined();+ if (chunks.at(-1)?.endsWith("d"))+ expect(lastFrame(stderr).includes("DETAILS")).toBe(+ chunks.length > 1,+ );+ }+ } finally {+ dashboard.stop();+ await Promise.resolve();+ }+ expect(input.isRaw).toBe(true);+ expect(input.listenerCount("data")).toBe(1);+ expect(input.listenerCount("keypress")).toBe(1);+ expect(observer).toHaveBeenCalledTimes(+ pasted.length + chunks.length + Number(mode === "component detail"),+ );+ expect(jest.getTimerCount()).toBe(0);+ }+ },+ );+test.each(["enter", "escape", "abort", "stop", "interrupt", "eof"] as const)("dismisses a budget prompt without increasing the limit on %s",async (action) => {@@ -191,7 +584,8 @@ describe("live scan dashboard", () => {},);- test("shows concurrent components and keeps their activity and costs separate", () => {+ test("shows concurrent components and keeps their activity and costs separate", async () => {+ jest.useFakeTimers();const stderr = capture(true);const input = new DashboardTestInput();let timers = 0;@@ -299,7 +693,10 @@ describe("live scan dashboard", () => {expect(frame()).toContain("API session detail");expect(frame()).not.toContain("Web session detail");input.emit("data", "\u001B");- input.emit("data", "\u001B[B\r");+ jest.advanceTimersToNextTimer();+ await Promise.resolve();+ input.emit("data", "\u001B[");+ input.emit("data", "B\r");expect(frame()).toContain("Web only activity");expect(frame()).not.toContain("API only activity");dashboard.updateComponent({@@ -825,7 +1222,8 @@ describe("live scan dashboard", () => {frame.indexOf("finding-20"),);- input.emit("data", "\u001B[A");+ input.emit("data", "\u001B");+ input.emit("data", "[A");frame = lastFrame(stderr);expect(frame).toContain("finding-15");expect(frame).not.toContain("finding-20");@@ -837,12 +1235,14 @@ describe("live scan dashboard", () => {expect(frame).not.toContain("finding-20");expect(frame).toContain("1 line above live");- input.emit("data", "\u001B[H");+ input.emit("data", "\u001B[");+ input.emit("data", "H");frame = lastFrame(stderr);expect(frame).toContain("finding-1");expect(frame).not.toContain("finding-20");- input.emit("data", "\u001B[F");+ input.emit("data", "\u001B[");+ input.emit("data", "F");frame = lastFrame(stderr);expect(frame).toContain("finding-20");expect(frame).not.toContain("events · live");@@ -929,9 +1329,11 @@ describe("live scan dashboard", () => {expect(frame).toContain("finding-20");expect(frame).not.toContain("above live");- input.emit("data", "\u001B[5~");+ input.emit("data", "\u001B[5");+ input.emit("data", "~");expect(lastFrame(stderr)).toContain("7 lines above live");- input.emit("data", "\u001B[6~");+ input.emit("data", "\u001B");+ input.emit("data", "[6~");expect(lastFrame(stderr)).not.toContain("above live");dashboard.stop();});