/** * Utility functions for security field skipping */ /** * Check if a field should be skipped based on skip field patterns */ export function shouldSkipSecurityField(fieldName: string, skipFields: string[]): boolean { if (!skipFields || skipFields.length === 0) { return false; } const lowerFieldName = fieldName.toLowerCase(); return skipFields.some(skipField => lowerFieldName.includes(skipField.toLowerCase()) ); } /** * Check if a URL should be skipped based on skip URL patterns */ export function shouldSkipSecurityUrl(url: string, skipUrls: string[]): boolean { if (!skipUrls || skipUrls.length === 0) { return false; } // Check if the url matches any of the configured skip URL patterns return skipUrls.some(skipUrl => { // Exact match if (url === skipUrl) return true; // Path starts with skip URL (for sub-paths) if (url.startsWith(skipUrl + '/')) return true; // For paths ending with /, also check without the trailing slash if (skipUrl.endsWith('/') && url === skipUrl.slice(0, -1)) return true; // Support wildcard patterns (simple implementation) if (skipUrl.includes('*')) { const regex = new RegExp('^' + skipUrl.replace(/\*/g, '.*') + '$'); return regex.test(url); } return false; }); }