Skip to content

chore(security): complete npm security hardening (follow-up to #360)#361

Merged
Alan-TheGentleman merged 2 commits into
mainfrom
chore/npm-security-hardening-followup
May 12, 2026
Merged

chore(security): complete npm security hardening (follow-up to #360)#361
Alan-TheGentleman merged 2 commits into
mainfrom
chore/npm-security-hardening-followup

Conversation

@Alan-TheGentleman
Copy link
Copy Markdown
Collaborator

@Alan-TheGentleman Alan-TheGentleman commented May 12, 2026

Closes #362

Summary

Follow-up to #360. Completes coverage of all non-N/A items in the Liran Tal npm-security-best-practices audit.

Stacked on: #360. Merge that one first, then GitHub will retarget this against main.

What's in this PR

Item Practice Where covered
#4 npq / Socket Firewall SECURITY.md + CONTRIBUTING.md policy
#5 Lockfile-lint plugin/obsidian/package.json preinstall + lockfile
#6 npm ci Lockfile committed, ready for CI
#10 Dev containers .devcontainer/devcontainer.json
#11 npm 2FA SECURITY.md maintainer policy
#15 Snyk consultation SECURITY.md + CONTRIBUTING.md policy
#16 files allowlist (defense in depth) plugin/obsidian/package.json

Full audit coverage after this PR

Status Count
PASS 15 / 17
N/A 2 / 17 (items #8 npx, #9 .env — neither used in repo)

Required follow-up (manual, by maintainer)

  • Enable auth-and-writes 2FA on the npm account that owns gentle-engram
  • Configure trusted publishing on npmjs.com per chore(security): harden npm supply chain #360's PR description
  • First contributor on the dev container should test cd plugin/obsidian && npm ci --ignore-scripts

Test plan

  • CI passes
  • cd plugin/obsidian && npx lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity succeeds locally
  • .devcontainer/devcontainer.json opens cleanly in VS Code (if anyone tests it)

Audit reference: https://github.com/lirantal/npm-security-best-practices/

Copilot AI review requested due to automatic review settings May 12, 2026 21:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Completes the remaining non-N/A items from the npm-security-best-practices audit (follow-up to #360) by adding maintainer/contributor policy documentation and tightening npm/package handling for the Obsidian plugin, plus a hardened devcontainer setup.

Changes:

  • Add maintainer npm security policies and dependency vetting guidance in SECURITY.md and CONTRIBUTING.md.
  • Add a files allowlist and lockfile-lint wiring (plus committed lockfile) for plugin/obsidian.
  • Introduce a security-hardened .devcontainer/devcontainer.json to standardize a safer dev environment.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
SECURITY.md Adds maintainer policies for npm account security and dependency vetting workflow.
CONTRIBUTING.md Documents npm dependency hygiene practices for contributors.
plugin/obsidian/package.json Adds files allowlist and a preinstall lockfile-lint check; adds lockfile-lint devDependency.
plugin/obsidian/package-lock.json Commits the lockfile to support reproducible installs and enable npm ci.
.devcontainer/devcontainer.json Adds a devcontainer definition with tightened container privileges and Go feature.
Files not reviewed (1)
  • plugin/obsidian/package-lock.json: Language not supported

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

"README.md"
],
"scripts": {
"preinstall": "npx lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
Comment on lines +9 to +10
"manifest.json",
"README.md"
Comment thread CONTRIBUTING.md
Comment on lines +169 to +173
- `ignore-scripts=true` — third-party lifecycle scripts do NOT run on install
- `allow-git=none` — git URLs as deps are rejected
- `min-release-age=3` — packages newer than 3 days old are rejected

If you have a legitimate reason to override these for local dev (e.g. `esbuild` postinstall), use a flag for that specific command — DO NOT edit `.npmrc`:
Comment on lines +7 to +9
"--cap-add=CHOWN",
"--cap-add=SETUID",
"--cap-add=SETGID"
@Alan-TheGentleman Alan-TheGentleman added the type:chore Maintenance/tooling label May 12, 2026
@Alan-TheGentleman Alan-TheGentleman changed the base branch from chore/npm-security-hardening to main May 12, 2026 21:40
Follow-up to #360 covering remaining best practices:
- Add files allowlist to engram-brain (defense in depth)
- Add lockfile + lockfile-lint preinstall for plugin/obsidian
- Add .devcontainer/ with hardened container runtime flags
- Document 2FA and OIDC publishing policy in SECURITY.md
- Document npq + Snyk vetting workflow for contributors

Audit reference: https://github.com/lirantal/npm-security-best-practices/
@Alan-TheGentleman Alan-TheGentleman force-pushed the chore/npm-security-hardening-followup branch from 4b0135d to a880745 Compare May 12, 2026 21:44
npm 10.x does not support OIDC trusted publishers — that was introduced
in 11.5.1. Node 24 ships with npm 11.x but the specific bundled version
can lag behind, so verify and upgrade defensively before publishing.

Avoids npm@latest (known to self-corrupt with promise-retry errors in CI)
by pinning to a specific version.

Refs #362
Copilot AI review requested due to automatic review settings May 12, 2026 21:48
@Alan-TheGentleman Alan-TheGentleman merged commit b9128ff into main May 12, 2026
7 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • plugin/obsidian/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

plugin/obsidian/package.json:14

  • Even when lifecycle scripts are enabled, running npx lockfile-lint in preinstall will fetch and execute lockfile-lint from the registry before any dependencies are installed/pinned by the lockfile. That undermines the goal of lockfile-based supply-chain hardening. Prefer a check that uses a pinned tool version (e.g. a dedicated CI step or an npm script that runs after npm ci using the locally installed lockfile-lint).
  "scripts": {
    "preinstall": "npx lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
    "build": "node esbuild.config.mjs",

"README.md"
],
"scripts": {
"preinstall": "npx lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
Comment on lines +9 to +10
"manifest.json",
"README.md"
"version": "1.25"
}
},
"postCreateCommand": "echo 'Run: cd plugin/obsidian && npm ci --ignore-scripts'"
Comment thread CONTRIBUTING.md
If you have a legitimate reason to override these for local dev (e.g. `esbuild` postinstall), use a flag for that specific command — DO NOT edit `.npmrc`:

```bash
npm install --ignore-scripts=false esbuild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:chore Maintenance/tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(security): harden npm supply chain per Liran Tal best practices

2 participants