Skip to content

Security Scanning Cheat Sheet

Verify open source repos and dependencies before use.

Terminal window
# Before cloning: check project health
scorecard --repo=github.com/owner/project
# Before installing: check for malicious packages
guarddog pypi scan requests
guarddog npm scan lodash
# After cloning: comprehensive scan
trivy repo .

Scores repos 0-10 on 16 security checks.

Terminal window
# Install
brew install scorecard
# or: go install github.com/ossf/scorecard/v5/cmd/scorecard@latest
# Scan public repo
scorecard --repo=github.com/owner/project
# Scan with GitHub token (higher rate limits)
export GITHUB_AUTH_TOKEN=ghp_xxx
scorecard --repo=github.com/owner/project
# JSON output for CI
scorecard --repo=github.com/owner/project --format=json
# Check specific checks only
scorecard --repo=github.com/owner/project --checks=Maintained,Vulnerabilities
CheckWhat It Evaluates
MaintainedRecent commits, issue response
VulnerabilitiesKnown CVEs in dependencies
Branch-ProtectionPR reviews, signed commits required
Code-ReviewChanges reviewed before merge
CI-TestsTests run on PRs
SASTStatic analysis in pipeline
Signed-ReleasesCryptographic signatures on releases
Pinned-DependenciesExact versions, not ranges
Security-PolicySECURITY.md exists
FuzzingParticipates in OSS-Fuzz
Token-PermissionsMinimal GitHub Actions permissions
Dependency-Update-ToolDependabot, Renovate configured
Binary-ArtifactsNo compiled binaries in repo
ContributorsMultiple orgs contributing
CII-Best-PracticesCore Infrastructure Initiative badge
PackagingPublished to package registry

Detects typosquatting, obfuscation, data exfiltration.

Terminal window
# Install
pip install guarddog
# Scan before installing
guarddog pypi scan requests
guarddog npm scan lodash
guarddog go scan github.com/gin-gonic/gin
# Scan local package
guarddog pypi verify ./my-package-1.0.0.tar.gz
guarddog npm verify ./package.tgz
# Scan requirements file
guarddog pypi verify requirements.txt
# Output as JSON
guarddog pypi scan requests --output-format=json
CategoryExamples
Code Executionexec(base64.decode(...)), hidden eval
ExfiltrationSending env vars, credentials to remote server
ObfuscationBase64-encoded payloads, steganography
Typosquattingreqeusts, lodasj (misspelled popular packages)
Install HooksMalicious code in setup.py, postinstall
Suspicious MetaEmpty description, single file, bundled binaries

Behavioral analysis with maintainer reputation tracking.

Terminal window
# Install CLI
npm install -g @socketsecurity/cli
# Wrap package managers (scans on install)
alias npm="socket npm"
alias pip="socket pip"
# Scan directory
socket scan .
# Check specific package
socket npm info lodash

Scans repos, containers, IaC, and secrets.

Terminal window
# Install
brew install trivy
# Scan repository
trivy repo .
trivy repo https://github.com/owner/project
# Scan filesystem
trivy fs .
# Scan container image
trivy image python:3.11
trivy image myapp:latest
# Scan IaC (Terraform, CloudFormation, Kubernetes)
trivy config .
# Scan for secrets
trivy fs --scanners secret .
# Filter by severity
trivy repo . --severity HIGH,CRITICAL
# Ignore unfixed vulnerabilities
trivy repo . --ignore-unfixed
# Output formats
trivy repo . --format json --output results.json
trivy repo . --format table # default
trivy repo . --format sarif # for GitHub Security tab

Google-backed, uses call analysis for fewer false positives.

Terminal window
# Install
go install github.com/google/osv-scanner/cmd/osv-scanner@latest
# Scan directory
osv-scanner -r .
# Scan lockfile
osv-scanner --lockfile=package-lock.json
osv-scanner --lockfile=poetry.lock
osv-scanner --lockfile=go.sum
# Scan SBOM
osv-scanner --sbom=sbom.json
# Call analysis (only reachable vulns)
osv-scanner --experimental-call-analysis -r .
# Output formats
osv-scanner -r . --format json
osv-scanner -r . --format markdown

Reachability analysis—flags only vulns your code actually calls.

Terminal window
# Install
brew install safedep/tap/vet
# Scan with policy
vet scan -D .
# Generate SBOM
vet scan -D . --report-sbom=sbom.json
# Filter by reachability
vet scan -D . --filter-reachable
Terminal window
# Go: govulncheck (official, call-path aware)
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
# Python: pip-audit
pip install pip-audit
pip-audit
pip-audit -r requirements.txt
# Node: npm audit
npm audit
npm audit --json
npm audit fix # auto-fix where possible
# Ruby: bundler-audit
gem install bundler-audit
bundle-audit check --update

Fast scanning with 700+ regex patterns.

Terminal window
# Install
brew install gitleaks
# Scan current directory
gitleaks detect
# Scan git history
gitleaks detect --source=. --log-opts="--all"
# Scan specific commits
gitleaks detect --log-opts="HEAD~10..HEAD"
# Pre-commit hook
gitleaks protect --staged
# Baseline (ignore existing secrets)
gitleaks detect --baseline-path=.gitleaks-baseline.json
# Custom config
gitleaks detect --config=.gitleaks.toml
  • AWS access keys and secrets
  • GitHub/GitLab tokens
  • Stripe, Slack, Twilio API keys
  • Database connection strings
  • Private keys (RSA, SSH, PGP)
  • Generic high-entropy strings
Terminal window
# Syft (Anchore)
brew install syft
syft . -o spdx-json > sbom.spdx.json
syft . -o cyclonedx-json > sbom.cdx.json
# Trivy
trivy sbom . --format cyclonedx > sbom.cdx.json
# CycloneDX tools
pip install cyclonedx-bom
cyclonedx-py requirements > sbom.xml
npm install -g @cyclonedx/cyclonedx-npm
cyclonedx-npm --output-file sbom.json
.github/workflows/security.yml
name: Security Scan
on: [push, pull_request]
jobs:
scorecard:
runs-on: ubuntu-latest
steps:
- uses: ossf/scorecard-action@v2
with:
results_file: scorecard.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: scorecard.sarif
trivy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aquasecurity/trivy-action@master
with:
scan-type: fs
severity: HIGH,CRITICAL
exit-code: 1
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
.pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
hooks:
- id: gitleaks
- repo: https://github.com/python-security/guarddog
rev: v1.3.0
hooks:
- id: guarddog
Terminal window
# 1. Check project health
scorecard --repo=github.com/owner/project
# 2. Check for malicious patterns
guarddog pypi scan package-name
# 3. Check known vulnerabilities
osv-scanner --lockfile=requirements.txt
# 4. Review if scores are concerning
# - Scorecard < 5: investigate further
# - GuardDog warnings: read the flagged code
# - Any CRITICAL CVEs: check if patched version exists
TaskCommand
Project health scorescorecard --repo=github.com/o/p
Detect malicious packageguarddog pypi scan pkg
Scan repo for vulnstrivy repo .
Scan containertrivy image name:tag
Scan for secretsgitleaks detect
Go vulnerabilitiesgovulncheck ./...
Python vulnerabilitiespip-audit
Node vulnerabilitiesnpm audit
Generate SBOMsyft . -o cyclonedx-json
Lockfile vulns (any lang)osv-scanner --lockfile=lockfile
ToolStrengthBest For
ScorecardProject health metricsEvaluating before adoption
GuardDogMalicious code detectionCatching supply chain attacks
TrivyBroad coverage (vulns, secrets, IaC)CI/CD scanning
OSV-ScannerCall analysis, low false positivesPrioritizing real risks
VetReachability-awareReducing noise
GitleaksFast secrets scanningPre-commit, history scanning
SocketBehavioral analysisnpm/PyPI deep analysis