Remove or wire up unused dependencies: `hpp` and `express-mongo-sanitize` are declared but never imported
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 62/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- express, nodejs, typescript
Research direction
Start with git log -S on package.json for hpp and express-mongo-sanitize to establish intent, then read the middleware chain in src/main.ts (helmet, SanitizePipe, createGlobalValidationPipe). If the packages are dead, remove them and regenerate package-lock.json; if intended, apply hpp() and mongoSanitize() before the pipes and add a test for duplicate query keys or $where operators. Done means the intent is recorded in the PR, npm ci, npx tsc --noEmit and npm test pass, and no unused entry remains for this pair.
Written by the indexing model from the issue text.
Description
Problem
package.json declares HTTP-parameter-pollution and NoSQL-injection protections that are never used anywhere in src/:
"express-mongo-sanitize": "^2.2.0",
"hpp": "^0.2.3",
A scan of every TypeScript file under src/ for hpp and mongoSanitize returns zero matches for both. They are installed in production dependencies but not applied.
src/main.ts sets up a global middleware/pipe chain — helmet (line 60), a favicon handler (63-69), SanitizePipe (75), createGlobalValidationPipe() (76), and CORS (80) — and neither library appears in it.
For contrast, the protections that are wired up: helmet with a full CSP (src/config/helmet.config.ts), a SanitizePipe using class-sanitizer (src/common/pipes/sanitize.pipe.ts), x-powered-by disabled (line 83), and strict validation.
Why it matters
Two possible states, both worth fixing:
- Dead dependencies. They add install time, image size, and supply-chain surface for no benefit — every dependency is code an attacker could target and maintainers must track.
npm auditwill also report on them. - Intended but forgotten protections. If someone added these deliberately and never wired them up, then the API is missing HTTP parameter pollution defence and NoSQL operator sanitisation, and the install step created a false sense of coverage.
Which one it is determines the fix, so establish that first.
Suggested Direction
- Determine intent. Check git history for why these were added. If there is no rationale, they are dead weight.
- If dead: remove them from
package.jsonand regeneratepackage-lock.json. Also remove thepathandcryptostub packages if not already handled by the dependency-alignment issue. - If intended: wire them up in
src/main.tsalongside the existing middleware, ordered deliberately:
Place them beforeapp.use(hpp()); app.use(mongoSanitize());SanitizePipeand the validation pipe so polluted or operator-laden parameters are rejected before validation. - Verify no regression. The global
ValidationPipesetsforbidNonWhitelisted: true, so extra query parameters already 400 — buthppprotects against duplicate-key confusion which the pipe does not catch.
Constraints
hppoperates onreq.queryand mutates it; confirm it does not break legitimate repeated query parameters before applying.express-mongo-sanitizewas unmaintained at one point — verify the installed version (2.2.x) is current and compatible with Express 5, which the repo uses.- If removing, ensure
npm cistill resolves and CI passes.
Acceptance Criteria
- The intent of each dependency is established and recorded in the PR.
- Either the dependency is removed and the lockfile regenerated, or it is applied in
src/main.tswith a comment on ordering. - A test covers the behaviour being protected (duplicate query keys or
__proto__/$whereoperators). -
npm ci,npx tsc --noEmit, andnpm testpass. - No unused entry remains in
dependenciesfor this pair.
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 55
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SourceXXL/alian_structure-api
-
good first issue help wanted security
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#266 ·
-
Parallelize the cache-warming loop in `cache-warming.service.ts` — warmers run strictly sequentiallyPossibly taken @syntaxsuuvam-spec claimed this 2 days ago. Opengood first issue performance
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#240 ·
-
documentation help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
SourceXXL/alian_structure-api#215 ·
-
good first issue refactor tooling
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
SourceXXL/alian_structure-api#199 ·
-
help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SourceXXL/alian_structure-api#196 ·
All issues in SourceXXL/alian_structure-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
db-ux-design-system/core-web#8461 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Cannot run an integration on windows when power shell is selected as the default profile terminalOpenPriority/Blocker Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
wso2/product-integrator#2767 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
severity:low
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day