Environment Enum
Classifies the deployment environment into one of four categories.Import
Values
| Member | Value | Risk Multiplier | Description |
|---|---|---|---|
PRODUCTION | "production" | 1.5x | Live production environment. Risk is amplified. |
STAGING | "staging" | 1.2x | Pre-production staging environment. Slight risk amplification. |
CI | "ci" | 1.0x | Continuous integration environment. No risk adjustment. |
DEVELOPMENT | "development" | 0.8x | Local development environment. Risk is reduced. |
detect_environment()
Auto-detect the deployment environment using a prioritized detection chain. TheATTESTA_ENV environment variable always takes precedence. Falls back to heuristic detection from CI markers, production variables, and hostname patterns.
Import
Signature
Environment.
Detection Order
Detection uses a first-match-wins strategy:| Priority | Method | Details |
|---|---|---|
| 1 | ATTESTA_ENV variable | Explicit override. Set to production, staging, ci, or development. |
| 2 | CI markers | Checks CI, GITHUB_ACTIONS, GITLAB_CI, JENKINS_URL, CIRCLECI, TRAVIS, BUILDKITE. |
| 3 | Production markers | Checks NODE_ENV=production, FLASK_ENV=production, DJANGO_SETTINGS_MODULE containing prod, RAILS_ENV=production. |
| 4 | Hostname patterns | Matches prod-*, prod.* for production; stg-*, stg.*, staging-*, staging.* for staging. |
| 5 | Default | Returns Environment.DEVELOPMENT. |
Example
RISK_MULTIPLIERS
A dictionary mapping environment values to risk score multipliers. Used by the gate pipeline to adjust raw risk scores based on the operational context.Import
Values
Usage
Overriding the Environment
Via Environment Variable
Set theATTESTA_ENV variable to force a specific environment regardless of auto-detection:
Via the @gate Decorator
Override the environment per-gate using theenvironment parameter:
Via attesta.yaml
Set a default environment in the configuration file:attesta.yaml
Risk Scoring
How environment multipliers affect the final risk score
Configuration
Set default environment in attesta.yaml