





















@@ -246,7 +246,7 @@ describe("command explainer tree-sitter runtime", () => {
246246"python",
247247]);
248248expect(explanation.topLevelCommands[2]?.argv).toEqual(["python", "-c", 'print("hi")']);
249-expect(explanation.nestedCommands).toEqual([]);
249+expect(explanation.nestedCommands).toStrictEqual([]);
250250expect(explanation.topLevelCommands[2]?.span).toEqual(
251251expect.objectContaining({ startIndex: expect.any(Number), endIndex: expect.any(Number) }),
252252);
@@ -275,7 +275,7 @@ describe("command explainer tree-sitter runtime", () => {
275275it("marks command substitution in executable position as dynamic", async () => {
276276const explanation = await explainShellCommand("$(whoami) --help");
277277278-expect(explanation.topLevelCommands).toEqual([]);
278+expect(explanation.topLevelCommands).toStrictEqual([]);
279279expect(explanation.nestedCommands).toEqual([
280280expect.objectContaining({ context: "command-substitution", executable: "whoami" }),
281281]);
@@ -422,7 +422,7 @@ describe("command explainer tree-sitter runtime", () => {
422422);
423423424424const dynamicPayload = await explainShellCommand('bash -lc "$CMD"');
425-expect(dynamicPayload.nestedCommands).toEqual([]);
425+expect(dynamicPayload.nestedCommands).toStrictEqual([]);
426426expect(dynamicPayload.risks).toContainEqual(
427427expect.objectContaining({
428428kind: "shell-wrapper",
@@ -439,7 +439,7 @@ describe("command explainer tree-sitter runtime", () => {
439439const powershellPipeline = await explainShellCommand(
440440'pwsh -Command "Get-ChildItem | Select Name"',
441441);
442-expect(powershellPipeline.nestedCommands).toEqual([]);
442+expect(powershellPipeline.nestedCommands).toStrictEqual([]);
443443expect(powershellPipeline.risks).toContainEqual(
444444expect.objectContaining({
445445kind: "shell-wrapper",
@@ -514,25 +514,25 @@ describe("command explainer tree-sitter runtime", () => {
514514515515it("does not normalize dynamic executable names into trusted commands", async () => {
516516const dynamicPrefix = await explainShellCommand("e${CMD}ho hi");
517-expect(dynamicPrefix.topLevelCommands).toEqual([]);
517+expect(dynamicPrefix.topLevelCommands).toStrictEqual([]);
518518expect(dynamicPrefix.risks).toContainEqual(
519519expect.objectContaining({ kind: "dynamic-executable", text: "e${CMD}ho" }),
520520);
521521522522const dynamicQuoted = await explainShellCommand('"${CMD}" hi');
523-expect(dynamicQuoted.topLevelCommands).toEqual([]);
523+expect(dynamicQuoted.topLevelCommands).toStrictEqual([]);
524524expect(dynamicQuoted.risks).toContainEqual(
525525expect.objectContaining({ kind: "dynamic-executable", text: '"${CMD}"' }),
526526);
527527528528const dynamicGlob = await explainShellCommand("./ec* hi");
529-expect(dynamicGlob.topLevelCommands).toEqual([]);
529+expect(dynamicGlob.topLevelCommands).toStrictEqual([]);
530530expect(dynamicGlob.risks).toContainEqual(
531531expect.objectContaining({ kind: "dynamic-executable", text: "./ec*" }),
532532);
533533534534const dynamicBraceExpansion = await explainShellCommand("./{echo,printf} hi");
535-expect(dynamicBraceExpansion.topLevelCommands).toEqual([]);
535+expect(dynamicBraceExpansion.topLevelCommands).toStrictEqual([]);
536536expect(dynamicBraceExpansion.risks).toContainEqual(
537537expect.objectContaining({ kind: "dynamic-executable", text: "./{echo,printf}" }),
538538);
@@ -561,7 +561,7 @@ describe("command explainer tree-sitter runtime", () => {
561561);
562562563563const lineContinuation = await explainShellCommand("ec\\\nho hi");
564-expect(lineContinuation.topLevelCommands).toEqual([]);
564+expect(lineContinuation.topLevelCommands).toStrictEqual([]);
565565expect(lineContinuation.risks).toContainEqual(
566566expect.objectContaining({ kind: "line-continuation" }),
567567);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。