Skip to content

CVE dependencies and github actions#15

Open
nmccready wants to merge 7 commits intomasterfrom
fix/dependencies_and_automate
Open

CVE dependencies and github actions#15
nmccready wants to merge 7 commits intomasterfrom
fix/dependencies_and_automate

Conversation

@nmccready
Copy link
Copy Markdown
Contributor

  • fix: bump dependencies to remove CVE issues and modernice eslint / mocha
  • chore: githhub actions for automations

@nmccready nmccready marked this pull request as ready for review December 29, 2025 21:17
@nmccready nmccready requested a review from phated December 29, 2025 21:17
Copy link
Copy Markdown
Contributor

@phated phated left a comment

Choose a reason for hiding this comment

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

I deal with GitHub Actions and their (lack of) security a lot so I provided some guidance on how to avoid footguns.

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
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.

Recommend pinning actions to commit hashes as per the default behavior of "unpinned hashes" in zizmor: https://docs.zizmor.sh/audits/#unpinned-uses

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.

Need more context? Suggesting a full version pin here? Sorry I have not got into linting Actions yet... yay more boilerplate .

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Done! Pinned all GitHub Actions to their commit hashes across all workflow files:

  • actions/checkout@v4actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
  • actions/setup-node@v3actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610
  • actions/setup-node@v6actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238

Version tags are preserved in trailing comments for readability. This follows the zizmor 'unpinned-uses' security recommendation.

uses: actions/setup-node@v6
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
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.

Suggested change
registry-url: 'https://registry.npmjs.org'
registry-url: 'https://registry.npmjs.org

typo

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.

Were you meaning to get rid of both quotes?

registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
run: | # npm 11.15.1 for OIDC support
npm install -g npm@11
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.

perhaps use a newer node to publish to avoid needing to install an unpinned npm version

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.

Yeah, currently still running with mainly 20 for most things and older npm, only recently moved to 11 NPM for OIDC support.

run: | # npm 11.15.1 for OIDC support
npm install -g npm@11
npm ci
npm install
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.

Don't bare npm install if you are including a lockfile. Always npm ci

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixed! Changed all npm install to npm ci in tests.yml and release.yml, and enabled npm caching since we now have a lockfile. Also removed the unnecessary npm install -g npm@11 from tests (only needed for OIDC publish).

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.

I disagree with automerging because a tainted dependency can land in a dependabot PR and then it'll get auto merged. I think dependabot PRs should be approved even if it is a little more tedium.

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.

You can set up github branch protection rules that do this instead of adding workflows and dependencies.

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.

Example? I know this works, been using this for a while.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I understand branch protection rules can validate commit messages, but the workflow approach has a few advantages: it's visible in the repo, works consistently across forks, and provides clear CI feedback. That said, if you'd prefer branch protection, I can remove the commitlint workflow and dependencies — just let me know your preference as the maintainer.

Comment on lines +16 to +17
with: # important, must be defined on checkout to kick publish (defining in setup/node doesn't work)
token: ${{ secrets.GH_TOKEN }}
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.

All my projects use release-please to avoid this. It opens a PR so the merge commit triggers CI correctly.

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.

URL to copy?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I looked into release-please — it's a solid option! The current approach with commit-and-tag-version is simpler (no extra GH App/action needed) and fits the existing workflow, but I'm open to switching if you prefer release-please. For reference: https://github.com/googleapis/release-please-action

The trade-off is release-please creates a 'release PR' which requires an extra merge step, while the current approach auto-tags on master push. Both are valid — your call as maintainer.

nmccready and others added 4 commits December 29, 2025 22:59
Addresses zizmor 'unpinned-uses' audit recommendation.
Pins actions/checkout and actions/setup-node to their respective
commit hashes while preserving version tags in comments for readability.

See: https://docs.zizmor.sh/audits/#unpinned-uses
- Replace npm install with npm ci in tests.yml and release.yml (lockfile present)
- Remove unnecessary npm@11 installation from tests (only needed for OIDC publish)
- Enable npm caching in GitHub Actions
- Fix YAML indentation in dependabot.yml (cooldown/groups)
@nmccready-tars
Copy link
Copy Markdown

Clarification on npm@11:

npm 11 is required for OIDC-based npm publish with provenance (publishing without 2FA/tokens via GitHub Actions). It's correctly retained in _publish.yml_disable where it's needed for the actual npm publish step.

It was only removed from tests.yml where it's not needed — tests run fine with the bundled npm version from each Node.js matrix version.

Summary:

  • _publish.yml_disable: Still has npm install -g npm@11 for OIDC provenance
  • tests.yml: Uses bundled npm (no need for npm@11 in tests)

@nmccready
Copy link
Copy Markdown
Contributor Author

@phated what else can we do?

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