Your git secret scanner is looking at the wrong thing. It scans commits. Nothing you publish is a commit: an npm tarball is packed from files on disk, a PyPI sdist is assembled from your working tree, and a Docker image is a stack of layers that remember everything ever copied into them. The leak almost never happens in git. It happens in the build.

We re-crawl the latest tarballs of 1,010 popular npm packages and inspect every file (full audit, updated Dec 3): 51% ship source maps, 32% inline their full original source via sourcesContent, and 5% matched a secret pattern or a sensitive-file rule — CI config, coverage output, credential-shaped strings. Every one of those was a build-config default nobody looked at. The same defaults exist in the other two ecosystems. Here's how to check all three before you ship.

What actually leaks (the same five categories everywhere)

  1. Source maps with sourcesContent — the full pre-build source of every input file, comments and internal URLs included. Dead weight for open source; the whole codebase for a closed-source SDK or CLI.
  2. Credential files — .env, .npmrc with an auth token, .pypirc, service-account JSON, private keys. They live on disk (or in an image layer), never in git, so history scanners never see them.
  3. Hard-coded secrets in build output — a key a bundler inlined from an env var at build time, a token pasted into a test fixture. Filename checks miss these; you have to read file contents.
  4. Internal docs and code — roadmaps, internal/ folders, unreleased features, .git metadata baked into an image.
  5. Debug and infra leftovers — logs, coverage reports, database dumps, Terraform state, CI config, internal hostnames.

npm: the tarball is packed from disk, not from git

# exactly what would ship, without publishing npm pack --dry-run --json | jq -r '.[0].files[].path' # the usual suspects npm pack --dry-run --json | jq -r '.[0].files[].path' \ | grep -E '(^|/)\.env|\.map$|\.pem$|id_rsa|\.npmrc|coverage/' 

The two traps behind most npm leaks: adding a .npmignore makes npm stop reading .gitignore (the .npmignore trap), and a "files": ["dist"] allowlist ships everything in dist/ — maps, dotfiles, whatever the build dropped there (package.json files, in detail). Per-bundler fixes for source maps are in the source maps guide.

PyPI: the sdist is assembled from your working tree

A wheel ships what your build backend installs. An sdist is the dangerous one: it's assembled from the working tree under MANIFEST.in rules, and a broad graft or recursive-include happily pulls in tests, fixtures, and a .env sitting in the tree. Check both artifacts, not just the wheel:

python -m build tar -tzf dist/*.tar.gz | grep -E '\.env|\.pem|id_rsa|\.pypirc|coverage|\.sqlite' unzip -l dist/*.whl | grep -E '\.env|\.map$|\.pem|id_rsa' # and read contents, not just names — a key in a fixture has an innocent filename mkdir -p /tmp/sdist && tar -xzf dist/*.tar.gz -C /tmp/sdist grep -rE 'AKIA[0-9A-Z]{16}|sk_live_|ghp_[0-9A-Za-z]{36}|-----BEGIN.*PRIVATE KEY' /tmp/sdist 

Fixes: prune in MANIFEST.in (global-exclude *.env*, explicit prune tests/fixtures where you don't ship them), keep package data deliberate instead of include_package_data plus a catch-all graft, and never build a release from a dirty working tree.

Docker: layers never forget

Deleting a file in a later layer does not remove it — anyone can pull the image and extract the earlier layer. The classic sequence:

COPY . . # .env and .git included if .dockerignore is missing/thin RUN ./setup.sh # uses the secrets RUN rm .env # hides them from the final filesystem view only 

.dockerignore is the .npmignore trap in a different uniform: if it doesn't list .env, .git, and your local config, COPY . . ships them. Build-time secrets passed as --build-arg are just as exposed — they show up in the image history. Inspect before you push:

docker history --no-trunc <image> # layer commands, incl. ARG values docker save <image> -o image.tar mkdir layers && tar -xf image.tar -C layers grep -rE 'AKIA[0-9A-Z]{16}|sk_live_|-----BEGIN.*PRIVATE KEY' layers find layers -name '.env' -o -name '*.map' -o -name 'id_rsa' 

Fixes: a real .dockerignore, multi-stage builds so build secrets never reach the final image, and BuildKit secret mounts (--mount=type=secret) instead of build args or copied files.

The 60-second pre-publish checklist

List the artifact Grep the contents
npm npm pack --dry-run --json unpack the tarball, scan every file
PyPI tar -tzf the sdist, unzip -l the wheel grep the unpacked sdist and wheel
Docker docker history --no-trunc docker save, grep every layer

Filename checks catch category 2. Only reading contents catches categories 1, 3 and 5 — which is most of what the audit finds. That's the check ReleaseShield automates: it unpacks the final npm tarball, PyPI wheel/sdist, or Docker image and runs secret patterns and sensitive-file rules over every byte that would ship, and the GitHub Action fails the release job on a critical finding so the check happens on every publish, not just the one where someone remembered. The web checker is free, no login: scan a package or upload an artifact.

If you find something already published: rotate the credential first (mirrors and caches already have the artifact), then ship a clean patch and deprecate the leaky versions. Order matters — the full walkthrough is in published a secret to npm?.

Check any published package before you ship it: scan a package or upload a tarball, free.