Cheat Sheets

Three dense quick references by persona—daily developer CI workflows, platform deploy/promote operations, and security scanning plus policy-as-code commands. Use Copy sheet for plain text or persona filters to focus one role.

developer devops security Cosign Trivy

Developer Cheat Sheet

Local workflows, PR feedback, security scans before push, Helm/Kustomize dry-runs. Chapters: CI Pipelines, Source Control.

developer

Daily pipeline & git commands

TaskCommandNotes
Run tests locallymake testMirror CI target
Lint before pushpre-commit run --all-filesSame rules as pipeline
Debug CI locallyact -j buildGitHub Actions emulator
Check PR CI statusgh pr checks 1842Requires gh CLI auth
View workflow runsgh run list --workflow=ci.ymlFilter: --branch=feature/x
Re-run failed jobsgh run rerun RUN_ID --failedAfter fixing infra flake
Clone with depthgit clone --depth=1Faster CI checkout
Signed commitgit commit -S -m 'fix: auth'GPG or SSH sig
View SARIF in PROpen Security tabGitHub code scanning
Cosign verify imagecosign verify --certificate-oidc-issuer REGISTRY_IMAGE:tagBefore deploy
Trivy scan locallytrivy image --severity HIGH,CRITICAL myapp:devCatch before push
Semgrep localsemgrep scan --config=autoSAST in IDE terminal
Check secret leakgitleaks detect --source .Pre-commit hook
Helm template dry-runhelm template api ./chart -f values-staging.yamlRender without cluster
Kustomize buildkubectl kustomize overlays/stagingValidate overlays
Port-forward stagingkubectl port-forward svc/api 8080:80 -n stagingDebug without ingress
Fetch pod logskubectl logs -f deploy/api -n staging --tail=200Since deploy
Exec debug shellkubectl exec -it deploy/api -n staging -- /bin/shEphemeral debug
Diff cluster vs gitargocd app diff api-stagingDrift before merge
Trigger review appgh pr create --fillOpens PR → CI deploys preview

Environment variables (twelve-factor)

TaskCommandNotes
ENVLOG_LEVEL=debugNon-secret config
DATABASE_URLvault://secret/dev/dbNever in .env committed
FEATURE_XtruePrefer feature flag service
OTEL_SERVICE_NAMEapiTracing resource attr
CI=trueset by runnerDetect CI in scripts

Pre-commit hook (.pre-commit-config.yaml)

repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.18.4
    hooks:
      - id: gitleaks
  - repo: https://github.com/returntocorp/semgrep
    rev: v1.72.0
    hooks:
      - id: semgrep
        args: ['--config', 'p/ci', '--error']
  - repo: local
    hooks:
      - id: unit-tests
        name: unit tests
        entry: make test
        language: system
        pass_filenames: false

Makefile targets (CI parity)

.PHONY: test lint scan build
test:
	pytest -q --tb=short
lint:
	ruff check . && ruff format --check .
scan:
	trivy fs --severity HIGH,CRITICAL .
build:
	docker build -t $(APP):$(GIT_SHA) .
💡 Tip

Run make lint test scan before every push. If local passes, CI failure is infra—not your code.

DevOps / Platform Cheat Sheet

Deploy, promote, rollback, GitOps sync, pipeline metrics, registry operations. Chapters: Deployment, Environments.

devops

CI/CD & deploy operations

TaskCommandNotes
List workflowsgh workflow listGitHub
Dispatch workflowgh workflow run promote.yml -f image_digest=sha256:abcManual promote
GitLab pipelineglab ci viewLive pipeline status
Retry GitLab jobglab ci retry JOB_IDAfter runner recovery
Push to ECRaws ecr get-login-password | docker login …OIDC preferred in CI
Sign imagecosign sign --yes IMAGE@DIGESTKeyless with Fulcio
Copy image cross-accountcrane copy SRC DSTPromotion between registries
Helm upgradehelm upgrade --install api ./chart -n prod -f values-prod.yaml --atomicRollback on failure
Helm rollbackhelm rollback api 41 -n prodPrevious revision
ArgoCD syncargocd app sync api-prod --pruneGitOps deploy
ArgoCD rollbackargocd app rollback api-prod 12To previous git revision
Kubectl rollout statuskubectl rollout status deploy/api -n prod --timeout=300sWait for deploy
Drain nodekubectl drain NODE --ignore-daemonsets --delete-emptydir-dataPre-upgrade
Apply Kyverno policykubectl apply -f policies/verify-images.yamlAdmission verify
Terraform plan in CIterraform plan -out=plan.tfplanPR comment with summary
Atlantis applyatlantis apply -p prodAfter approved PR
Vault login OIDCvault login -method=oidcHuman break-glass
ESO refresh secretkubectl annotate es api-db force-sync=$(date +%s)Force ExternalSecret sync
Pushgateway metricecho 'ci_build_duration_seconds 142' | curl --data-binary @- PUSHGATEWAY/metrics/job/ciPipeline metrics
Promote GitLab envglab ci run --branch main deploy:productionManual prod job

Promotion one-liner (digest pin)

# Promote verified digest to prod overlay
DIGEST=sha256:abc123...
yq -i ".image.digest = \"$DIGEST\"" deploy/overlays/prod/values.yaml
git commit -am "promote: $DIGEST" && git push
argocd app sync api-prod --timeout 600

Pipeline failure triage

Stage redFirst commandCommon fix
lintRun linter locallyAuto-format, commit fix
unit testpytest -k failing_testFix or quarantine flake
SASTsemgrep --config=ruleidFix or document waiver
container scantrivy image IMAGEBase image upgrade
deploykubectl describe pod -n nsImagePullBackOff, OOM, probe
policykyverno policy report -n nsMissing signature, resource limit
🔬 Under the Hood

helm upgrade --atomic rolls back automatically if hooks or readiness fail—use on prod to avoid half-upgraded releases.

Security Engineer Cheat Sheet

SAST, SCA, secret scanning, image signing, policy-as-code, runtime checks. Chapters: Security Scanning, Policy as Code.

security

Scanning & supply chain commands

TaskCommandNotes
Trivy fs scantrivy fs --scanners vuln,secret,misconfig .Repo + IaC
Trivy image CI gatetrivy image --exit-code 1 --severity CRITICAL,HIGH IMAGEBlock pipeline
Grype SBOM scangrype sbom:./sbom.jsonFrom Syft SBOM
Syft generate SBOMsyft packages IMAGE -o spdx-json > sbom.jsonAttach to release
Semgrep CIsemgrep ci --config p/ciPR blocking rules
Gitleaks historygitleaks detect --source . --log-opts='--all'Full git history
Conftest K8sconftest test -p policy/ deploy.yamlOPA/Rego policies
Cosign verify policycosign verify --certificate-identity-regexp .* IMAGESigstore
SLSA provenanceslsa-verifier verify-artifact ARTIFACT --provenance-path provenance.intoto.jsonlSupply chain
OPA evalopa eval -d policy.rego 'data.kubernetes.admission.deny'Test Rego locally
Kyverno testkyverno test ./tests/Policy unit tests
Checkov IaCcheckov -d terraform/Terraform misconfig
tfsectfsec terraform/Alternative IaC scanner
Falco alertkubectl logs -n falco -l app=falcoRuntime threats
Network policy testkubectl run test --rm -it --image=nicolaka/netshoot -- curl targetVerify deny
RBAC auditkubectl auth can-i --list --as=system:serviceaccount:prod:apiSA permissions
SAST SARIF uploadgh api repos/OWNER/REPO/code-scanning/sarifs -f [email protected]GitHub Security
Dependency reviewgh api dependency-graph/snapshotsTransitive vulns
Vault policy writevault policy write ci-read - <Least privilege CI
Rotate leaked secret1. Revoke 2. Rotate in vault 3. gitleaks allowlist false positiveIncident playbook

Kyverno verifyImages policy

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-signed-images
spec:
  validationFailureAction: Enforce
  rules:
    - name: verify-cosign
      match:
        any:
          - resources:
              kinds: [Pod]
      verifyImages:
        - imageReferences: ["123456789012.dkr.ecr.us-east-1.amazonaws.com/*"]
          attestors:
            - entries:
                - keyless:
                    subject: "https://github.com/org/repo/.github/workflows/*"
                    issuer: "https://token.actions.githubusercontent.com"

Severity response matrix

SeveritySLAPipeline actionException process
Critical24h fix or blockFail build (--exit-code 1)CISO waiver + ticket
High7 daysWarn + Jira auto-createRisk acceptance doc
Medium30 daysReport onlyBacklog prioritization
Low90 daysSBOM attachNo exception needed
🔒 Security

Never waive Critical findings without expiry date and compensating control documented. Waivers without TTL become permanent vulnerabilities.

GitHub Actions quick flags

Flag / syntaxPurpose
if: always()Run step even when job fails (metrics upload)
needs: [job-a]DAG dependencies between jobs
environment: productionApproval gate + secrets scope
concurrency: group: deployCancel in-progress duplicate deploys
permissions: id-token: writeOIDC for AWS/GCP without static keys

GitLab CI quick reference

# Stages run in order; jobs in same stage parallel
stages: [test, scan, build, deploy]

# Cache between pipelines
cache:
  key: $CI_COMMIT_REF_SLUG
  paths: [node_modules/, .venv/]

# Rules replace only/except
rules:
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

# Protected environments need Maintainer to deploy
deploy:prod:
  environment: production
  when: manual

Supply chain one-liners

TaskCommand
SBOM from imagesyft packages IMAGE -o spdx-json
Attest provenancecosign attest --predicate provenance.json IMAGE
Verify in clusterKyverno verifyImages + cosign keyless
Pin action SHAuses: actions/checkout@b4ffde65... not @v4
🎯 Interview Tip

Memorize the promote flow: build → scan → sign → staging → E2E → manual/auto prod with same digest. Mention cosign verify, SARIF gates, and deployment markers for rollback correlation.

Developer — extended commands

TaskCommandNotes
Install pre-commitpip install pre-commit && pre-commit installHooks run on git commit
Run single hookpre-commit run gitleaks --all-filesDebug one hook
Docker build no cachedocker build --no-cache -t app:test .Reproduce CI image build
Compose up CI paritydocker compose -f compose.ci.yml up --abort-on-container-exitLocal integration
kubectl ctx switchkubectl config use-context stagingAvoid wrong cluster deploy
Watch rolloutkubectl rollout status deploy/api -wWait for preview ready
Helm diffhelm diff upgrade api ./chart -f values.yamlPR review for chart changes
ArgoCD loginargocd login argocd.example.com --ssoGitOps CLI
gh pr viewgh pr view --webOpen PR in browser
git bisect startgit bisect start; git bisect bad; git bisect good v1.2Find breaking commit

DevOps — extended commands

TaskCommandNotes
Terraform fmt checkterraform fmt -check -recursiveCI formatting gate
Terraform validateterraform validateAfter init in CI
Ansible checkansible-playbook site.yml --checkDry-run changes
Pulumi previewpulumi preview --diffPR comment with diff
crane digestcrane digest REGISTRY/image:tagGet sha256 for promotion
cosign downloadcosign download signature IMAGE > sig.blobDebug verify failure
kubectl topkubectl top pods -n prod --sort-by=cpuPost-deploy resource check
stern logsstern api -n prod --since 15mMulti-pod log tail
k9sk9s -n prodInteractive cluster UI
velero backupvelero backup create pre-deploy-$(date +%s) --include-namespaces prodPre-change snapshot

Security — extended commands

TaskCommandNotes
Nuclei scannuclei -u https://staging.example.com -t cves/DAST quick sweep
ZAP baselinedocker run owasp/zap2docker zap-baseline.py -t URLCI DAST gate
Snyk testsnyk test --severity-threshold=highSCA in pipeline
pip-auditpip-audit -r requirements.txtPython dep vulns
npm auditnpm audit --audit-level=highNode dep vulns
dockle lintdockle --exit-code 1 IMAGEDockerfile best practices
hadolinthadolint DockerfileLint Dockerfile in CI
kube-benchkube-bench run --targets nodeCIS K8s benchmark
kube-hunterkube-hunter --remote ARGOCD_URLPassive K8s pentest
Falco rule testfalco --dry-run -r custom-rules.yamlValidate runtime rules

Workflow snippet #1

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Workflow snippet #2

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Workflow snippet #3

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Workflow snippet #4

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Workflow snippet #5

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Workflow snippet #6

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Workflow snippet #7

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Workflow snippet #8

# Emergency prod rollback (GitOps)
git revert HEAD --no-edit && git push
argocd app sync api-prod --prune --timeout 600
kubectl rollout status deploy/api -n production

# Verify cosign signature before deploy
cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com IMAGE@DIGEST

# Export pipeline metrics (Pushgateway)
echo "ci_build_duration_seconds{repo=\"org/api\"} 245" | curl --data-binary @- http://pushgateway:9091/metrics/job/ci

Tooling matrix

ToolCLIPrimary use
GitHub CLIghpr, run, workflow, secret
GitLab CLIglabci, mr, release
Cosigncosignsign, verify, attest
Trivytrivyfs, image, config, sbom
Semgrepsemgrepscan, ci, test
Syftsyftpackages, attest
Grypegrypesbom:, dir:
Gitleaksgitleaksdetect, protect
Checkovcheckov-d terraform/
Conftestconftesttest -p policy/
Kyvernokyvernoapply, test
OPAopaeval, test, run
Helmhelmupgrade, rollback, diff
Kustomizekubectl kustomizebuild overlays/
ArgoCDargocdapp sync, diff, rollback
Terraformterraformplan, apply, import
Cranecranecopy, digest, ls
Sternsternmulti-pod logs
Kubectxkubectxswitch context fast
Vaultvaultkv, login, policy

Dockerfile hardening checklist (1)

RuleDockerfileScanner
Non-root USERUSER 10001Dockle, Trivy config
No secrets in ENVUse runtime injectionGitleaks, Trivy secret
Pinned base digestFROM node@sha256:...Renovate bot
Minimal basedistroless or alpineImage size + CVE count
Multi-stage buildSeparate build and runtimeSmaller attack surface

Dockerfile hardening checklist (2)

RuleDockerfileScanner
Non-root USERUSER 10001Dockle, Trivy config
No secrets in ENVUse runtime injectionGitleaks, Trivy secret
Pinned base digestFROM node@sha256:...Renovate bot
Minimal basedistroless or alpineImage size + CVE count
Multi-stage buildSeparate build and runtimeSmaller attack surface

Dockerfile hardening checklist (3)

RuleDockerfileScanner
Non-root USERUSER 10001Dockle, Trivy config
No secrets in ENVUse runtime injectionGitleaks, Trivy secret
Pinned base digestFROM node@sha256:...Renovate bot
Minimal basedistroless or alpineImage size + CVE count
Multi-stage buildSeparate build and runtimeSmaller attack surface

Dockerfile hardening checklist (4)

RuleDockerfileScanner
Non-root USERUSER 10001Dockle, Trivy config
No secrets in ENVUse runtime injectionGitleaks, Trivy secret
Pinned base digestFROM node@sha256:...Renovate bot
Minimal basedistroless or alpineImage size + CVE count
Multi-stage buildSeparate build and runtimeSmaller attack surface

Dockerfile hardening checklist (5)

RuleDockerfileScanner
Non-root USERUSER 10001Dockle, Trivy config
No secrets in ENVUse runtime injectionGitleaks, Trivy secret
Pinned base digestFROM node@sha256:...Renovate bot
Minimal basedistroless or alpineImage size + CVE count
Multi-stage buildSeparate build and runtimeSmaller attack surface

Dockerfile hardening checklist (6)

RuleDockerfileScanner
Non-root USERUSER 10001Dockle, Trivy config
No secrets in ENVUse runtime injectionGitleaks, Trivy secret
Pinned base digestFROM node@sha256:...Renovate bot
Minimal basedistroless or alpineImage size + CVE count
Multi-stage buildSeparate build and runtimeSmaller attack surface