Rules

API key or private key hardcoded in source code

SR-SEC-002 · High

A key written directly into source code ends up in every clone of the repo, in its git history and often in the built app. Stripe live keys, webhook secrets, OpenAI, Anthropic and AWS keys, Supabase secret keys, GitHub tokens and private key blocks all give whoever holds them access to your accounts or your bill. The fix is to load the key from an environment variable that is kept out of git, then rotate it with the provider. Deleting the line is not enough, because the old commit still contains the key.

The fix

Before · app/api/chat/route.ts
import OpenAI from "openai";

const openai = new OpenAI({ apiKey: "sk-proj-..." });
After · app/api/chat/route.ts
import OpenAI from "openai";

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

How ShipReady finds it

ShipReady matches source files against the formats of Stripe live and webhook secrets, OpenAI, Anthropic, Supabase secret, AWS and GitHub keys, and private key blocks. Env files and test files are skipped. Findings carry rule ID SR-SEC-002.

Run the check

Terminal
npx @shipmate-agency/shipready check .
GitHub Action
# .github/workflows/shipready.yml
name: ShipReady
on: [push, pull_request]

permissions:
  contents: read
  security-events: write

jobs:
  shipready:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: deeflect/shipready@v0.2.0

Want a person to check every area and send the fixes as pull requests? Launch Lockdown, $950 once.