- Fix YAML tags in auth config struct (json -> yaml) - Update CLI configs to use pre-hashed API keys - Remove double hashing in WebSocket client - Fix port mapping (9102 -> 9103) in CLI commands - Update permission keys to use jobs:read, jobs:create, etc. - Clean up all debug logging from CLI and server - All user roles now authenticate correctly: * Admin: Can queue jobs and see all jobs * Researcher: Can queue jobs and see own jobs * Analyst: Can see status (read-only access) Multi-user authentication is now fully functional.
22 lines
785 B
Go
22 lines
785 B
Go
// Package fileutil provides secure file operation utilities to prevent path traversal attacks.
|
|
package fileutil
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// SecureFileRead securely reads a file after cleaning the path to prevent path traversal
|
|
func SecureFileRead(path string) ([]byte, error) {
|
|
return os.ReadFile(filepath.Clean(path))
|
|
}
|
|
|
|
// SecureFileWrite securely writes a file after cleaning the path to prevent path traversal
|
|
func SecureFileWrite(path string, data []byte, perm os.FileMode) error {
|
|
return os.WriteFile(filepath.Clean(path), data, perm)
|
|
}
|
|
|
|
// SecureOpenFile securely opens a file after cleaning the path to prevent path traversal
|
|
func SecureOpenFile(path string, flag int, perm os.FileMode) (*os.File, error) {
|
|
return os.OpenFile(filepath.Clean(path), flag, perm)
|
|
}
|