Adds output path validation for enhanced security
Enhances security by validating output paths and executable paths. This prevents path traversal attacks and command injection vulnerabilities by ensuring that users can only specify valid relative paths within the vault and safe executable paths. It also displays notices when the path is deemed unsafe.
This commit is contained in:
3 files changed
+167
-5
No files matched your search
@@ -7,6 +7,7 @@ import { Setting, App } from 'obsidian';
|
||||
import { ModalSection, ModalState, ValidationResult } from '../modalTypes';
|
||||
import { ExportFormat } from '../../../core/settings';
|
||||
import { FolderSuggest } from '../../components/FolderSuggest';
|
||||
import { SecurityUtils } from '../../../core/SecurityUtils';
|
||||
|
||||
export class GeneralSection implements ModalSection {
|
||||
private container: HTMLElement | null = null;
|
||||
@@ -101,10 +102,8 @@ export class GeneralSection implements ModalSection {
|
||||
// Validate output folder
|
||||
if (this.outputFolderInput) {
|
||||
const value = this.outputFolderInput.value.trim();
|
||||
if (!value) {
|
||||
errors.push('Output folder is required');
|
||||
} else if (value.startsWith('/') || value.startsWith('\\')) {
|
||||
warnings.push('Output folder should be relative to vault root');
|
||||
if (!SecurityUtils.validateOutputPath(value)) {
|
||||
errors.push(SecurityUtils.getPathValidationError(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user