-
Notifications
You must be signed in to change notification settings - Fork 0
fix: clear AssistSupport security alerts #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| // @vitest-environment jsdom | ||
| import React from "react"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import { cleanup, render, screen, waitFor } from "@testing-library/react"; | ||
| import userEvent from "@testing-library/user-event"; | ||
| import { isAllowedYouTubeUrl, YouTubeIngest } from "./YouTubeIngest"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| ingestYoutube: vi.fn(), | ||
| ingesting: false, | ||
| })); | ||
|
|
||
| vi.mock("../../hooks/useIngest", () => ({ | ||
| useIngest: () => ({ | ||
| ingestYoutube: mocks.ingestYoutube, | ||
| ingesting: mocks.ingesting, | ||
| }), | ||
| })); | ||
|
|
||
| vi.mock("../shared/Button", () => ({ | ||
| Button: ({ | ||
| children, | ||
| onClick, | ||
| disabled, | ||
| }: { | ||
| children: React.ReactNode; | ||
| onClick?: () => void; | ||
| disabled?: boolean; | ||
| }) => ( | ||
| <button type="button" onClick={onClick} disabled={disabled}> | ||
| {children} | ||
| </button> | ||
| ), | ||
| })); | ||
|
|
||
| afterEach(() => { | ||
| cleanup(); | ||
| mocks.ingestYoutube.mockReset(); | ||
| mocks.ingesting = false; | ||
| }); | ||
|
|
||
| describe("isAllowedYouTubeUrl", () => { | ||
| it("accepts canonical YouTube hosts", () => { | ||
| expect( | ||
| isAllowedYouTubeUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ"), | ||
| ).toBe(true); | ||
| expect(isAllowedYouTubeUrl("https://youtube.com/watch?v=dQw4w9WgXcQ")).toBe( | ||
| true, | ||
| ); | ||
| expect(isAllowedYouTubeUrl("https://youtu.be/dQw4w9WgXcQ")).toBe(true); | ||
| }); | ||
|
|
||
| it("rejects lookalike hosts that only contain YouTube text", () => { | ||
| expect( | ||
| isAllowedYouTubeUrl( | ||
| "https://youtube.com.evil.example/watch?v=dQw4w9WgXcQ", | ||
| ), | ||
| ).toBe(false); | ||
| expect( | ||
| isAllowedYouTubeUrl("https://notyoutube.com/watch?v=dQw4w9WgXcQ"), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("rejects malformed or unsupported URLs", () => { | ||
| expect(isAllowedYouTubeUrl("youtube.com/watch?v=dQw4w9WgXcQ")).toBe(false); | ||
| expect( | ||
| isAllowedYouTubeUrl("ftp://www.youtube.com/watch?v=dQw4w9WgXcQ"), | ||
| ).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("YouTubeIngest", () => { | ||
| it("shows the install warning when yt-dlp is unavailable", () => { | ||
| render( | ||
| <YouTubeIngest | ||
| namespaceId="default" | ||
| ytdlpAvailable={false} | ||
| onSuccess={vi.fn()} | ||
| onError={vi.fn()} | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.getByText("yt-dlp Not Installed")).toBeTruthy(); | ||
| expect(screen.getByText("brew install yt-dlp")).toBeTruthy(); | ||
| expect(screen.queryByLabelText("YouTube URL")).toBeNull(); | ||
| }); | ||
|
|
||
| it("rejects invalid YouTube lookalike hosts before ingesting", async () => { | ||
| const user = userEvent.setup(); | ||
| const onError = vi.fn(); | ||
| render( | ||
| <YouTubeIngest | ||
| namespaceId="default" | ||
| ytdlpAvailable={true} | ||
| onSuccess={vi.fn()} | ||
| onError={onError} | ||
| />, | ||
| ); | ||
|
|
||
| await user.type( | ||
| screen.getByLabelText("YouTube URL"), | ||
| "https://youtube.com.evil.example/watch?v=dQw4w9WgXcQ", | ||
| ); | ||
| await user.click(screen.getByRole("button", { name: "Ingest Transcript" })); | ||
|
|
||
| expect(onError).toHaveBeenCalledWith("Please enter a valid YouTube URL"); | ||
| expect(mocks.ingestYoutube).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("ingests valid trimmed YouTube URLs and clears the field", async () => { | ||
| const user = userEvent.setup(); | ||
| const onSuccess = vi.fn(); | ||
| mocks.ingestYoutube.mockResolvedValue({ | ||
| title: "Demo video", | ||
| chunk_count: 2, | ||
| word_count: 120, | ||
| }); | ||
| render( | ||
| <YouTubeIngest | ||
| namespaceId="default" | ||
| ytdlpAvailable={true} | ||
| onSuccess={onSuccess} | ||
| onError={vi.fn()} | ||
| />, | ||
| ); | ||
|
|
||
| const input = screen.getByLabelText("YouTube URL") as HTMLInputElement; | ||
| await user.type(input, " https://youtu.be/dQw4w9WgXcQ "); | ||
| await user.click(screen.getByRole("button", { name: "Ingest Transcript" })); | ||
|
|
||
| await waitFor(() => { | ||
| expect(mocks.ingestYoutube).toHaveBeenCalledWith( | ||
| "https://youtu.be/dQw4w9WgXcQ", | ||
| "default", | ||
| ); | ||
| }); | ||
| expect(onSuccess).toHaveBeenCalledWith( | ||
| 'Ingested "Demo video" (2 chunks, 120 words)', | ||
| ); | ||
| expect(input.value).toBe(""); | ||
| }); | ||
|
|
||
| it("submits with Enter and shows the ingesting label", async () => { | ||
| const user = userEvent.setup(); | ||
| mocks.ingesting = true; | ||
| render( | ||
| <YouTubeIngest | ||
| namespaceId="default" | ||
| ytdlpAvailable={true} | ||
| onSuccess={vi.fn()} | ||
| onError={vi.fn()} | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.getByRole("button", { name: "Ingesting..." })).toBeTruthy(); | ||
| expect(screen.getByRole("button").hasAttribute("disabled")).toBe(true); | ||
|
|
||
| await user.keyboard("{Enter}"); | ||
| expect(mocks.ingestYoutube).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When passphrase-derived keys are generated, this now stores the Argon2 output in a heap
Vecand immediately consumes it withtry_into(). In every passphrase wrap/unwrap/export path, that drops the original heap allocation without zeroizing it, so the KEK can remain in freed heap memory even though the callers only zeroize the returned array and the surrounding docs say the derived key is zeroized after use. Please derive into a fixed[u8; KEY_LEN]as before or wrap the temporary buffer in a zeroizing type before converting it.Useful? React with 👍 / 👎.