Skip to content

Npm plugin loading#242

Open
kzhou314 wants to merge 9 commits into
mainfrom
npm-plugin-loading
Open

Npm plugin loading#242
kzhou314 wants to merge 9 commits into
mainfrom
npm-plugin-loading

Conversation

@kzhou314

Copy link
Copy Markdown
Contributor

Scanner-side fixes for https://github.com/github/accessibility/issues/10755.
Consumers request a first-party NPM plugin by passing an object in the scans input:

scans: |
  ["axe", {"name": "alt-text-scan", "package": "@github/accessibility-scanner-alt-text-plugin", "version": "1.0.0"}]

kzhou314 added 2 commits June 25, 2026 15:20
Accept object entries in the 'scans' input ({name, package, version}) and install/import them at runtime via npm install --ignore-scripts. Loading is gated to first-party allowlist. Includes unit tests.
GitHub Advanced Security started work on behalf of kzhou314 June 25, 2026 22:23 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 25, 2026 22:23
@kzhou314 kzhou314 marked this pull request as ready for review June 25, 2026 22:24
@kzhou314 kzhou314 requested a review from a team as a code owner June 25, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for installing and loading curated first-party accessibility scanner plugins from NPM, driven by object entries in the scans input (alongside existing built-in and local plugins). This addresses consumers who want to use a first-party plugin without vendoring plugin source into their repo.

Changes:

  • Extend scans input parsing to accept {name, package, version?} entries and forward requested NPM plugins into plugin loading.
  • Add an NPM plugin loader that installs packages at runtime and dynamically imports them.
  • Document the new NPM plugin mechanism and update the action input description; add unit tests for the NPM loader and NPM-plugin loading path.
Show a summary per file
File Description
PLUGINS.md Documents how to request and load first-party NPM-published plugins via scans.
.github/actions/find/action.yml Expands scans input description to include object-form entries for NPM plugins.
.github/actions/find/src/scansContextProvider.ts Parses scans entries into scan names + a list of requested NPM plugins.
.github/actions/find/src/pluginManager/types.ts Introduces NpmPluginRequest type for NPM plugin requests.
.github/actions/find/src/pluginManager/npmPluginLoader.ts Adds runtime npm install + dynamic import for NPM plugin modules.
.github/actions/find/src/pluginManager/index.ts Loads curated first-party NPM plugins after built-in and local plugins, with validation/precedence rules.
.github/actions/find/src/findForUrl.ts Passes parsed npmPlugins into plugin loading so NPM plugins can be installed/loaded for the scan run.
.github/actions/find/tests/npmPluginLoader.test.ts Adds unit tests for NPM install flags and NPM plugin loading/skip behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 8/8 changed files
  • Comments generated: 5

Comment thread .github/actions/find/src/scansContextProvider.ts
Comment thread .github/actions/find/src/pluginManager/npmPluginLoader.ts
Comment thread .github/actions/find/src/pluginManager/pluginNpmLoader.ts
Comment thread .github/actions/find/src/pluginManager/index.ts Outdated
Comment thread .github/actions/find/src/findForUrl.ts
GitHub Advanced Security started work on behalf of kzhou314 June 26, 2026 18:36 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 26, 2026 18:37
GitHub Advanced Security started work on behalf of kzhou314 June 26, 2026 19:11 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 26, 2026 19:12
GitHub Advanced Security started work on behalf of kzhou314 June 27, 2026 00:13 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 27, 2026 00:13
Comment thread .github/actions/find/src/pluginManager/pluginNpmLoader.ts
GitHub Advanced Security started work on behalf of kzhou314 June 29, 2026 17:39 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 29, 2026 17:40
}

// exported for mocking/testing. not for actual use
// export to be used for mocking/testing. not for actual use

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see these "not for actual" use comments are increasing in number; are they still accurate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was an existing convention I noticed, for functions that needed to be exported since it was used in testing files, but the export wouldn't actually be used anywhere in production. Technically its accurate but it can be misleading. Do we need the label here or should I clean it up?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically its accurate but it can be misleading.

Feel free to do this in a followup pull request, but yeah, I'm not sure these comments are particularly useful here since they're not programmatically enforced + nothing crazy should happen if, for some reason, you import and use one of these functions individually. But cc @abdulahmad307 in the event I'm missing something.

If we just want to separate out exports which solely exist for testing, maybe we could move these function definitions into a separate file imported both here and in tests? 🤷‍♀️

Comment thread .github/actions/find/src/pluginManager/index.ts Outdated
Comment thread PLUGINS.md Outdated
Comment thread .github/actions/find/src/scansContextProvider.ts Outdated
GitHub Advanced Security started work on behalf of kzhou314 June 29, 2026 18:25 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 29, 2026 18:26
GitHub Advanced Security started work on behalf of kzhou314 June 29, 2026 19:04 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 29, 2026 19:05
GitHub Advanced Security started work on behalf of kzhou314 June 29, 2026 21:16 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 29, 2026 21:17
@JoyceZhu

Copy link
Copy Markdown
Contributor

Should've thought of this earlier, but cc @abdulahmad307 if you also wanted to give this PR a review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants