UNPKG

supamend

Version:

Pluggable DevSecOps Security Scanner with 10+ scanners and multiple reporting channels

120 lines 5.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RecoverySuggestions = exports.ErrorCodes = exports.ValidationError = exports.PluginError = exports.ConfigurationError = exports.GitError = exports.ReporterError = exports.ScannerError = exports.SupaMendError = void 0; class SupaMendError extends Error { constructor(message, code, options = {}) { super(message); this.name = 'SupaMendError'; this.code = code; if (options.context !== undefined) { this.context = options.context; } this.recoverable = options.recoverable ?? false; this.retryable = options.retryable ?? false; if (options.cause !== undefined) { this.cause = options.cause; } } } exports.SupaMendError = SupaMendError; class ScannerError extends SupaMendError { constructor(message, scannerName, options = {}) { super(message, 'SCANNER_ERROR', { ...options, context: { ...options.context, scanner: scannerName } }); this.name = 'ScannerError'; } } exports.ScannerError = ScannerError; class ReporterError extends SupaMendError { constructor(message, reporterName, options = {}) { super(message, 'REPORTER_ERROR', { ...options, context: { ...options.context, reporter: reporterName } }); this.name = 'ReporterError'; } } exports.ReporterError = ReporterError; class GitError extends SupaMendError { constructor(message, operation, options = {}) { super(message, 'GIT_ERROR', { ...options, context: { ...options.context, operation } }); this.name = 'GitError'; } } exports.GitError = GitError; class ConfigurationError extends SupaMendError { constructor(message, file, options = {}) { super(message, 'CONFIGURATION_ERROR', { ...options, ...(file && { context: { ...options.context, file } }) }); this.name = 'ConfigurationError'; } } exports.ConfigurationError = ConfigurationError; class PluginError extends SupaMendError { constructor(message, pluginName, options = {}) { super(message, 'PLUGIN_ERROR', { ...options, context: { ...options.context, plugin: pluginName } }); this.name = 'PluginError'; } } exports.PluginError = PluginError; class ValidationError extends SupaMendError { constructor(message, field, options = {}) { super(message, 'VALIDATION_ERROR', { ...options, context: { ...options.context, field } }); this.name = 'ValidationError'; } } exports.ValidationError = ValidationError; // Error codes for better error handling exports.ErrorCodes = { SCANNER_NOT_FOUND: 'SCANNER_NOT_FOUND', SCANNER_NOT_AVAILABLE: 'SCANNER_NOT_AVAILABLE', SCANNER_EXECUTION_FAILED: 'SCANNER_EXECUTION_FAILED', REPORTER_NOT_FOUND: 'REPORTER_NOT_FOUND', REPORTER_NOT_AVAILABLE: 'REPORTER_NOT_AVAILABLE', REPORTER_EXECUTION_FAILED: 'REPORTER_EXECUTION_FAILED', GIT_CLONE_FAILED: 'GIT_CLONE_FAILED', GIT_CLEANUP_FAILED: 'GIT_CLEANUP_FAILED', CONFIG_LOAD_FAILED: 'CONFIG_LOAD_FAILED', CONFIG_INVALID: 'CONFIG_INVALID', PLUGIN_LOAD_FAILED: 'PLUGIN_LOAD_FAILED', PLUGIN_INIT_FAILED: 'PLUGIN_INIT_FAILED', VALIDATION_FAILED: 'VALIDATION_FAILED', NETWORK_ERROR: 'NETWORK_ERROR', PERMISSION_ERROR: 'PERMISSION_ERROR', TIMEOUT_ERROR: 'TIMEOUT_ERROR', UNKNOWN_ERROR: 'UNKNOWN_ERROR' }; // Error recovery suggestions exports.RecoverySuggestions = { [exports.ErrorCodes.SCANNER_NOT_FOUND]: 'Check if the scanner is properly installed and available in PATH', [exports.ErrorCodes.SCANNER_NOT_AVAILABLE]: 'Install the required scanner or check its configuration', [exports.ErrorCodes.SCANNER_EXECUTION_FAILED]: 'Check scanner configuration and try again', [exports.ErrorCodes.REPORTER_NOT_FOUND]: 'Check if the reporter is properly installed', [exports.ErrorCodes.REPORTER_NOT_AVAILABLE]: 'Check reporter configuration and ensure all required dependencies are installed', [exports.ErrorCodes.REPORTER_EXECUTION_FAILED]: 'Check reporter configuration and try again', [exports.ErrorCodes.GIT_CLONE_FAILED]: 'Check repository URL and access permissions', [exports.ErrorCodes.GIT_CLEANUP_FAILED]: 'Manually clean up temporary files if needed', [exports.ErrorCodes.CONFIG_LOAD_FAILED]: 'Check configuration file path and format', [exports.ErrorCodes.CONFIG_INVALID]: 'Validate configuration file syntax', [exports.ErrorCodes.PLUGIN_LOAD_FAILED]: 'Check plugin installation and dependencies', [exports.ErrorCodes.PLUGIN_INIT_FAILED]: 'Check plugin configuration and try again', [exports.ErrorCodes.VALIDATION_FAILED]: 'Check input parameters and try again', [exports.ErrorCodes.NETWORK_ERROR]: 'Check network connectivity and try again', [exports.ErrorCodes.PERMISSION_ERROR]: 'Check file permissions and try again', [exports.ErrorCodes.TIMEOUT_ERROR]: 'Increase timeout settings or try again', [exports.ErrorCodes.UNKNOWN_ERROR]: 'Check logs for more details and try again' }; //# sourceMappingURL=errors.js.map