Security: prevent unauthorized plugin modifications

This commit is contained in:
2026-04-17 02:53:03 +10:00
parent 82ae0a05b0
commit 9c34554bad

View File

@@ -171,6 +171,29 @@ for (const file of changedFiles) {
const content = await readFile(file, 'utf-8');
const plugin = JSON.parse(content);
// Check if this plugin already exists on main
let isModification = false;
let originalAuthor = null;
try {
const originalContent = await readFile(`../base/${file}`, 'utf-8');
const originalPlugin = JSON.parse(originalContent);
isModification = true;
originalAuthor = originalPlugin.author;
} catch {
// File doesn't exist on main, this is a new plugin
isModification = false;
}
// If modifying existing plugin, MUST match original author
if (isModification) {
if (originalAuthor !== prAuthor) {
errors.push(`${file}: Cannot modify plugin owned by "${originalAuthor}" (you are "${prAuthor}")`);
continue;
}
console.log(` Modifying existing plugin by ${originalAuthor}`);
}
// Check required fields
for (const field of REQUIRED_FIELDS) {
if (!plugin[field]) {
@@ -188,7 +211,7 @@ for (const file of changedFiles) {
errors.push(`${file}: Invalid version format: ${plugin.version}`);
}
// Check author matches PR creator (for new files)
// Check author matches PR creator
if (plugin.author !== prAuthor) {
errors.push(`${file}: Author "${plugin.author}" must match PR creator "${prAuthor}"`);
}