Bundle Reference¶
API-level reference for the SecretZero provider bundle framework. For a practical walkthrough, see Extending SecretZero.
BundleManifest¶
BundleManifest
¶
Bases: BaseModel
Manifest describing a SecretZero provider bundle.
A bundle is a pip-installable package that contributes one or more of: a provider class, generator kinds, and target kinds to SecretZero.
Bundles register themselves via Python entry_points under the
secretzero.providers group, and the bundle registry discovers
them automatically at startup.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique bundle identifier (e.g. |
version |
str
|
Semantic version string for the bundle. |
provider_class |
str | None
|
Dotted path to the provider class
( |
generators |
dict[str, str]
|
Mapping of generator kind string to dotted class path. |
targets |
dict[str, str]
|
Mapping of target kind string to dotted class path. |
generator_kinds |
list[str]
|
Optional list of new |
target_kinds |
list[str]
|
Optional list of new |
Source code in src/secretzero/bundles/registry.py
BundleRegistry¶
BundleRegistry
¶
Central registry for provider bundles, generators, targets, and providers.
The registry maps string kind identifiers to their corresponding classes,
enabling the sync engine to look up implementations without hard-coded
if/elif chains.
Built-in generators, targets, and providers are pre-registered at
startup. Third-party bundles are discovered via Python entry_points
(group "secretzero.providers").
Usage::
registry = get_bundle_registry()
generator_class = registry.get_generator_class("random_password")
target_class = registry.get_target_class("github_secret")
provider_class = registry.get_provider_class("aws")
Source code in src/secretzero/bundles/registry.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
__init__()
¶
Initialize an empty bundle registry.
Source code in src/secretzero/bundles/registry.py
register_bundle(manifest)
¶
Register all classes declared in a bundle manifest.
Classes that cannot be imported (e.g. missing optional dependency) are silently skipped for graceful degradation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
BundleManifest
|
The bundle manifest to register. |
required |
Source code in src/secretzero/bundles/registry.py
register_generator(kind, cls)
¶
Directly register a generator class by kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Generator kind identifier (e.g. |
required |
cls
|
type
|
Generator class to register. |
required |
Source code in src/secretzero/bundles/registry.py
register_target(kind, cls)
¶
Directly register a target class by kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Target kind identifier (e.g. |
required |
cls
|
type
|
Target class to register. |
required |
Source code in src/secretzero/bundles/registry.py
register_provider(kind, cls)
¶
Directly register a provider class by kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Provider kind identifier (e.g. |
required |
cls
|
type
|
Provider class to register. |
required |
Source code in src/secretzero/bundles/registry.py
discover_and_register()
¶
Auto-discover installed bundles via Python entry_points.
Iterates over all packages that have registered an entry point
under the "secretzero.providers" group. Each entry point
value must be a :class:BundleManifest instance; others are
silently skipped.
Source code in src/secretzero/bundles/registry.py
get_generator_class(kind)
¶
Return the generator class for kind, or None if unknown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Generator kind string (e.g. |
required |
Returns:
| Type | Description |
|---|---|
type | None
|
Generator class or |
Source code in src/secretzero/bundles/registry.py
get_target_class(kind)
¶
Return the target class for kind, or None if unknown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Target kind string (e.g. |
required |
Returns:
| Type | Description |
|---|---|
type | None
|
Target class or |
Source code in src/secretzero/bundles/registry.py
get_provider_class(kind)
¶
Return the provider class for kind, or None if unknown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Provider kind string (e.g. |
required |
Returns:
| Type | Description |
|---|---|
type | None
|
Provider class or |
Source code in src/secretzero/bundles/registry.py
list_bundles()
¶
Return a sorted list of all registered bundle names.
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted list of bundle name strings. |
list_generator_kinds()
¶
Return a sorted list of all registered generator kind strings.
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted list of generator kind strings. |
list_target_kinds()
¶
Return a sorted list of all registered target kind strings.
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted list of target kind strings. |
list_provider_kinds()
¶
Return a sorted list of all registered provider kind strings.
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted list of provider kind strings. |
get_bundle(name)
¶
Return the manifest for a registered bundle, or None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Bundle name. |
required |
Returns:
| Type | Description |
|---|---|
BundleManifest | None
|
BundleManifest or |
Source code in src/secretzero/bundles/registry.py
validate_bundle_manifest(manifest)
¶
Validate that all dotted paths in a manifest can be resolved.
Checks that each declared class path is importable, inherits from the appropriate base class, and is callable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
BundleManifest
|
The manifest to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of error strings. An empty list means the manifest is valid. |
Source code in src/secretzero/bundles/registry.py
Module-level functions¶
get_bundle_registry()
¶
Return the global :class:BundleRegistry singleton.
On first call the registry is populated with all built-in generators,
targets, and providers, then third-party bundles discovered via
entry_points are registered.
Returns:
| Type | Description |
|---|---|
BundleRegistry
|
Global BundleRegistry instance. |
Source code in src/secretzero/bundles/registry.py
discover_bundles()
¶
Discover all installed provider bundles via entry_points.
Returns:
| Type | Description |
|---|---|
list[BundleManifest]
|
List of :class: |
Source code in src/secretzero/bundles/registry.py
reset_bundle_registry()
¶
Reset the global bundle registry singleton (for testing only).
After calling this, the next call to :func:get_bundle_registry will
create a fresh registry and re-run discovery.
Source code in src/secretzero/bundles/registry.py
Class Loader¶
load_class(dotted_path)
¶
Load a class from a dotted path string.
The path format is 'module.submodule:ClassName', where the colon
separates the importable module path from the attribute name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dotted_path
|
str
|
Dotted path in |
required |
Returns:
| Type | Description |
|---|---|
type
|
The class referenced by the path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the path format is invalid (no colon separator). |
ImportError
|
If the module cannot be imported. |
AttributeError
|
If the class cannot be found in the module. |
Example
cls = load_class("secretzero.generators.static:StaticGenerator") cls.name 'StaticGenerator'
Source code in src/secretzero/bundles/loader.py
load_class_safe(dotted_path)
¶
Load a class from a dotted path string, returning None on failure.
Convenience wrapper around :func:load_class that catches all errors
and returns None instead of raising, enabling graceful degradation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dotted_path
|
str
|
Dotted path in |
required |
Returns:
| Type | Description |
|---|---|
type[Any] | None
|
The class if loading succeeded, or |
Source code in src/secretzero/bundles/loader.py
Base Classes¶
These are the abstract base classes that bundle implementations must subclass.
BaseProvider¶
BaseProvider
¶
Bases: IProviderWithCapabilities
Base class for all providers with capability support.
Source code in src/secretzero/providers/base.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
provider_kind
abstractmethod
property
¶
Return provider type identifier.
Returns:
| Type | Description |
|---|---|
str
|
Provider kind string (e.g., 'vault', 'aws', 'github') |
test_connection()
abstractmethod
¶
Test provider connectivity.
Returns:
| Type | Description |
|---|---|
tuple[bool, str | None]
|
Tuple of (success: bool, error_message: Optional[str]) |
authenticate()
¶
Authenticate with the provider.
Returns:
| Type | Description |
|---|---|
bool
|
True if authentication successful, False otherwise |
Source code in src/secretzero/providers/base.py
is_authenticated()
¶
Check if provider is authenticated.
Returns:
| Type | Description |
|---|---|
bool
|
True if authenticated, False otherwise |
get_supported_targets()
abstractmethod
¶
Get list of supported target types for this provider.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of target type names |
get_capabilities()
classmethod
¶
Declare all capabilities this provider offers.
Default implementation uses introspection to find methods starting with 'generate_', 'retrieve_', 'store_', 'rotate_', or 'delete_'.
Override this method for custom capability declarations.
Returns:
| Type | Description |
|---|---|
ProviderCapabilities
|
ProviderCapabilities describing all methods and their signatures |
Source code in src/secretzero/providers/base.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
get_provider_detail()
classmethod
¶
Return a self-describing detail dict used by CLI providers commands.
The returned dict has keys description, auth_methods,
config, example, target_details — all sourced from
class-level attributes so bundles self-register their docs.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Provider detail dictionary. |
Source code in src/secretzero/providers/base.py
ProviderAuth¶
ProviderAuth
¶
Bases: ABC
Base class for provider authentication.
Source code in src/secretzero/providers/base.py
authenticate()
abstractmethod
¶
Authenticate with the provider.
Returns:
| Type | Description |
|---|---|
bool
|
True if authentication successful, False otherwise |
is_authenticated()
abstractmethod
¶
Check if currently authenticated.
Returns:
| Type | Description |
|---|---|
bool
|
True if authenticated, False otherwise |
get_client()
¶
Get authenticated client for the provider.
Returns:
| Type | Description |
|---|---|
Any
|
Authenticated client instance or None |
get_token_info()
¶
Return information about the current authentication token.
Providers that support token introspection should override this method to return details such as user identity, scopes/permissions, and token type.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with at least: - user: Identity associated with the token - scopes: List of permission scopes granted - token_type: Kind of token (e.g. 'PAT', 'OAuth') |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the provider does not support token introspection. |
Source code in src/secretzero/providers/base.py
BaseGenerator¶
BaseGenerator
¶
Bases: ABC
Abstract base class for secret generators.
Source code in src/secretzero/generators/base.py
generate()
abstractmethod
¶
generate_with_fallback(env_var_name=None, field_description=None)
¶
Generate a secret value with environment variable fallback.
First checks for an environment variable, then falls back to generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_var_name
|
str | None
|
Optional environment variable name to check first |
None
|
field_description
|
str | None
|
Optional field description for context in prompts |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Secret value from environment or generated |
Source code in src/secretzero/generators/base.py
BaseTarget¶
BaseTarget
¶
Bases: ABC
Abstract base class for secret storage targets.
Source code in src/secretzero/targets/base.py
store(secret_name, secret_value)
abstractmethod
¶
Store a secret value in the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret_name
|
str
|
Name/key of the secret |
required |
secret_value
|
str
|
Value to store |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in src/secretzero/targets/base.py
retrieve(secret_name)
abstractmethod
¶
Retrieve a secret value from the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret_name
|
str
|
Name/key of the secret |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Secret value if found, None otherwise |
validate()
¶
Validate that the target is accessible and writable.
Returns:
| Type | Description |
|---|---|
bool
|
Tuple of (success, error_message) |
str | None
|
If successful, error_message is None. |
tuple[bool, str | None]
|
If failed, error_message describes the issue. |
Source code in src/secretzero/targets/base.py
Dotted Path Format¶
All class references in a BundleManifest use the module.path:ClassName format:
secretzero_mycloud.provider:MyCloudProvider
│ │ │
│ │ └── Attribute name within the module
│ └── Submodule
└── Top-level package
The colon (:) separates the importable module path from the class attribute. This is the same format used by Python entry_points.
Entry Points Group¶
Bundles register under the secretzero.providers entry-point group:
# pyproject.toml
[project.entry-points."secretzero.providers"]
mycloud = "secretzero_mycloud:BUNDLE_MANIFEST"
The entry-point name (left side) is informational. The entry-point value (right side) must resolve to a BundleManifest instance.
Built-in Bundle Manifests¶
Each built-in provider exposes a _get_bundle_manifest() factory function that returns its BundleManifest. These are registered by _register_builtin_bundles() during registry initialization rather than via entry_points.
| Provider | Manifest factory |
|---|---|
| AWS | secretzero.providers.aws:_get_bundle_manifest |
| Azure | secretzero.providers.azure:_get_bundle_manifest |
| Vault | secretzero.providers.vault:_get_bundle_manifest |
| GitHub | secretzero.providers.github:_get_bundle_manifest |
| GitLab | secretzero.providers.gitlab:_get_bundle_manifest |
| Jenkins | secretzero.providers.jenkins:_get_bundle_manifest |
| Kubernetes | secretzero.providers.kubernetes:_get_bundle_manifest |
| Ansible Vault | secretzero.providers.ansible_vault:_get_bundle_manifest |
| Infisical | secretzero.providers.infisical:_get_bundle_manifest |