hyperledger / hyperledger/fabric-samples

rest-api-typescript: migrate off bullmq v1 to clear the uuid advisory

Open
#1,449 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3k
Forks
3.5k
Avg merge
3d 20h
Merged PRs (30d)
6

Description

## Summary

`asset-transfer-basic/rest-api-typescript` is pinned to `bullmq@^1.47.2`, which transitively depends on `uuid@^9.0.0`. `uuid@9.0.1` is affected by [GHSA-w5hq-g745-h8pq](https://github.com/advisories/GHSA-w5hq-g745-h8pq) (medium — missing buffer bounds check in v3/v5/v6 when `buf` is provided, patched in `11.1.1`).

There is no patched `uuid` reachable while bullmq stays on v1, because bullmq@1 pins `uuid: ^9.0.0`. The only fix is to move the sample to a bullmq version that no longer depends on it.

Dependabot attempted exactly that in #1448, bumping `bullmq` straight from `^1.47.2` to `^6.3.4`, but the jump cannot work as a dependency-only change and broke CI (`test-sample` and `typescript` both failed on the same `npm install` error).

## Why the straight bump fails

**1. `ioredis` became a peer dependency.**

`bullmq@1.91.1` vendored its own `node_modules/bullmq/node_modules/ioredis@5.3.2`, so it never interacted with the root's `ioredis@^4.27.8`. `bullmq@6` declares `ioredis` as a peer (`>=5.0.0`) instead, so it now resolves against the root, which is still on v4:

```
npm error While resolving: bullmq@6.3.4
npm error Found: ioredis@4.28.5
npm error ioredis@"^4.27.8" from the root project
npm error peer ioredis@"4.x" from ioredis-mock@5.9.1
npm error Could not resolve dependency:
npm error peerOptional ioredis@">=5.0.0" from bullmq@6.3.4
```

**2. `QueueScheduler` was removed in bullmq v2.**

Its responsibilities (stalled and delayed jobs) moved into `Worker`. There is no `queue-scheduler` module in the 6.3.4 tarball, so `tsc` would fail even after the install resolved. The sample uses it in three places:

- `src/jobs.ts:217` — `initJobQueueScheduler()`
- `src/index.ts:68` — conditional startup behind `config.submitJobQueueScheduler`
- `src/index.ts:83` — shutdown in the error path

## Work required

- `bullmq` → `^6`
- `ioredis` `^4.27.8` → `^5`
- `ioredis-mock` `^5.6.0` → `^8` (peers on `ioredis: ^5`)
- drop `@types/ioredis@^4.26.4` — ioredis 5 ships its own types
- remove `initJobQueueScheduler` and its call sites; retire the `SUBMIT_JOB_QUEUE_SCHEDULER` config option (`src/config.ts:98`)
- check `src/redis.ts` against the ioredis 5 API — `redis.config('GET', ...)` return typing changed
- update the mocks in `src/redis.spec.ts`, `src/fabric.spec.ts` and `src/__tests__/api.test.ts`

## Interim state

#1448 has had its `bullmq` bump reverted so the five other security updates in that group (`@grpc/grpc-js`, `brace-expansion`, `axios`, `qs`, `tmp`) can land and CI can go green. That leaves the `uuid` advisory open, which is what this issue tracks.

Practical exposure is low: the sample only reaches `uuid` transitively through bullmq's job-ID generation, which does not pass a caller-supplied `buf`.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failed npm install and reviewing the bullmq, ioredis, and ioredis-mock dependency declarations. Then inspect the QueueScheduler references in src/jobs.ts:217 and src/index.ts:68,83, the option in src/config.ts:98, and the mocks in src/redis.spec.ts, src/fabric.spec.ts, and src/__tests__/api.test.ts. Done means the migration installs cleanly, TypeScript and test-sample checks pass, and the obsolete scheduler path is removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.