Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
address review comments
adilson24f092a1dcd0
diff --git a/frontend/src/components/v3/generic/IconButton/IconButton.tsx b/frontend/src/components/v3/generic/IconButton/IconButton.tsxindex b6cc473039..588ff281b6 100644--- a/frontend/src/components/v3/generic/IconButton/IconButton.tsx+++ b/frontend/src/components/v3/generic/IconButton/IconButton.tsx@@ -123,12 +123,12 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(return (<Compref={ref}- data-slot="icon-button"type={type}className={cn(iconButtonVariants({ variant, size, isPending }), className)}aria-busy={isPending || undefined}disabled={isPending || disabled || isDisabled}{...props}+ data-slot="icon-button">{content}</Comp>diff --git a/frontend/src/components/v3/platform/SecretInput/SecretInput.stories.tsx b/frontend/src/components/v3/platform/SecretInput/SecretInput.stories.tsxindex ab0b52c24e..c7584388d4 100644--- a/frontend/src/components/v3/platform/SecretInput/SecretInput.stories.tsx+++ b/frontend/src/components/v3/platform/SecretInput/SecretInput.stories.tsx@@ -58,9 +58,9 @@ export const InvisibleCharacters: Story = {isVisible: true,value: ["{",- ' "HILTON_BASE_URL":\u00a0"https://kapip-s.hilton.io/gateway",',- ' "HILTON_API_KEY": "a1b2c3d4e5",',- ' "HILTON_TIMEOUT": 30\u200b',+ ' "BASE_URL":\u00a0"https://example.com",',+ ' "API_KEY": "a1b2c3d4e5",',+ ' "TIMEOUT": 30\u200b',"\ufeff}",REFERENCE_WITH_NBSP].join("\n"),diff --git a/frontend/src/components/v3/platform/SecretInput/SecretInput.test.tsx b/frontend/src/components/v3/platform/SecretInput/SecretInput.test.tsxindex 5ed8b9284e..454419e418 100644--- a/frontend/src/components/v3/platform/SecretInput/SecretInput.test.tsx+++ b/frontend/src/components/v3/platform/SecretInput/SecretInput.test.tsx@@ -1,4 +1,5 @@/* eslint-disable no-template-curly-in-string */+import { type ReactNode } from "react";import { renderToStaticMarkup } from "react-dom/server";import assert from "node:assert/strict";import { describe, it, vi } from "vitest";@@ -11,11 +12,29 @@ import { SecretInput } from "./SecretInput";// The @app/hooks barrel pulls in the router and API client, which cannot load outside the app.vi.mock("@app/hooks", async () => import("@app/hooks/useToggle"));+// Radix keeps tooltip content unmounted until it opens, which static markup never does.+vi.mock("../../generic/Tooltip", async () => {+ const { createElement } = await import("react");++ return {+ Tooltip: ({ children }: { children: ReactNode }) => children,+ TooltipTrigger: ({ children }: { children: ReactNode }) => children,+ TooltipContent: ({ children }: { children: ReactNode }) =>+ createElement("div", { "data-slot": "tooltip-content" }, children)+ };+});+const MARKER_REGEX = /<span class="[^"]*bg-warning\/25[^"]*">([^<]*)<\/span>/g;const WARNING_ICON = 'aria-label="Value contains invisible characters"';+const ICON_BUTTON = 'data-slot="icon-button"';+const TOOLTIP_INTRO = "This value contains invisible characters that can break it when used:";+const TOOLTIP_ITEM_REGEX = /<li>([^<]*)<\/li>/g;const markedChars = (markup: string) => [...markup.matchAll(MARKER_REGEX)].map(([, char]) => char);+const tooltipItems = (markup: string) =>+ [...markup.matchAll(TOOLTIP_ITEM_REGEX)].map(([, text]) => text);+const render = (value: string, isVisible = true) =>renderToStaticMarkup(<SecretInput value={value} isVisible={isVisible} readOnly />);@@ -85,11 +104,15 @@ describe("SecretInput invisible characters", () => {describe("SecretInput invisible characters warning icon", () => {it("shows the warning icon when the value contains invisible characters", () => {- assert.ok(render("KEY=\u00a0value").includes(WARNING_ICON));+ const markup = render("KEY=\u00a0value");+ assert.ok(markup.includes(WARNING_ICON));+ assert.ok(markup.includes(ICON_BUTTON));});it("shows the warning icon while the value is masked", () => {- assert.ok(render("KEY=\u200bvalue", false).includes(WARNING_ICON));+ const markup = render("KEY=\u200bvalue", false);+ assert.ok(markup.includes(WARNING_ICON));+ assert.ok(markup.includes(ICON_BUTTON));});it("does not show the warning icon for an ordinary value", () => {@@ -107,6 +130,46 @@ describe("SecretInput invisible characters warning icon", () => {});});+describe("SecretInput invisible characters tooltip", () => {+ it("lists each invisible character with its count, label, and code point", () => {+ const markup = render("\u00a0a\u00a0\u200b\u0001");+ assert.ok(markup.includes(TOOLTIP_INTRO));+ assert.deepEqual(tooltipItems(markup), [+ "2x Non-breaking space (U+00A0)",+ "1x Zero-width space (U+200B)",+ "1x Control character (U+0001)"+ ]);+ });++ it("uses the range label when a character has no specific name", () => {+ assert.deepEqual(tooltipItems(render("\u2003\u202e\u0085")), [+ "1x Unicode space (U+2003)",+ "1x Bidirectional control (U+202E)",+ "1x Control character (U+0085)"+ ]);+ });++ it("lists the same characters while the value is masked", () => {+ const markup = render("secret\u00a0value", false);+ assert.deepEqual(tooltipItems(markup), ["1x Non-breaking space (U+00A0)"]);+ assert.ok(!markup.includes("secret\u00a0value"));+ });++ it("renders no tooltip entries for an ordinary value, while loading, or after a load error", () => {+ assert.deepEqual(tooltipItems(render("KEY=value with spaces\ttab\n")), []);++ const props = { value: "KEY=\u00a0value", isVisible: true, readOnly: true };+ assert.deepEqual(+ tooltipItems(renderToStaticMarkup(<SecretInput {...props} isLoadingValue />)),+ []+ );+ assert.deepEqual(+ tooltipItems(renderToStaticMarkup(<SecretInput {...props} isErrorLoadingValue />)),+ []+ );+ });+});+describe("getInvisibleCharacterSummary", () => {it("returns nothing for ordinary text", () => {assert.deepEqual(getInvisibleCharacterSummary("plain value\twith\ttabs\n"), []);diff --git a/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx b/frontend/src/components/v3/platform/SecretInput/SecretInput.tsxindex fc9c1ec9f8..65ecd1b0bb 100644--- a/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx+++ b/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx@@ -5,6 +5,7 @@ import { TriangleAlertIcon } from "lucide-react";import { HIDDEN_SECRET_VALUE } from "@app/const/secrets";import { useToggle } from "@app/hooks";+import { IconButton } from "../../generic/IconButton";import { Tooltip, TooltipContent, TooltipTrigger } from "../../generic/Tooltip";import { cn } from "../../utils";import { getInvisibleCharacterSummary, INVISIBLE_CHAR_REGEX } from "./invisibleCharacters";@@ -229,12 +230,16 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>("no-scrollbar w-full overflow-auto bg-transparent text-foreground",variant === "default" &&"flex min-h-9 items-center rounded-md border border-border shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 data-[invalid=true]:border-danger data-[invalid=true]:ring-danger/40",+ variant === "plain" && invisibleChars.length > 0 && "flex",containerClassName)}style={{ maxHeight: `${21 * 7}px` }}><div- className={cn("relative w-full overflow-hidden", variant === "default" && "px-2.5 py-1")}+ className={cn(+ "relative w-full min-w-0 overflow-hidden",+ variant === "default" && "px-2.5 py-1"+ )}><divaria-hidden@@ -301,16 +306,18 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>({invisibleChars.length > 0 && (<Tooltip><TooltipTrigger asChild>- <button- type="button"+ <IconButtonaria-label="Value contains invisible characters"+ variant="ghost"+ size="xs"className={cn(- "sticky top-0 flex h-5 shrink-0 items-center self-start",+ "border-transparent bg-transparent text-warning hover:bg-transparent hover:text-warning data-[state=open]:bg-transparent",+ "sticky top-0 self-start",variant === "default" && "mt-1 mr-2.5")}>- <TriangleAlertIcon className="size-4 text-warning" />- </button>+ <TriangleAlertIcon />+ </IconButton></TooltipTrigger><TooltipContent className="max-w-72"><p>This value contains invisible characters that can break it when used:</p>