Skip to content

Modernize browser extensions with prebuilt packages and shared popup - #624

Merged
eoftedal merged 21 commits into
RetireJS:masterfrom
PekSec:codex/browser-extensions
Nov 14, 2026
Merged

eoftedal merged 21 commits into
RetireJS:masterfrom
PekSec:codex/browser-extensions

Conversation

@PekSec

@PekSec PekSec commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Browser scans could lose or mix results across navigation and background restarts. This PR shares a runtime and popup across Chrome, Chrome without function scanning, and a modern Firefox WebExtension, with stale-result rejection, detector refresh with cached fallback, and regression coverage.

Scan results are kept only in background memory, per top-level navigation: they reset when the page navigates, when the tab closes, or when the background restarts. No scan state is stored. Only settings and repository updates use storage.local.

Popup

The popup is the existing toolbar window (600×600); nothing is injected into the page. It follows the system light or dark appearance and shows the retire.js icon, which turns gray while scanning is disabled, like the toolbar icon.

  • It opens on a summary of the page: advisory counts for every severity, a search field, and libraries grouped into vulnerable, no known findings, scanning, and other scripts. Each row shows nonzero counts per severity. Unidentified scripts and failed scans are listed by file name.
  • Selecting a library opens its details: the script URL with Copy URL, how it was detected, and each advisory with its affected range and references.
  • Scanning, Deep scan, Show unidentified scripts, and Export JSON are in an options sheet. Counts and exports remain unfiltered.
  • Refresh discards the tab's results and scans the scripts seen since the last navigation again, without a page reload (for example after toggling Deep scan). After a background restart, reloading the page is still required.

Text and controls meet WCAG AA contrast in both themes. Advisory text is rendered as text, and links are limited to HTTP(S).

Ready to load without Node

Complete prebuilt packages are committed in chrome/extension, chrome/extension-no-func, and dist/firefox. Download and extract the repository ZIP, then load the appropriate package. Node is needed only for development. Firefox uses temporary add-on installation, which lasts until browser exit.

The Chrome packages retain their original paths so existing installations loaded directly from the repository continue to work after git pull. Shared extension sources and build files live under chrome/build.

The development instructions recommend Node 24 LTS. Portable build/test scripts support Windows and Linux, and CI covers Node 24 and 26, including a rebuild check for committed packages. The added --no-audit/--no-fund flags are removed. Generated files are marked as such for review.

The prebuilt service workers bundle repository/jsrepository-v6-combined.json, so the packages must be rebuilt after merging repository updates from master.

Actual popup screenshots

Captured on November 3, 2026 in Chrome 156 with the real toolbar popup, on a local example page that loads real builds of AngularJS 1.5.0, Chart.js 2.6.0 (which bundles moment.js 2.18.1), Highcharts 4.2.4, jQuery Validation 1.15.1, ECharts 6.0.0, and Bootstrap 5.0.0. These are version matches, not exploit confirmations. Firefox shares the UI. Every popup screen, in light and dark, is in docs/images/popup.

Chrome window with the retire.js popup, light

Chrome window with the retire.js popup, dark

Validation and compatibility

  • 102 Node tests and 26 extension tests pass; TypeScript checking and ESLint pass.
  • CI passes on Windows and Linux with Node 24 and 26, along with the separate detection job and the prebuilt check that rebuilds the packages and compares them with the committed files.
  • Native browser smoke checks pass in Chrome 156 (with and without function detection) and Firefox 159 on Linux: real detection, the 600×600 popup, the details view, search with unfiltered counts, copy/fallback, full JSON download, settings, restricted pages, and function-only detection in the sandbox variant. They use the default Windows install paths unless CHROME_PATH/FIREFOX_PATH is set.
  • Minimum versions: Chrome 116 and Firefox 140. Firefox and Chrome no-func use static/AST detection; only the full Chrome variant executes downloaded scripts in its isolated sandbox.

This is the extension-only replacement for #622. The branch is synced with upstream master (970fc88), including the merged CLI and CycloneDX fixes. No browser-store publishing is included. The toolbar icons in the popup are Font Awesome Free (CC BY 4.0), with the attribution kept in the markup. AI-assisted implementation.

Related merged replacements: CLI fixes #623 and CycloneDX #625. Completing this also covers #428 (upstreaming the third-party plugin).

🤖 Generated with Claude Code

@eoftedal

Copy link
Copy Markdown
Member

How is this new popup show? Is it overlaid to the page itself?

matrix:
node-version: [26.x]
os: [ubuntu-latest, windows-latest]
node-version: [24.x, 26.x]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test runs on a single version of node as test-detection is a heavy test that downloads a lot of files to test the repo. This test does not need to be run across multiple OSes and node versions. There will need to be a split

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.

Moved test-detection.js and its cache into a separate ubuntu-latest / Node 24 job. The other checks remain in the OS/Node matrix.

@eoftedal

eoftedal commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

The previous version of the prebuilt chrome extensions also bundle the repository, allowing it to be used with a slightly stale version of the repository even if it cannot download a new version. Use case is copying it in to a network without internet access or where access to github is blocked.

@PekSec
PekSec force-pushed the codex/browser-extensions branch from 42be9e8 to c790318 Compare September 30, 2026 13:04
@PekSec

PekSec commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

By "popup", I mean the existing extension window that opens when you click retire.js in the browser's top-right toolbar or Extensions menu. This PR redesigns that window; it does not inject anything into the web page.

The screenshot below shows the whole Chrome window, including the toolbar button and its native popup, on a local test page. GitHub access was blocked to verify detection using the bundled repository on a fresh profile.

Full Chrome window with the native retire.js toolbar popup

All three prebuilt packages already bundle the advisory repository. I added a regression test for first-launch detection without a cached repository or a successful update, and documented the fallback. Chrome, Chrome no-func, and Firefox browser checks passed.

All six PR commits now have verified signatures. Validation: 62 Node tests, 17 extension tests, all 48 detection packages, build, typecheck, and ESLint passed.

@PekSec
PekSec requested a review from eoftedal October 2, 2026 10:35
@eoftedal

eoftedal commented Oct 2, 2026

Copy link
Copy Markdown
Member

Where are the prebuilt extension packages?

@eoftedal eoftedal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is getting close, but till some adjustments needed

Comment thread .gitattributes Resolved
Comment thread build_chrome.sh Resolved
Comment thread build_chrome.sh Resolved
Comment thread chrome/build/extension/js/runtime.js Resolved
Comment thread chrome/build/extension/js/runtime.js Resolved
@PekSec

PekSec commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Moved the prebuilt-package check to a separate job using the PR head commit, so newer advisory data from master does not cause a false mismatch. The existing test matrix still runs against the merge result. No application code changed.

@PekSec
PekSec requested a review from eoftedal October 6, 2026 06:09
@eoftedal

eoftedal commented Oct 8, 2026

Copy link
Copy Markdown
Member

It would be preferable if the chrome finished chrome extensions stayed in their original locations rather than in a generic dist folder. People are often using the repository directly, and a git pull would break this as the location is swapped. I would rather we move the build files into a separate folder (chrome/build).

@PekSec

PekSec commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Kept the Chrome extensions at their original paths, moved the sources into chrome/build, and synced with upstream master.

@eoftedal

Copy link
Copy Markdown
Member

Comments on the popup:
image

Version number is misaligned vertically (see green line).

The numbers are context-less. Is "6 vulnerabilities" 6 high? 2 medium? 0 low? The header line must say how many of each.
How many mediums are on jQuery? The "medium" label should include a number.
The deep scan label on the right is not needed. There is already a checkbox above stating if deep scan is enabled.

@eoftedal

Copy link
Copy Markdown
Member

Also I want to drop the storage. It introduces complexity. You can simply reload the page to scan again. It is cheap. This appears to introduce "per tab" storage of vulnerabilities, while the intention is per top level navigation.

@eoftedal

Copy link
Copy Markdown
Member

Once this is done we can also close #428

@PekSec

PekSec commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Updated table alignment, header severity counts and per-library count pills; removed the redundant scan-mode label and persisted scan state. The refreshed dark palette keeps the teal accent and separates severity colors; only numbers are colored in the header.

All three packages rebuilt; extension tests and Chrome/Firefox checks passed. Commit 5eb241c has a verified signature.

Full Chrome window with the native toolbar popup; nothing is injected into the page. Detection here uses bundled data with repository network access blocked.

Updated retire.js colors in the native Chrome toolbar popup

@PekSec

PekSec commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@eoftedal Can you review if you have free time and let me know if any changes needed?

@eoftedal

Copy link
Copy Markdown
Member

Also I want to drop the storage. It introduces complexity. You can simply reload the page to scan again. It is cheap. This appears to introduce "per tab" storage of vulnerabilities, while the intention is per top level navigation.

This is still open

@PekSec

PekSec commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

47560d5 removed persisted scan results and pending requests; results now reset on top-level navigation and worker restart. Is your remaining concern the in-memory tab state, or the local storage for settings and repository updates?

@PekSec

PekSec commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

47560d5 removed persisted scan results and pending requests; results now reset on top-level navigation and worker restart. Is your remaining concern the in-memory tab state, or the local storage for settings and repository updates?

@eoftedal checking in to see if you have any updates or would like any further changes.

PekSec and others added 2 commits October 30, 2026 21:18
Refresh discards the current tab's results and rescans the scripts seen
since the last top-level navigation, using the current settings. Results
stay in memory only; a reload is still needed after a background restart.

Renew the popup screenshots for the current UI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PekSec

PekSec commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@eoftedal a few updates:

  • Merged the latest master (advisory data only) and rebuilt the three prebuilt packages so they bundle the current repository.
  • Added a Refresh button to the controls row. It discards the current tab's results and rescans the scripts seen since the last top-level navigation, without reloading the page (useful after toggling Deep scan, for example). Nothing is stored: results are still kept only in memory and reset on navigation, and after a background restart a reload is still needed. If you'd rather keep "reload to rescan" only, I'll drop it.
  • Renewed the popup screenshots:

Resource overview

Advisory details

PekSec and others added 3 commits October 30, 2026 21:57
The Chrome check read the popup's severity summary as soon as the
background reported results, before the popup (which polls once per
second) had rendered them, so the later unfiltered-count comparison
failed with all-zero counts. Read it after the popup shows its rows.

Firefox 159 requires MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1 in addition to
--remote-allow-system-access before chrome-context Marionette calls.

CHROME_PATH and FIREFOX_PATH override the default Windows install
locations so the checks also run on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new docs/images/popup folder has each popup screen in light and dark,
captured from the real extension scanning real library builds, plus the
whole Chrome window with the toolbar popup open. The old single-theme
screenshots of the previous popup are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The popup opens on a summary of the page: advisories by severity, search,
and libraries grouped into vulnerable, no known findings, scanning and
other scripts. Selecting a library slides in its details: URL with Copy
URL, how it was detected, and each advisory with its affected range and
references. Scanning, Deep scan, Show unidentified scripts and Export JSON
move to an options sheet. The header keeps per-severity counts and rows
keep numbered per-severity pills.

The popup follows the system light or dark appearance with a navy and
teal palette carried over from the previous popup, shows the retire.js
icon (gray while scanning is disabled), and meets WCAG AA contrast in both
themes. Unidentified and failed scripts are listed by file name, and rows
that share a name show their file. Advisory text is still rendered as
text, and links are still limited to HTTP(S).

The smoke checks open a library before Copy URL and the sheet before
Export, wait for an identified library rather than any row text, and
capture the detail view. The toolbar icons are Font Awesome Free (CC BY
4.0), with the attribution comment kept in the markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PekSec

PekSec commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@eoftedal I redesigned the popup. The runtime, storage, and packaging are unchanged:

  • It opens on a summary of the page, with libraries grouped by outcome. Selecting a library slides in its details, and Back returns to the list.
  • It follows the system light or dark appearance. The navy and teal palette carries over from the previous version, and the retire.js icon is in the header.
  • Your earlier popup points still hold: the header shows a count for every severity, and each row shows numbered pills (for example 5 M 1 L).
  • One change to note: Scanning, Deep scan, Show unidentified scripts, and Export JSON moved into an options sheet, so Deep scan's state is no longer visible on the main screen. I can show it in the header if you prefer.

Extension tests (26), Node tests (102), and the Chrome, Chrome no-func, and Firefox smoke checks pass, and all three packages are rebuilt. The PR description has the full browser window in light and dark; every screen is in docs/images/popup.

Library details, light:

Library details in light mode

Options, dark:

Options sheet in dark mode

PekSec and others added 2 commits November 3, 2026 21:36
Results live only in background memory, so a tab loaded before the
worker started (extension reload or install, or the browser stopping the
idle worker after about 30s) showed nothing until the page was reloaded.

When a tab is activated, the popup opens on it, or it is the active tab
when the worker starts, and the runtime did not watch it load from its
top-level navigation, it now waits 3 seconds for late scripts, then
reads the scripts the page actually loaded (performance resource
entries, all frames) and scans them through the existing path. URLs
already seen through webRequest are merged in. Refresh uses the same
path, so it also recovers scripts loaded before the worker started, and
it keeps requests that are still downloading.

This needs the scripting permission, which an earlier change ruled out
for Refresh. It is justified now because scanning open tabs without a
reload needs it. <all_urls> is already granted, so it adds no new
install warning. Results still stay in memory only. Only resources the
browser fetched are used, not <script src> values, so a page cannot
make the extension request URLs it never loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rotate-left icon points anticlockwise but reused the clockwise
spinner keyframes. Reverse the animation for the icon only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PekSec

PekSec commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Two new commits:

00e8ee7 Scan already-open tabs on tab switch without a reload

Results still live only in background memory. Before this, a tab loaded before the worker started (extension reload or install, or the browser stopping the idle worker after about 30s) showed nothing until you reloaded it.

  • When it scans: a tab gets scanned if the runtime didn't watch it load from navigation and one of these happens: you switch to it, the popup opens on it, or it's the active tab when the worker starts. The runtime waits 3 seconds for late scripts, then reads the scripts the page actually loaded (resource timing entries with initiatorType: "script", all frames). Those go through the existing scan path, merged with what webRequest already saw.
  • Refresh: it uses the same path, so it also recovers scripts loaded before the worker started. Requests still downloading now carry over to the new results instead of being dropped.
  • New permission: this needs scripting. <all_urls> is already granted, so the install prompt gets no new warning. Nothing is written to storage.
  • Safety: it only uses resources the browser fetched, never <script src> values. A page can't get the extension to request URLs it never loaded, including ones blocked by CSP, a content blocker or local network access rules.
  • Tests and docs: new tests cover tab activation, the active tab at worker start, partial tabs, navigation during the wait, pages that refuse injection, and Refresh keeping downloads in progress. Both READMEs and the zero-result Refresh message are updated.

a79db61 Spin the Refresh icon anticlockwise to match its arrow

The prebuilt packages are rebuilt in both commits, and the extension tests pass (32).

@eoftedal

eoftedal commented Nov 9, 2026

Copy link
Copy Markdown
Member

Sorry this is taking so long, but massive PRs are hard to review, especially then things are changed.

The original idea here was to capture requests are they were loaded and scan as they were loaded. Some pages may load scripts later (e.g. Vue's dynamic loading). I'm not sure why waiting 3 seconds is needed, if it responds to scripts being loaded, rather than query something after the fact.

I spend some time on reviewing this soon, but the last weeks have been super busy, and I have not really had time to review all the new work. Smaller PRs are easier to review, so maybe limit changes to what is required from review, so we can get the first version merged.

Thanks for doing this, btw

Comment thread .github/workflows/test.yml Outdated
- run: node validate
working-directory: repository

prebuilt:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should not run on repository only updates, as the extension will normally auto-update the repository on first load.

@eoftedal

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request. Merges in this file should not be solved individually. Pull in the latest changes from main, and run the generation script to generate a new version of the conflicting file.

eoftedal and others added 2 commits November 14, 2026 10:37
Resolve README conflict, bump the Chrome source manifests to 6.1.1 to
match master, and regenerate the prebuilt extension packages.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@eoftedal
eoftedal merged commit 35dca7b into RetireJS:master Nov 14, 2026
9 checks passed
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.

2 participants