mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:40:44 +00:00
feat(plugins): move Bonjour discovery into bundled plugin
* fix(deps): detect constant dynamic imports in ownership audit * feat(plugins): move bonjour discovery into bundled plugin * test(plugins): remove moved bonjour core tests * fix(plugins): harden bonjour disable and console restore * fix(plugins): split gateway discovery ids from services * fix(plugins): harden bonjour advertiser shutdown * fix(plugins): clean up bonjour split lint
This commit is contained in:
@@ -17,6 +17,12 @@ const IMPORT_PATTERNS = [
|
||||
/\brequire\s*\(\s*["']([^"']+)["']\s*\)/g,
|
||||
/\b(?:require|[_$A-Za-z][\w$]*require[\w$]*)\.resolve\s*\(\s*["']([^"']+)["']\s*\)/gi,
|
||||
];
|
||||
const STRING_CONSTANT_PATTERN = /\b(?:const|let|var)\s+([_$A-Za-z][\w$]*)\s*=\s*["']([^"']+)["']/g;
|
||||
const DYNAMIC_CONSTANT_IMPORT_PATTERNS = [
|
||||
/\bimport\s*\(\s*([_$A-Za-z][\w$]*)\s*\)/g,
|
||||
/\brequire\s*\(\s*([_$A-Za-z][\w$]*)\s*\)/g,
|
||||
/\b(?:require|[_$A-Za-z][\w$]*require[\w$]*)\.resolve\s*\(\s*([_$A-Za-z][\w$]*)\s*\)/gi,
|
||||
];
|
||||
|
||||
function readJson(filePath) {
|
||||
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
@@ -73,6 +79,20 @@ export function collectModuleSpecifiers(source) {
|
||||
}
|
||||
}
|
||||
}
|
||||
const stringConstants = new Map();
|
||||
for (const match of source.matchAll(STRING_CONSTANT_PATTERN)) {
|
||||
if (match[1] && match[2]) {
|
||||
stringConstants.set(match[1], match[2]);
|
||||
}
|
||||
}
|
||||
for (const pattern of DYNAMIC_CONSTANT_IMPORT_PATTERNS) {
|
||||
for (const match of source.matchAll(pattern)) {
|
||||
const specifier = match[1] ? stringConstants.get(match[1]) : undefined;
|
||||
if (specifier) {
|
||||
specifiers.add(specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
return specifiers;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user