Skip to content

CCM-17440: Fix dependabot issues#321

Open
simonlabarere wants to merge 15 commits intomainfrom
feature/CCM-17440_dependabot_updates
Open

CCM-17440: Fix dependabot issues#321
simonlabarere wants to merge 15 commits intomainfrom
feature/CCM-17440_dependabot_updates

Conversation

@simonlabarere
Copy link
Copy Markdown
Contributor

@simonlabarere simonlabarere commented Apr 30, 2026

Description

Updated the following dependencies:

  • axios
  • uuid override for mermaid
  • erb

node-jose uses a vulnerable version of uuid and it couldn't be overridden (I hacked it to force it use a new version and node-jose wouldn't work because it detected something was wrong).

I used copilot to replace node-jose with a combination of jose (which is maintained) and node:crypto. The problem is that jose version 6 (latest) is not compatible out of the box with the way we use jest for testing. I spent some time trying to make it work but it involved using an experimental version of jest and it made all the unit tests flaky in general. Version 5 of jose didn't have that problem so this is what I ended up using but it's a year old. On the other hand it doesn't have any vulnerabilities so it's still better than the 3 year old version of node-jose.

Testing involved generating a new public/private key pair and making sure it's working with the APIM authentication mechanism.

image image

Testing

Running the key-generation lambda manually

image

Generated private key

image

Generated public key

image image

APIM Updated to point at pr321

image

Token generation

image image

Other changes

Since we last ran the build docs step:

  • The package-lock.json that previously lived inside the docs folder no longer exists, as docs is now part of the root workspace. The build-docs action was running cd docs && npm ci, which no longer installs anything because there is no lockfile in that directory.
  • GitHub Actions (including build-docs) have been centralised and moved into the nhs-notify-shared-modules repository.
  • The workflow was previously referencing an older shared-modules release where the build-docs action was pinned to Node 18.

There is a corresponding PR in the shared-modules repository to address these changes. Until a new version of shared-modules is released, this PR references the commit SHA directly. Once a new release is available, we can update this to use the release tag instead.

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@simonlabarere simonlabarere requested a review from a team as a code owner April 30, 2026 09:57
@simonlabarere simonlabarere force-pushed the feature/CCM-17440_dependabot_updates branch 5 times, most recently from 0dfc38a to 2e522f2 Compare May 5, 2026 12:19
@simonlabarere simonlabarere added the dependencies Pull requests that update a dependency file label May 5, 2026
@simonlabarere simonlabarere force-pushed the feature/CCM-17440_dependabot_updates branch 2 times, most recently from 7d404da to 63ce4d2 Compare May 6, 2026 08:42
@simonlabarere simonlabarere force-pushed the feature/CCM-17440_dependabot_updates branch from 63ce4d2 to 72c1f93 Compare May 6, 2026 14:05
lapenna-bjss
lapenna-bjss previously approved these changes May 7, 2026
@lapenna-bjss lapenna-bjss requested a review from a team as a code owner May 7, 2026 14:28
lapenna-bjss
lapenna-bjss previously approved these changes May 8, 2026
Comment thread utils/utils/src/key-generation-utils/jwk.ts Outdated
Ian-Hodges
Ian-Hodges previously approved these changes May 8, 2026
@simonlabarere simonlabarere dismissed stale reviews from Ian-Hodges and lapenna-bjss via cb90136 May 8, 2026 10:10
@@ -1,4 +1,4 @@
import { KeyStore } from '../../key-generation-utils/jwk';
import { KeyStore } from '../../key-generation-utils/jwk-key-store';
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.

Sorry, it's super minor, but this can be shortened.
import { KeyStore } from '../../key-generation-utils';

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.

Actually, it can be added to the one below.
import { KeyStore, generateNewKey } from '../../key-generation-utils';

@@ -0,0 +1,73 @@
import { Key } from '../../key-generation-utils/jwk-key';
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
import { Key } from '../../key-generation-utils/jwk-key';
import { Key } from '../../key-generation-utils';

Comment on lines +1 to 3
import { asKeyStore } from '../../key-generation-utils/jwk';
import { logger } from '../../logger';
import { uploadPublicKeystoreToS3 } from '../../key-generation-utils';
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
import { asKeyStore } from '../../key-generation-utils/jwk';
import { logger } from '../../logger';
import { uploadPublicKeystoreToS3 } from '../../key-generation-utils';
import { logger } from '../../logger';
import { asKeyStore, uploadPublicKeystoreToS3 } from '../../key-generation-utils';

Comment on lines +1 to 6
import { asKey } from '../../key-generation-utils/jwk';
import {
ValidateKeyResult,
validatePrivateKey,
} from '../../key-generation-utils';

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
import {
asKey,
ValidateKeyResult,
validatePrivateKey,
} from '../../key-generation-utils';

@gareth-allan gareth-allan self-assigned this May 8, 2026
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: "Build docs"
uses: NHSDigital/nhs-notify-shared-modules/.github/actions/build-docs@3.0.0
uses: NHSDigital/nhs-notify-shared-modules/.github/actions/build-docs@53e42b5046ec10ce54d732c0051c96968aaebeb2
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.

This is a change that needs reverting before merge, right? Or updating to point at a new tag.


const key = await JWK.asKey(keyPem, 'pem');
const { kid } = key.toJSON() as KeyJson;
await asKey(keyPem, 'pem');
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.

The result of this asKey call isn't being used. Is it redundant? You seem to be getting the Key ID from the SSM parameter name instead?

const key = await JWK.asKey(keyPem, 'pem');
const { kid } = key.toJSON() as KeyJson;
await asKey(keyPem, 'pem');
const privateKeyRegex = /privatekey_(\d{8})_(.+)\.pem/;
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.

This regex also appears to be defined in validateParamName above. It could perhaps be extracted to a constant, or perhaps wrapped with a utility to use it to extract the components of a key name that can be reused?

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.

We should probably have tests for this class, shouldn't we?

Comment on lines +41 to +46
const pem = nodePrivateKey.export({
type: 'pkcs8',
format: 'pem',
}) as string;

const reImportedKey = createPrivateKey(pem);
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.

Why export nodePrivateKey and then re-import it? I assume there's a reason for it, but it would be worth a comment to explain what it is.

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

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants