Files
yoshiko-pg__difit/vitest.setup.ts
T
yoshiko d590ab2c7a Add image diff display support (#30)
* feat: Add image diff display support for inline and side-by-side layouts

- Add image file detection utility in imageUtils.ts
- Implement ImageDiffChunk component with before/after image display
- Support both inline (vertical) and side-by-side (horizontal) layouts
- Add /api/blob/* endpoint for serving image files from git refs
- Update GitDiffParser to handle binary files and serve blob content
- Integrate image diff display in DiffViewer component
- Handle deleted, added, and modified image files appropriately

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* 画像の表示

* added/deleted対応

* 背景透過対応

* サイズの表記を追加

* 表示位置修正

* ファイルサイズ上限設定10MB

* staged/.対応

* create tests

* Fix command injection vulnerability in getBlobContent

依頼されたプロンプト内容:
execやexecSyncなど任意コード実行のところで、自由な入力を実行しているなど危険な実装がないかレビューしてほしい

実行したTODOリスト:
1. getBlobContent関数のセキュリティ問題を修正
2. 修正後のテストを実行
3. lint/typecheckを実行

Changes:
- Replace execSync with execFileSync to prevent command injection
- Update tests to use execFileSync mock instead of execSync
- Remove unused mockExecSync variable

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update SECURITY_ANALYSIS.md to reflect execFileSync fix

- Mark command injection vulnerability as FIXED
- Update code examples to show execFileSync usage
- Update risk assessment from MEDIUM to LOW
- Document completed security improvements

* update document name

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-07 00:19:29 +09:00

36 lines
1017 B
TypeScript

import '@testing-library/jest-dom';
import { vi } from 'vitest';
import { Agent, setGlobalDispatcher } from 'undici';
// Disable keep-alive for tests to prevent ECONNRESET errors
// Use pipelining=0 instead of keepAlive=false for this version of undici
setGlobalDispatcher(new Agent({ pipelining: 0 }));
// Mock fetch globally for component tests, but not for server integration tests
if (!process.env.VITEST_SERVER_TEST) {
global.fetch = vi.fn();
}
// Mock console.error to suppress error logs during tests
global.console.error = vi.fn();
// Mock window.getComputedStyle
Object.defineProperty(window, 'getComputedStyle', {
value: () => ({
getPropertyValue: () => '',
}),
});
// Global test utilities
export const mockFetch = (response: any) => {
(global.fetch as any).mockResolvedValue({
ok: true,
json: async () => response,
blob: async () => ({ size: 1024 }),
});
};
export const mockFetchError = (error: string) => {
(global.fetch as any).mockRejectedValue(new Error(error));
};