Skip to content

Commit 04851f4

Browse files
ismoilovdevmlclaude
andcommitted
fix: Add CSRF protection and fix token masking issues
Security Improvements: - Add CSRF token validation for config POST requests - Add /api/csrf endpoint to generate CSRF tokens - Add unmask parameter to /api/config for internal API usage - Fix token masking in Settings UI while keeping API functional Bug Fixes: - Fix "Disconnected" status caused by masked token - Fix session token generation using crypto.randomBytes - Fix XSS vulnerability in LogViewer component - Fix path traversal in artifacts download - Fix rate limiting to fail-closed - Fix parseInt radix and NaN validation - Fix memory exhaustion with batch processing Testing: - Add Jest testing framework with 26 unit tests - Add auth.test.ts with password hashing tests - Add logger.test.ts with sanitization tests - All tests passing (100% pass rate) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 293eb72 commit 04851f4

File tree

16 files changed

+8083
-3574
lines changed

16 files changed

+8083
-3574
lines changed

jest.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const nextJest = require('next/jest')
2+
3+
const createJestConfig = nextJest({
4+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
5+
dir: './',
6+
})
7+
8+
// Add any custom config to be passed to Jest
9+
const customJestConfig = {
10+
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
11+
testEnvironment: 'jest-environment-jsdom',
12+
moduleNameMapper: {
13+
'^@/(.*)$': '<rootDir>/src/$1',
14+
},
15+
testMatch: [
16+
'**/__tests__/**/*.[jt]s?(x)',
17+
'**/?(*.)+(spec|test).[jt]s?(x)'
18+
],
19+
collectCoverageFrom: [
20+
'src/**/*.{js,jsx,ts,tsx}',
21+
'!src/**/*.d.ts',
22+
'!src/**/*.stories.{js,jsx,ts,tsx}',
23+
'!src/**/__tests__/**',
24+
],
25+
coverageThreshold: {
26+
global: {
27+
branches: 50,
28+
functions: 50,
29+
lines: 50,
30+
statements: 50,
31+
},
32+
},
33+
}
34+
35+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
36+
module.exports = createJestConfig(customJestConfig)

jest.setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Learn more: https://github.com/testing-library/jest-dom
2+
import '@testing-library/jest-dom'

0 commit comments

Comments
 (0)