Skip to content

fix: update dependencies to resolve npm audit vulnerabilities - #1352

Open
saidai-bhuvanesh wants to merge 1 commit into
Canopus-Labs:mainfrom
saidai-bhuvanesh:fix/npm-audit-fix
Open

fix: update dependencies to resolve npm audit vulnerabilities#1352
saidai-bhuvanesh wants to merge 1 commit into
Canopus-Labs:mainfrom
saidai-bhuvanesh:fix/npm-audit-fix

Conversation

@saidai-bhuvanesh

@saidai-bhuvanesh saidai-bhuvanesh commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

The backend has multiple npm vulnerabilities: 7 high-severity, 5 moderate-severity, and 1 low-severity. Vulnerable packages include file-type, nodemailer, uuid, and gaxios.

Changes

  • Updated file-type to 22.0.1
  • Updated nodemailer to 9.0.4
  • Updated uuid to 11.x
  • Updated gaxios to 6.8.0+
  • Files: backend/package.json, backend/package-lock.json

Testing

  • npm install succeeds
  • npm audit shows 0 vulnerabilities
  • Application starts without errors
  • All tests pass

Closes #1353

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The backend package manifest adds gaxios and development uuid, upgrades file-type and nodemailer, and constrains the nested gaxios UUID version.

Changes

Backend dependency updates

Layer / File(s) Summary
Dependency manifest updates
backend/package.json
The manifest adds gaxios and development uuid, upgrades file-type and nodemailer, and applies an npm override requiring gaxios’s uuid version to be >=11.1.1.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: anupamme, karanunique

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the dependency updates made to address npm audit vulnerabilities.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/npm-audit-fix
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/package.json`:
- Line 29: Resolve the incompatibility between the backend’s
require("file-type") usage and file-type@22.0.1 by either migrating the backend
import/runtime to ESM with Node.js 22 support or, preferably, pinning file-type
to a version compatible with the existing CommonJS backend and Node.js 18/20 CI
environments. Update the dependency entry and ensure the current backend loading
path remains functional.
- Around line 43-45: Update backend/package.json by removing the direct uuid
entry from devDependencies and removing the gaxios override. Allow gaxios to
resolve its compatible uuid^9.0.1 dependency, or configure the override to a
CommonJS-compatible uuid version.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d489923-85f2-43e5-9e1e-d4eb7ef1a4ff

📥 Commits

Reviewing files that changed from the base of the PR and between 32c4e5c and 733ecaf.

⛔ Files ignored due to path filters (1)
  • backend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • backend/package.json

Comment thread backend/package.json
"express": "^5.1.0",
"express-rate-limit": "^8.2.1",
"file-type": "^18.5.0",
"file-type": "^22.0.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n '"type"|"engines"' backend/package.json
rg -nP 'fileTypeFromBuffer|(?:from|require\()\s*["'\'']file-type' backend \
  --glob '*.js' --glob '*.mjs' --glob '*.cjs'
npm view file-type@22.0.1 engines type --json

Repository: Canopus-Labs/PrepPilot

Length of output: 160


🏁 Script executed:

set -u

printf '%s\n' '--- backend/package.json ---'
sed -n '1,120p' backend/package.json

printf '%s\n' '--- file-type references ---'
rg -n -P 'fileTypeFromBuffer|(?:from|require\()\s*["'\'']file-type' backend \
  --glob '*.js' --glob '*.mjs' --glob '*.cjs' || true

printf '%s\n' '--- runtime declarations and deployment files ---'
rg -n -i 'node(js)?|NODE_VERSION|runtime|engines|FROM node|setup-node|node-version' \
  backend .github Dockerfile* docker-compose* render* railway* vercel* fly* 2>/dev/null || true

printf '%s\n' '--- lockfile references ---'
rg -n -C 3 '"file-type"|file-type@' backend \
  --glob 'package-lock.json' --glob 'npm-shrinkwrap.json' --glob 'yarn.lock' \
  --glob 'pnpm-lock.yaml' || true

Repository: Canopus-Labs/PrepPilot

Length of output: 50378


🌐 Web query:

file-type 22.0.1 package.json engines type fileTypeFromBuffer Node.js

💡 Result:

The file-type package version 22.0.1 requires Node.js 22 or later [1][2][3]. It is an ESM-only package, meaning your project must also be configured for ESM (e.g., "type": "module" in your package.json) [4][5][6]. The fileTypeFromBuffer function is a core export of the package [7][8]. It is used to detect the file type (MIME type and extension) of a Uint8Array or ArrayBuffer by inspecting its magic number [7][9]. Example usage: import {fileTypeFromBuffer} from 'file-type'; import {readChunk} from 'read-chunk'; const buffer = await readChunk('file', {length: 4100}); const type = await fileTypeFromBuffer(buffer); console.log(type); // {ext: '...', mime: '...'} or undefined [7][8] Note that starting with version 22.0.0, the package dropped support for Node.js Readable streams in favor of web ReadableStreams [2][3]. If you have a Node.js Readable stream, you should convert it using Readable.toWeb before passing it to related functions [2].

Citations:


🏁 Script executed:

set -u

printf '%s\n' '--- CI workflow ---'
sed -n '1,80p' .github/workflows/ci.yml

printf '%s\n' '--- locked file-type metadata ---'
sed -n '1618,1638p' backend/package-lock.json

printf '%s\n' '--- upload middleware ---'
sed -n '1,110p' backend/middlewares/uploadMiddleware.js

printf '%s\n' '--- package metadata from npm registry ---'
curl -fsSL https://registry.npmjs.org/file-type/22.0.1 |
  node -e '
    let s = "";
    process.stdin.on("data", d => s += d);
    process.stdin.on("end", () => {
      const p = JSON.parse(s);
      console.log(JSON.stringify({
        version: p.version,
        type: p.type,
        engines: p.engines,
        exports: p.exports
      }, null, 2));
    });
  '

Repository: Canopus-Labs/PrepPilot

Length of output: 4858


Use a compatible file-type version or migrate the backend to ESM.

The backend uses require("file-type"), but file-type@22.0.1 is ESM-only and requires Node.js >=22. CI currently runs Node.js 18 and 20. Update the import and runtime, or select a compatible package version.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/package.json` at line 29, Resolve the incompatibility between the
backend’s require("file-type") usage and file-type@22.0.1 by either migrating
the backend import/runtime to ESM with Node.js 22 support or, preferably,
pinning file-type to a version compatible with the existing CommonJS backend and
Node.js 18/20 CI environments. Update the dependency entry and ensure the
current backend loading path remains functional.

Comment thread backend/package.json
Comment on lines 43 to +45
"devDependencies": {
"nodemon": "^3.1.10",
"uuid": "^14.0.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -nP '(?:from|require\()\s*["'\'']uuid' backend \
  --glob '*.js' --glob '*.mjs' --glob '*.cjs' --glob '*.ts'

Repository: Canopus-Labs/PrepPilot

Length of output: 160


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- backend/package.json ---'
cat -n backend/package.json

printf '%s\n' '--- dependency manifests and lockfiles ---'
git ls-files | rg '(^|/)(package(-lock)?\.json|yarn\.lock|pnpm-lock\.yaml|npm-shrinkwrap\.json)$' || true

printf '%s\n' '--- all uuid references ---'
rg -n -i '\buuid\b|from[[:space:]]+["'\'']uuid|require\([[:space:]]*["'\'']uuid' . \
  --glob '!node_modules/**' --glob '!dist/**' --glob '!build/**' \
  --glob '!coverage/**' || true

printf '%s\n' '--- backend source files ---'
git ls-files backend | sed -n '1,160p'

Repository: Canopus-Labs/PrepPilot

Length of output: 6415


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- root package manifests ---'
for f in package.json backend/package.json package-lock.json backend/package-lock.json; do
  if [ -f "$f" ]; then
    printf '\n--- %s ---\n' "$f"
    cat -n "$f" | sed -n '1,70p'
  fi
done

printf '%s\n' '--- lockfile uuid and gaxios records ---'
python3 - <<'PY'
import json

for path in ("backend/package-lock.json", "package-lock.json"):
    try:
        with open(path) as f:
            data = json.load(f)
    except FileNotFoundError:
        continue

    print(f"\n--- {path} ---")
    packages = data.get("packages", {})
    for key in ("", "node_modules/gaxios", "node_modules/uuid", "backend", "backend/node_modules/gaxios", "backend/node_modules/uuid"):
        if key in packages:
            print(key or "<root>")
            print(json.dumps(packages[key], indent=2))
PY

Repository: Canopus-Labs/PrepPilot

Length of output: 9184


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import json

path = "backend/package-lock.json"
with open(path) as f:
    lock = json.load(f)

packages = lock["packages"]
print("--- packages declaring uuid ---")
for name, meta in packages.items():
    deps = meta.get("dependencies", {})
    if "uuid" in deps:
        print(name or "<root>", "->", deps["uuid"])

print("\n--- installed uuid package entries ---")
for name, meta in packages.items():
    if name == "node_modules/uuid" or name.endswith("/node_modules/uuid"):
        print(name or "<root>", "version=", meta.get("version"),
              "dev=", meta.get("dev", False),
              "resolved=", meta.get("resolved"))

print("\n--- direct dependency classification ---")
root = packages[""]
print("uuid in dependencies:", root.get("dependencies", {}).get("uuid"))
print("uuid in devDependencies:", root.get("devDependencies", {}).get("uuid"))

print("\n--- package owners for uuid declarations ---")
for name, meta in packages.items():
    if "uuid" in meta.get("dependencies", {}):
        print(name or "<root>", "dev=", meta.get("dev", False),
              "optional=", meta.get("optional", False),
              "peer=", meta.get("peer", False))
PY

Repository: Canopus-Labs/PrepPilot

Length of output: 910


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import json

with open("backend/package-lock.json") as f:
    lock = json.load(f)

packages = lock["packages"]
for name, meta in packages.items():
    if "gaxios" in name or name.endswith("/node_modules/uuid") or name == "node_modules/uuid":
        print(f"\n--- {name or '<root>'} ---")
        for key in ("version", "resolved", "dev", "dependencies", "optionalDependencies", "peerDependencies"):
            if key in meta:
                print(f"{key}: {json.dumps(meta[key], indent=2)}")
PY

printf '%s\n' '--- lockfile uuid/gaxios context ---'
rg -n -C 8 '"uuid"|"gaxios"' backend/package-lock.json | sed -n '1,260p'

Repository: Canopus-Labs/PrepPilot

Length of output: 8473


🌐 Web query:

gaxios 6.7.1 uuid require CommonJS source

💡 Result:

In gaxios version 6.7.1, the uuid dependency upgrade to v10 was rolled back [1][2]. This rollback was performed to address compatibility issues introduced in version 6.7.0, specifically crashes occurring in older Node.js environments (such as Node.js 14 versions prior to 14.18.0) caused by uuid v10's requirement for newer Node.js features like 'node:crypto' [3][4]. By reverting this change in 6.7.1, gaxios returned to a state compatible with the previous uuid versioning, ensuring that common CommonJS environments that may have been broken by the upgrade would function as expected [3][4].

Citations:


🌐 Web query:

uuid 14.0.1 package.json exports require CommonJS

💡 Result:

In the uuid package, version 14.0.1 does not support CommonJS [1][2][3]. Starting with version 12, the uuid library removed support for CommonJS entirely, shifting to a pure ECMAScript Module (ESM) codebase [3][4]. Consequently, the package.json exports field in version 14.0.1 does not provide a require condition for CommonJS, as the package is intended for use in ESM environments [1][3]. Users attempting to use require with this version will encounter errors, as the library no longer provides the CommonJS compatibility layer that existed in earlier versions [3]. If you are working in a CommonJS project, you must either use an older version of the uuid package (prior to v12) or migrate your project to ESM [3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

python3 - "$tmp" <<'PY'
import json, os, sys, urllib.request

out = sys.argv[1]
for package, version in (("gaxios", "6.7.1"), ("uuid", "14.0.1")):
    data = json.load(urllib.request.urlopen(
        f"https://registry.npmjs.org/{package}/{version}"
    ))
    tarball = data["dist"]["tarball"]
    target = os.path.join(out, f"{package}.tgz")
    urllib.request.urlretrieve(tarball, target)
    print(package, version, tarball)
PY

mkdir "$tmp/gaxios" "$tmp/uuid"
tar -xzf "$tmp/gaxios.tgz" -C "$tmp/gaxios"
tar -xzf "$tmp/uuid.tgz" -C "$tmp/uuid"

printf '%s\n' '--- gaxios package metadata ---'
cat "$tmp/gaxios/package/package.json"

printf '%s\n' '--- gaxios uuid references and module loading ---'
rg -n -i 'uuid|require\(|from[[:space:]]+["'\'']' "$tmp/gaxios/package" \
  --glob '*.js' --glob '*.cjs' --glob '*.mjs' --glob '*.d.ts' || true

printf '%s\n' '--- uuid package metadata ---'
cat "$tmp/uuid/package/package.json"

Repository: Canopus-Labs/PrepPilot

Length of output: 2446


🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

for spec in gaxios@6.7.1 uuid@14.0.1; do
  name="${spec%@*}"
  version="${spec#*@}"
  curl -fsSLk "https://registry.npmjs.org/$name/$version" \
    -o "$tmp/$name.json"
  url="$(jq -r '.dist.tarball' "$tmp/$name.json")"
  curl -fsSLk "$url" -o "$tmp/$name.tgz"
  mkdir "$tmp/$name"
  tar -xzf "$tmp/$name.tgz" -C "$tmp/$name"
done

printf '%s\n' '--- gaxios package metadata ---'
cat "$tmp/gaxios/package/package.json"

printf '%s\n' '--- gaxios uuid references and module loading ---'
rg -n -i 'uuid|require\(|from[[:space:]]+["'\'']' "$tmp/gaxios/package" \
  --glob '*.js' --glob '*.cjs' --glob '*.mjs' --glob '*.d.ts' || true

printf '%s\n' '--- uuid package metadata ---'
cat "$tmp/uuid/package/package.json"

Repository: Canopus-Labs/PrepPilot

Length of output: 10310


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- backend Google package usage ---'
rg -n -C 3 '`@google`|google-auth-library|gcp-metadata|gtoken|gaxios' backend \
  --glob '!package-lock.json' --glob '!*.json' || true

printf '%s\n' '--- runtime declarations ---'
for f in backend/Dockerfile backend/.nvmrc backend/.node-version; do
  if [ -f "$f" ]; then
    printf '\n--- %s ---\n' "$f"
    cat -n "$f"
  fi
done

printf '%s\n' '--- production dependency parents in lockfile ---'
python3 - <<'PY'
import json

with open("backend/package-lock.json") as f:
    packages = json.load(f)["packages"]

targets = {"gcp-metadata", "google-auth-library", "gtoken", "gaxios"}
for name, meta in packages.items():
    deps = {**meta.get("dependencies", {}), **meta.get("optionalDependencies", {})}
    hit = sorted(targets.intersection(deps))
    if hit:
        print(name or "<root>", "->", ", ".join(f"{x}@{deps[x]}" for x in hit))
PY

Repository: Canopus-Labs/PrepPilot

Length of output: 1772


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import json

with open("backend/package-lock.json") as f:
    packages = json.load(f)["packages"]

for name in ("node_modules/@google/generative-ai", "node_modules/@google/genai"):
    print(f"--- {name} ---")
    print(json.dumps(packages.get(name, {}), indent=2))
PY

Repository: Canopus-Labs/PrepPilot

Length of output: 1080


Remove the gaxios override and the direct uuid devDependency. gaxios@6.7.1 calls require("uuid"), but the override resolves its production dependency to ESM-only uuid@14.0.1. Let gaxios resolve uuid^9.0.1, or pin a CommonJS-compatible version.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/package.json` around lines 43 - 45, Update backend/package.json by
removing the direct uuid entry from devDependencies and removing the gaxios
override. Allow gaxios to resolve its compatible uuid^9.0.1 dependency, or
configure the override to a CommonJS-compatible uuid version.

@KaranUnique

Copy link
Copy Markdown
Contributor

@saidai-bhuvanesh Take a look at coderabbit suggestions

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SECURITY] Multiple npm audit vulnerabilities in dependencies

3 participants