This commit is contained in:
sickle committed 2025-01-13 20:30:07 +08:00
1 parent 6b67692d42
commit bdf89aa0eb
3 files changed
+41 -3

No files matched your search

+19 -2
View File
@@ -20,9 +20,26 @@ const SCANNER_CONFIG = {
// API 相关配置
API: {
PATTERN: /['"](?:\/|\.\.\/|\.\/)[^\/\&\>\< \)\(\{\}\,\'\"\\]([^\>\< \)\(\{\}\,\'\"\\])*?[\'"]/g,
PATTERN: /['"`](?:\/|\.\.\/|\.\/)[^\/\>\< \)\(\}\,\'\"\\](?:[^\^\>\< \)\(\{\}\,\'\"\\])*?['"`]|['"`][a-zA_Z0-9]+(?<!text|application)\/(?:[^\^\>\< \)\(\{\}\,\'\"\\])*?["'`]/g,
// 静态文件后缀 - 增强匹配规则
STATIC_FILE_PATTERN: /\.(js|css|ico|png|webp|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|map|json|jsonp)(?:\?[^'"]*)?$/i
STATIC_FILE_PATTERN: /\.(js|css|ico|png|webp|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|map|json|jsonp)(?:\?[^'"]*)?$/i,
// 需要过滤的内容类型
FILTERED_CONTENT_TYPES: [
// 图片类型
'image/jpeg',
'image/gif',
'image/bmp',
'image/png',
'image/x-png',
'image/webp',
'image/svg+xml',
'image/x-emf',
'image/x-wmf',
'image/x-icon',
'image/tiff',
'multipart/form-data',
]
},
// 域名相关配置
+20
View File
@@ -9,9 +9,29 @@ const SCANNER_FILTER = {
// 检查是否是静态文件
if (SCANNER_CONFIG.API.STATIC_FILE_PATTERN.test(match)) {
resultsSet?.staticFiles?.add(match);
return true;
}
// 尝试获取文件扩展名或内容类型标识
let contentType = '';
try {
// 从URL中提取可能的内容类型标识
const lcMatch = match.toLowerCase();
contentType = SCANNER_CONFIG.API.FILTERED_CONTENT_TYPES.find(type =>
lcMatch.includes(type.toLowerCase()) ||
lcMatch.includes(type.split('/')[1]) // 匹配类型的后缀部分
) || '';
} catch (e) {
console.error('Error extracting content type:', e);
}
// 如果URL暗示这是一个被过滤的内容类型,将其添加到静态文件中
if (contentType) {
resultsSet?.staticFiles?.add(match);
} else {
resultsSet?.apis?.add(match);
}
return true;
};
})(),