Skip to main content
The environment module detects the deployment context from environment variables, CI markers, and hostname patterns. The detected environment is used by the gate pipeline to adjust risk scores — production environments amplify risk while development environments reduce it.

Environment Enum

Classifies the deployment environment into one of four categories.

Import

Values


detect_environment()

Auto-detect the deployment environment using a prioritized detection chain. The ATTESTA_ENV environment variable always takes precedence. Falls back to heuristic detection from CI markers, production variables, and hostname patterns.

Import

Signature

Returns: The detected (or overridden) Environment.

Detection Order

Detection uses a first-match-wins strategy:

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 the ATTESTA_ENV variable to force a specific environment regardless of auto-detection:

Via the @gate Decorator

Override the environment per-gate using the environment parameter:

Via attesta.yaml

Set a default environment in the configuration file:
attesta.yaml
In CI pipelines, the CI environment variable is typically set automatically. Attesta will detect this and apply a 1.0x multiplier (no adjustment). If you want CI to be treated like production for risk scoring, set ATTESTA_ENV=production in your CI configuration.

Risk Scoring

How environment multipliers affect the final risk score

Configuration

Set default environment in attesta.yaml