Update Apache SSL configuration and enhance security features across multiple files. Changed X-Frame-Options to SAMEORIGIN for better security, added optional Content Security Policy headers for testing, and improved password handling with HaveIBeenPwned checks during user registration and password reset. Implemented passkey login functionality in the authentication flow, including UI updates for user experience. Enhanced image upload processing with size limits and validation, and added rate limiting for various API endpoints to prevent abuse.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s
This commit is contained in:
35
server/utils/audit-log.js
Normal file
35
server/utils/audit-log.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
|
||||
// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
|
||||
const getDataPath = (filename) => {
|
||||
const cwd = process.cwd()
|
||||
if (cwd.endsWith('.output')) {
|
||||
// nosemgrep
|
||||
return path.join(cwd, '../server/data', filename)
|
||||
}
|
||||
// nosemgrep
|
||||
return path.join(cwd, 'server/data', filename)
|
||||
}
|
||||
|
||||
const AUDIT_LOG_FILE = getDataPath('audit.log.jsonl')
|
||||
|
||||
function safeStr(v, max = 500) {
|
||||
return String(v == null ? '' : v).slice(0, max)
|
||||
}
|
||||
|
||||
export async function writeAuditLog(eventType, data = {}) {
|
||||
const enabled = (process.env.AUDIT_LOG_ENABLED || 'true').toLowerCase() !== 'false'
|
||||
if (!enabled) return
|
||||
|
||||
const entry = {
|
||||
ts: new Date().toISOString(),
|
||||
type: safeStr(eventType, 100),
|
||||
data
|
||||
}
|
||||
|
||||
await fs.mkdir(path.dirname(AUDIT_LOG_FILE), { recursive: true })
|
||||
await fs.appendFile(AUDIT_LOG_FILE, JSON.stringify(entry) + '\n', 'utf-8')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user