Security Scanning Cheat Sheet
Verify open source repos and dependencies before use.
Quick Start
Section titled “Quick Start”# Before cloning: check project healthscorecard --repo=github.com/owner/project
# Before installing: check for malicious packagesguarddog pypi scan requestsguarddog npm scan lodash
# After cloning: comprehensive scantrivy repo .Project Health (OpenSSF Scorecard)
Section titled “Project Health (OpenSSF Scorecard)”Scores repos 0-10 on 16 security checks.
# Installbrew install scorecard# or: go install github.com/ossf/scorecard/v5/cmd/scorecard@latest
# Scan public reposcorecard --repo=github.com/owner/project
# Scan with GitHub token (higher rate limits)export GITHUB_AUTH_TOKEN=ghp_xxxscorecard --repo=github.com/owner/project
# JSON output for CIscorecard --repo=github.com/owner/project --format=json
# Check specific checks onlyscorecard --repo=github.com/owner/project --checks=Maintained,VulnerabilitiesWhat Scorecard Checks
Section titled “What Scorecard Checks”| Check | What It Evaluates |
|---|---|
| Maintained | Recent commits, issue response |
| Vulnerabilities | Known CVEs in dependencies |
| Branch-Protection | PR reviews, signed commits required |
| Code-Review | Changes reviewed before merge |
| CI-Tests | Tests run on PRs |
| SAST | Static analysis in pipeline |
| Signed-Releases | Cryptographic signatures on releases |
| Pinned-Dependencies | Exact versions, not ranges |
| Security-Policy | SECURITY.md exists |
| Fuzzing | Participates in OSS-Fuzz |
| Token-Permissions | Minimal GitHub Actions permissions |
| Dependency-Update-Tool | Dependabot, Renovate configured |
| Binary-Artifacts | No compiled binaries in repo |
| Contributors | Multiple orgs contributing |
| CII-Best-Practices | Core Infrastructure Initiative badge |
| Packaging | Published to package registry |
Malicious Package Detection
Section titled “Malicious Package Detection”GuardDog
Section titled “GuardDog”Detects typosquatting, obfuscation, data exfiltration.
# Installpip install guarddog
# Scan before installingguarddog pypi scan requestsguarddog npm scan lodashguarddog go scan github.com/gin-gonic/gin
# Scan local packageguarddog pypi verify ./my-package-1.0.0.tar.gzguarddog npm verify ./package.tgz
# Scan requirements fileguarddog pypi verify requirements.txt
# Output as JSONguarddog pypi scan requests --output-format=jsonWhat GuardDog Detects
Section titled “What GuardDog Detects”| Category | Examples |
|---|---|
| Code Execution | exec(base64.decode(...)), hidden eval |
| Exfiltration | Sending env vars, credentials to remote server |
| Obfuscation | Base64-encoded payloads, steganography |
| Typosquatting | reqeusts, lodasj (misspelled popular packages) |
| Install Hooks | Malicious code in setup.py, postinstall |
| Suspicious Meta | Empty description, single file, bundled binaries |
Socket
Section titled “Socket”Behavioral analysis with maintainer reputation tracking.
# Install CLInpm install -g @socketsecurity/cli
# Wrap package managers (scans on install)alias npm="socket npm"alias pip="socket pip"
# Scan directorysocket scan .
# Check specific packagesocket npm info lodashVulnerability Scanning
Section titled “Vulnerability Scanning”Trivy (All-in-One)
Section titled “Trivy (All-in-One)”Scans repos, containers, IaC, and secrets.
# Installbrew install trivy
# Scan repositorytrivy repo .trivy repo https://github.com/owner/project
# Scan filesystemtrivy fs .
# Scan container imagetrivy image python:3.11trivy image myapp:latest
# Scan IaC (Terraform, CloudFormation, Kubernetes)trivy config .
# Scan for secretstrivy fs --scanners secret .
# Filter by severitytrivy repo . --severity HIGH,CRITICAL
# Ignore unfixed vulnerabilitiestrivy repo . --ignore-unfixed
# Output formatstrivy repo . --format json --output results.jsontrivy repo . --format table # defaulttrivy repo . --format sarif # for GitHub Security tabOSV-Scanner
Section titled “OSV-Scanner”Google-backed, uses call analysis for fewer false positives.
# Installgo install github.com/google/osv-scanner/cmd/osv-scanner@latest
# Scan directoryosv-scanner -r .
# Scan lockfileosv-scanner --lockfile=package-lock.jsonosv-scanner --lockfile=poetry.lockosv-scanner --lockfile=go.sum
# Scan SBOMosv-scanner --sbom=sbom.json
# Call analysis (only reachable vulns)osv-scanner --experimental-call-analysis -r .
# Output formatsosv-scanner -r . --format jsonosv-scanner -r . --format markdownSafeDep Vet
Section titled “SafeDep Vet”Reachability analysis—flags only vulns your code actually calls.
# Installbrew install safedep/tap/vet
# Scan with policyvet scan -D .
# Generate SBOMvet scan -D . --report-sbom=sbom.json
# Filter by reachabilityvet scan -D . --filter-reachableLanguage-Specific
Section titled “Language-Specific”# Go: govulncheck (official, call-path aware)go install golang.org/x/vuln/cmd/govulncheck@latestgovulncheck ./...
# Python: pip-auditpip install pip-auditpip-auditpip-audit -r requirements.txt
# Node: npm auditnpm auditnpm audit --jsonnpm audit fix # auto-fix where possible
# Ruby: bundler-auditgem install bundler-auditbundle-audit check --updateSecrets Detection
Section titled “Secrets Detection”Gitleaks
Section titled “Gitleaks”Fast scanning with 700+ regex patterns.
# Installbrew install gitleaks
# Scan current directorygitleaks detect
# Scan git historygitleaks detect --source=. --log-opts="--all"
# Scan specific commitsgitleaks detect --log-opts="HEAD~10..HEAD"
# Pre-commit hookgitleaks protect --staged
# Baseline (ignore existing secrets)gitleaks detect --baseline-path=.gitleaks-baseline.json
# Custom configgitleaks detect --config=.gitleaks.tomlCommon Patterns Detected
Section titled “Common Patterns Detected”- 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
SBOM Generation
Section titled “SBOM Generation”# Syft (Anchore)brew install syftsyft . -o spdx-json > sbom.spdx.jsonsyft . -o cyclonedx-json > sbom.cdx.json
# Trivytrivy sbom . --format cyclonedx > sbom.cdx.json
# CycloneDX toolspip install cyclonedx-bomcyclonedx-py requirements > sbom.xml
npm install -g @cyclonedx/cyclonedx-npmcyclonedx-npm --output-file sbom.jsonCI/CD Integration
Section titled “CI/CD Integration”GitHub Actions
Section titled “GitHub Actions”name: Security Scanon: [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@v2Pre-commit Hooks
Section titled “Pre-commit Hooks”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: guarddogWorkflow: Evaluating a New Dependency
Section titled “Workflow: Evaluating a New Dependency”# 1. Check project healthscorecard --repo=github.com/owner/project
# 2. Check for malicious patternsguarddog pypi scan package-name
# 3. Check known vulnerabilitiesosv-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 existsQuick Reference
Section titled “Quick Reference”| Task | Command |
|---|---|
| Project health score | scorecard --repo=github.com/o/p |
| Detect malicious package | guarddog pypi scan pkg |
| Scan repo for vulns | trivy repo . |
| Scan container | trivy image name:tag |
| Scan for secrets | gitleaks detect |
| Go vulnerabilities | govulncheck ./... |
| Python vulnerabilities | pip-audit |
| Node vulnerabilities | npm audit |
| Generate SBOM | syft . -o cyclonedx-json |
| Lockfile vulns (any lang) | osv-scanner --lockfile=lockfile |
Tool Comparison
Section titled “Tool Comparison”| Tool | Strength | Best For |
|---|---|---|
| Scorecard | Project health metrics | Evaluating before adoption |
| GuardDog | Malicious code detection | Catching supply chain attacks |
| Trivy | Broad coverage (vulns, secrets, IaC) | CI/CD scanning |
| OSV-Scanner | Call analysis, low false positives | Prioritizing real risks |
| Vet | Reachability-aware | Reducing noise |
| Gitleaks | Fast secrets scanning | Pre-commit, history scanning |
| Socket | Behavioral analysis | npm/PyPI deep analysis |
See Also
Section titled “See Also”- Cryptography — Hashing, encryption, and TLS commands
- Cryptography Lesson Plan — Key management and common mistakes
- CI/CD
- Security Lesson Plan