-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(plugins): updatePlugins.sh actually updates installed plugins (closes #6670) #7644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JohnMcLear
wants to merge
2
commits into
develop
Choose a base branch
from
fix/issue-6670-update-plugins
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+140
−11
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| 'use strict'; | ||
|
|
||
| import {strict as assert} from 'assert'; | ||
| import {filterUpdatablePluginNames} from '../../../../bin/commonPlugins'; | ||
|
|
||
| // Regression test for #6670: the bug fix in `pnpm run plugins update` reads | ||
| // var/installed_plugins.json and re-invokes the installer per entry. The | ||
| // filter that picks safe-to-install names lives in bin/commonPlugins so that | ||
| // it is testable in isolation — the script itself has top-level side | ||
| // effects. If the filter ever regresses (skipping ep_ validation, allowing | ||
| // ep_etherpad-lite back in, dropping de-dup, choking on bad shapes) these | ||
| // assertions fail before the broken behaviour can ship. | ||
| describe(__filename, function () { | ||
| it('keeps every ep_-prefixed plugin name verbatim', function () { | ||
| const out = filterUpdatablePluginNames([ | ||
| {name: 'ep_align'}, | ||
| {name: 'ep_markdown'}, | ||
| {name: 'ep_headings2'}, | ||
| ]); | ||
| assert.deepEqual(out, ['ep_align', 'ep_markdown', 'ep_headings2']); | ||
| }); | ||
|
|
||
| it('drops ep_etherpad-lite because the core is vendored, not plugin-installed', function () { | ||
| const out = filterUpdatablePluginNames([ | ||
| {name: 'ep_etherpad-lite'}, | ||
| {name: 'ep_align'}, | ||
| ]); | ||
| assert.deepEqual(out, ['ep_align']); | ||
| }); | ||
|
|
||
| it('rejects names without the ep_ prefix so a corrupted manifest cannot install arbitrary packages', function () { | ||
| const out = filterUpdatablePluginNames([ | ||
| {name: 'ep_align'}, | ||
| {name: 'malicious-package'}, | ||
| {name: 'lodash'}, | ||
| {name: '../../../etc/passwd'}, | ||
| ]); | ||
| assert.deepEqual(out, ['ep_align']); | ||
| }); | ||
|
|
||
| it('de-duplicates repeated names so each plugin is installed at most once', function () { | ||
| const out = filterUpdatablePluginNames([ | ||
| {name: 'ep_align'}, | ||
| {name: 'ep_align'}, | ||
| {name: 'ep_markdown'}, | ||
| {name: 'ep_align'}, | ||
| ]); | ||
| assert.deepEqual(out, ['ep_align', 'ep_markdown']); | ||
| }); | ||
|
|
||
| it('tolerates missing, null, or non-string name fields', function () { | ||
| const out = filterUpdatablePluginNames([ | ||
| {name: 'ep_align'}, | ||
| {}, | ||
| null, | ||
| undefined, | ||
| {name: null as unknown as string}, | ||
| {name: 42 as unknown as string}, | ||
| {name: 'ep_markdown'}, | ||
| ]); | ||
| assert.deepEqual(out, ['ep_align', 'ep_markdown']); | ||
| }); | ||
|
|
||
| it('returns an empty array for an empty manifest', function () { | ||
| assert.deepEqual(filterUpdatablePluginNames([]), []); | ||
| }); | ||
|
|
||
| it('honours a custom prefix when one is supplied (defends against hard-coding)', function () { | ||
| const out = filterUpdatablePluginNames( | ||
| [{name: 'foo_one'}, {name: 'ep_align'}, {name: 'foo_two'}], | ||
| 'foo_', | ||
| ); | ||
| assert.deepEqual(out, ['foo_one', 'foo_two']); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. update() lacks regression test
📘 Rule violation☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation toolsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 750430a: added
src/tests/backend/specs/filterUpdatablePluginNames.tscovering the seven cases that would distinguish the fixed behaviour from the prior broken one — keep prefixed names, dropep_etherpad-lite, reject non-prefixed entries (the security gate), de-duplicate repeats, tolerate missing/null/non-stringnamefields, empty input, and honour a custom prefix. The script-level entry point still has top-level side effects so the helper is what's exported and tested; if the filter ever regresses (drops theep_gate, letsep_etherpad-liteback in, etc.) the existingBackend testsworkflow will fail before the broken behaviour can ship.