Workbench · Bench 04 · Code security

What a careful read of a codebase turns up.

Dependencies, lint, code smells and leaked secrets, checked in one pass and written up as a plain report you can act on. Notes from reading code with a suspicious eye.

See the four checks

Four things a security read looks at.

The same ground a tool like SonarQube covers, and worth a human read as well as a scan.

  1. 01

    Dependencies and CVEs

    Every package in your lockfile matched against the public vulnerability databases, with the version that fixes it.

    High lodash 4.17.15 CVE-2021-23337 · fixed in 4.17.21
  2. 02

    Lint and conventions

    Your own linter config run as the team intended, plus the rules that catch real bugs: unused results, unsafe any, floating promises.

    Medium src/api/orders.ts:88 Promise returned is not awaited
  3. 03

    Code smells

    Long functions, deep nesting, copy-pasted blocks and files everyone is scared to touch, ranked by how often they change.

    Smell checkout.ts · handlePayment() 212 lines · complexity 31
  4. 04

    Secrets and config

    Keys and tokens in the code or the git history, debug flags left on, and permissions wider than they need to be.

    Critical .env.backup (commit 4e1a9c2) AWS access key in history

A scanner gives you four hundred warnings. What helps is a short ranked list, and fixing the worst three first.

How a review usually runs.

Scan for breadth, read what it flags, and rank what is left.

  1. 1

    Run the scanners

    Dependency, lint and secret scanners over the whole repository, for breadth.

  2. 2

    Read what they flag

    Open the flagged code, check it is real, and drop the noise.

  3. 3

    Rank the findings

    A short list with the fix for each finding, worst first.

Stacks I read

  • TypeScript
  • JavaScript
  • Node.js
  • PHP
  • Laravel
  • Python
  • Go
  • Docker
See the other benches