NR-929: implementing the kainos npm security measurements - #205
sekhar-kainos merged 1 commit into
Conversation
679c900 to
d5f5e87
Compare
d5f5e87 to
00cae2e
Compare
| "build": "tsc", | ||
| "start": "node dist/index.js", | ||
| "start:local": "yarn tsc --watch & node --watch dist/index.js", | ||
| "start:local": "tsc --watch & node --watch dist/index.js", |
There was a problem hiding this comment.
Thinking these need npx to run them from Node's install of tsc
| "build": "tsc", | ||
| "start": "node dist/index.js", | ||
| "start:local": "yarn tsc -w & node --watch dist/index.js", | ||
| "start:local": "tsc -w & node --watch dist/index.js", |
| min-release-age=3 | ||
| engine-strict=true | ||
| allow-git=none | ||
| audit=true No newline at end of file |
There was a problem hiding this comment.
Align with our service's
Namely we can't have min-release-age and allow-git until we upgrade to Node v26
| - Use `npm install` only when intentionally changing dependencies, then review the `package-lock.json` diff. | ||
| - Run application builds explicitly with `npm run build` after dependencies are installed. | ||
| - Run `npm run security` for the full audit used by CI or `npm run security:production` to check production dependencies only. | ||
| - The `qs@6.16.0` override addresses current Express 4 advisories and crosses Express's declared `~6.15.1` range. Verify API tests before changing or removing it. |
There was a problem hiding this comment.
Few extra bullets in here that shouldn't be
Again, align with our service's
| RUN npm run build --workspace @notarialapi/worker | ||
| # reinstall only production deps | ||
| RUN yarn workspaces focus @notarialapi/worker --production | ||
| RUN npm prune --omit=dev --ignore-scripts=true |
There was a problem hiding this comment.
Shouldn't need --ignore-scripts here
We've already installed all packages without
Unless we do and we haven't done this correctly in our service?
| "@typescript-eslint/eslint-plugin": "^8.70.0", | ||
| "@typescript-eslint/parser": "^8.70.0", | ||
| "babel-jest": "^29.7.0", | ||
| "eslint": "^8.56.0", |
There was a problem hiding this comment.
Run npm outdated --min-release-age 5
Install safe package increases
Would recommend doing them in groups per commit so it's easy to revert any given
I.e.
eslint 8.57.1 8.57.1 10.10.0 node_modules/eslint api@npm:@notarialapi/api@1.0.0
eslint 8.57.1 8.57.1 10.10.0 node_modules/eslint notarial-api
eslint-config-prettier 9.1.2 9.1.2 10.1.8 node_modules/eslint-config-prettier api@npm:@notarialapi/api@1.0.0
eslint-config-prettier 9.1.2 9.1.2 10.1.8 node_modules/eslint-config-prettier notarial-api
Would do these ESLints together across all that have it
There was a problem hiding this comment.
Also, I'm 99% there shouldn't be any pkgs in this root folder with exception of eslint and prettier
But I think these are just leftovers from moving them into workspaces
One to follow up with Simon and co to see what we can tidy up
| }, | ||
| "scripts": { | ||
| "build": "yarn tsc", | ||
| "build": "tsc", |
marc-temp
left a comment
There was a problem hiding this comment.
Looks fine to me
Will need supporting evidence of testing to ensure no regression and works BAU
Would ofc want Simon/Conor opinion/testing on this too
There was a problem hiding this comment.
🟡 Changes recommended
Critical Docker build failures and unresolved npm/documentation migration issues remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Migrates the monorepo from Yarn to npm workspaces, adds npm security auditing, and upgrades tooling to Node.js 24.
Changes:
- Replaced Yarn commands and configuration with npm equivalents.
- Added npm security settings and dependency auditing.
- Updated CI, release workflows, Docker builds, documentation, and formatting configuration.
File summaries
| File | Summary |
|---|---|
worker/src/queues/ses/helpers/SESEmail.ts |
Formatting update. |
worker/package.json |
npm scripts and dependency updates. |
worker/Dockerfile |
Critical (3 votes): stale .yarn copy causes the Docker build to fail. |
worker/.prettierrc |
Formatting update. |
README.md |
npm workflow and security documentation updates. |
package.json |
Moderate (1 vote): port Yarn resolutions to npm overrides and regenerate the lockfile. |
eslint.config.mjs |
Flat ESLint configuration. |
dynamic-content/README.md |
npm usage instructions. |
dynamic-content/babel.config.js |
Formatting update. |
dynamic-content/.prettierrc |
Formatting update. |
docs/testing.md |
Nit (3 votes): replace unsupported Yarn Cypress and smoke-test commands. |
api/src/middlewares/services/UserService/UserService.ts |
Formatting update. |
api/src/middlewares/services/UserService/NotifyTemplates/MarriageUserTemplates.ts |
Formatting update. |
api/src/middlewares/services/UserService/NotifyTemplates/CertifyCopyUserTemplates.ts |
Formatting update. |
api/src/middlewares/services/UserService/__tests__/userService.test.ts |
Formatting update. |
api/src/middlewares/services/SubmitService/SubmitService.ts |
Formatting update. |
api/src/middlewares/services/QueueService/QueueService.ts |
Formatting update. |
api/src/middlewares/services/CaseService/requestDocument/requestDocumentCaseService.ts |
Formatting update. |
api/src/middlewares/services/CaseService/certifyCopy/CertifyCopyCaseService.ts |
Formatting update. |
api/README.md |
Node.js and npm setup updates. |
api/package.json |
npm scripts and dependency updates. |
api/Dockerfile |
Critical (3 votes): stale .yarn copy causes the Docker build to fail. |
.yarnrc.yml |
Removed Yarn configuration. |
.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs |
Removed Yarn workspace plugin. |
.prettierrc |
Formatting configuration update. |
.prettierignore |
Formatting exclusions. |
.npmrc |
npm security configuration. |
.gitignore |
Tracks the npm lockfile. |
.github/workflows/release.yml |
Node.js 24 and npm release updates. |
.eslintrc.json |
Removed legacy ESLint configuration. |
.dockerignore |
Removed Yarn-specific exclusions. |
.circleci/config.yml |
npm installation, auditing, and Node.js 24 updates. |
Review details
Suppressed comments (2)
api/Dockerfile:17
- The npm workspace install records API-only dependencies such as
joi@18.2.9underapi/node_modules, while the root lock tree also containsjoi@17.13.7for dynamic-content. This image copies only/usr/src/app/node_modules, then relocates the compiled API to/usr/dist/app/dist, so the API'simport joieither resolves the wrong major or cannot resolve it at runtime. Copy/flatten the API workspace's production node_modules into the runtime tree, or build a production install layout that preserves the API dependency tree.
RUN npm ci --ignore-scripts=true --workspace @notarialapi/api --include-workspace-root
package.json:35
- This migration removes the Yarn
resolutionsblock but does not add npmoverridesfor its transitive security pins. Although the current lockfile records versions, a later intentionalnpm installcan re-resolve packages such asfollow-redirects,qs, ortarwithout those constraints; port the required pins tooverridesand regenerate the lockfile.
"semantic-release": "^25.0.9"
- Files reviewed: 25/35 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| COPY . . | ||
| RUN yarn workspaces focus @notarialapi/api | ||
| RUN yarn api build | ||
| RUN npm ci --ignore-scripts=true --workspace @notarialapi/api --include-workspace-root |
| RUN yarn worker build | ||
| # reinstall only production deps | ||
| RUN yarn workspaces focus @notarialapi/worker --production | ||
| RUN npm ci --ignore-scripts=true --workspace @notarialapi/worker --include-workspace-root |
| ### running unit tests | ||
| Unit tests will be run every time a new commit is pushed to any branch, however you can also, and are encouraged to, run the tests locally before pushing up your changes. | ||
| To run unit tests across the entire repo, execute the command `yarn test`. This will then delegate the command to each workspace independently, and have each workspace execute its own tests. | ||
| To run unit tests across the entire repo, execute the command `npm test`. This will then delegate the command to each workspace independently, and have each workspace execute its own tests. |
a4480c9 to
bb87812
Compare
bb87812 to
69bf353
Compare
marc-temp
left a comment
There was a problem hiding this comment.
Need to leave this PR open and point to main branch
Implement Kainos npm security measures: notarial-api
JIRA: https://consular.atlassian.net/browse/NR-929
changes description:
Migrated dependency management from Yarn to npm workspaces.
Added npm security configuration to restrict lifecycle scripts and Git dependencies.
Added moderate-severity dependency auditing to the CircleCI pipeline.
Updated API and worker Docker builds to use secure npm installation.
Upgraded Node.js to version 24 across CI, releases, and containers.
pipeline on this feature branch - circle -ci
![Uploading Screenshot 2026-09-21 at 12.38.41.png…]()