Prompt

What's the best way to keep database credentials and API keys out of code and CI logs?

Technology / Cybersecurity1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

Best practice is to treat credentials as secrets and keep them out of both source code and build output by using environment variables + a secret manager.

Recommended approach

1) Never hardcode secrets in code

Avoid putting database passwords, API keys, tokens, or private keys in:

  • application source files
  • config files committed to git
  • Dockerfiles
  • CI YAML
  • shell scripts

2) Inject secrets at runtime

Use one of these:

  • Environment variables for local dev and simple deployments
  • Secret manager for production and CI/CD

Examples of secret managers:

  • AWS Secrets Manager / SSM Parameter Store
  • Azure Key Vault
  • Google Secret Manager
  • HashiCorp Vault
  • Kubernetes Secrets
  • GitHub Actions Secrets / GitLab CI Variables / CircleCI Contexts

3) Load secrets from the environment in your app

Your app should read values like:

  • DATABASE_URL
  • API_KEY
  • JWT_SECRET

Example pattern:

import os

db_url = os.environ["DATABASE_URL"]
api_key = os.environ["API_KEY"]

4) Keep secrets out of CI logs

In CI:

  • store secrets in the platform’s secret store
  • pass them as masked environment variables
  • never echo them
  • disable verbose/debug output when secrets might appear
  • avoid printing full command lines that include secrets
  • make sure scripts don’t dump environment variables

Also:

  • use secret masking features where available
  • be careful with tools that print config, env, or stack traces
  • avoid command arguments containing secrets, since some systems log them

5) Use .env only for local development

For local dev, a .env file is fine, but:

  • add it to .gitignore
  • commit only .env.example with placeholder values
  • don’t use .env in production unless it’s injected securely by your runtime

6) Rotate and scope credentials

If a secret leaks:

  • rotate it immediately
  • use least privilege
  • use short-lived credentials where possible
  • separate dev/staging/prod credentials

Good workflow

  • Local dev: .env file + .gitignore
  • CI/CD: masked CI secrets or OIDC to fetch temporary credentials
  • Production: secret manager + runtime injection

Extra protections

  • Use OIDC/federated identity instead of long-lived cloud keys in CI when possible
  • Scan repos for leaked secrets with tools like:
    • GitHub secret scanning
    • TruffleHog
    • Gitleaks
  • Set up pre-commit hooks to block accidental commits

Rule of thumb

If a secret is:

  • in code, it can be committed
  • in a command line, it can be logged
  • in a file on disk, it can be copied

So the safest pattern is: store secrets centrally, inject them at runtime, and never print them.

If you want, I can also give you a best-practice setup for GitHub Actions, Docker, or Kubernetes specifically.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.