tripwire-py 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tripwire/__init__.py +45 -0
- tripwire/branding.py +111 -0
- tripwire/cli.py +1453 -0
- tripwire/config.py +322 -0
- tripwire/core.py +356 -0
- tripwire/exceptions.py +220 -0
- tripwire/git_audit.py +644 -0
- tripwire/parser.py +447 -0
- tripwire/py.typed +0 -0
- tripwire/scanner.py +358 -0
- tripwire/secrets.py +962 -0
- tripwire/validation.py +562 -0
- tripwire_py-0.2.0.dist-info/METADATA +1113 -0
- tripwire_py-0.2.0.dist-info/RECORD +17 -0
- tripwire_py-0.2.0.dist-info/WHEEL +4 -0
- tripwire_py-0.2.0.dist-info/entry_points.txt +2 -0
- tripwire_py-0.2.0.dist-info/licenses/LICENSE +21 -0
tripwire/__init__.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""TripWire - Catch config errors before they explode.
|
|
2
|
+
|
|
3
|
+
TripWire provides import-time validation of environment variables with type safety,
|
|
4
|
+
format validation, secret detection, and git audit capabilities.
|
|
5
|
+
|
|
6
|
+
Basic usage:
|
|
7
|
+
>>> from tripwire import env
|
|
8
|
+
>>> API_KEY = env.require("API_KEY")
|
|
9
|
+
>>> DEBUG = env.optional("DEBUG", default=False, type=bool)
|
|
10
|
+
|
|
11
|
+
Advanced usage:
|
|
12
|
+
>>> from tripwire import TripWire
|
|
13
|
+
>>> custom_env = TripWire(env_file=".env.production")
|
|
14
|
+
>>> db_url = custom_env.require("DATABASE_URL", format="postgresql")
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from tripwire.core import TripWire, env
|
|
18
|
+
from tripwire.exceptions import (
|
|
19
|
+
DriftError,
|
|
20
|
+
EnvFileNotFoundError,
|
|
21
|
+
MissingVariableError,
|
|
22
|
+
SecretDetectedError,
|
|
23
|
+
TripWireError,
|
|
24
|
+
TypeCoercionError,
|
|
25
|
+
ValidationError,
|
|
26
|
+
)
|
|
27
|
+
from tripwire.validation import validator
|
|
28
|
+
|
|
29
|
+
__version__ = "0.2.0"
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
# Core
|
|
33
|
+
"TripWire",
|
|
34
|
+
"env",
|
|
35
|
+
# Exceptions
|
|
36
|
+
"TripWireError",
|
|
37
|
+
"MissingVariableError",
|
|
38
|
+
"ValidationError",
|
|
39
|
+
"TypeCoercionError",
|
|
40
|
+
"EnvFileNotFoundError",
|
|
41
|
+
"SecretDetectedError",
|
|
42
|
+
"DriftError",
|
|
43
|
+
# Utilities
|
|
44
|
+
"validator",
|
|
45
|
+
]
|
tripwire/branding.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Branding and visual identity for TripWire.
|
|
2
|
+
|
|
3
|
+
This module provides ASCII art logos, color codes, and status indicators
|
|
4
|
+
for consistent branding across CLI, documentation, and terminal output.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
# ANSI color codes for terminal output
|
|
8
|
+
COLORS = {
|
|
9
|
+
"valid": "\033[32m", # Green
|
|
10
|
+
"invalid": "\033[31m", # Red
|
|
11
|
+
"warning": "\033[33m", # Yellow/Amber
|
|
12
|
+
"neutral": "\033[90m", # Grey
|
|
13
|
+
"reset": "\033[0m", # Reset
|
|
14
|
+
"bold": "\033[1m", # Bold
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Brand colors (hex codes for web/documentation)
|
|
18
|
+
BRAND_COLORS = {
|
|
19
|
+
"valid_green": "#2E7D32",
|
|
20
|
+
"error_red": "#C62828",
|
|
21
|
+
"warning_amber": "#FFC107",
|
|
22
|
+
"neutral_grey": "#455A64",
|
|
23
|
+
"bg_light": "#FAFAFA",
|
|
24
|
+
"bg_dark": "#121212",
|
|
25
|
+
"text_light": "#212121",
|
|
26
|
+
"text_dark": "#E0E0E0",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_status_icon(state: str = "neutral", colored: bool = True, rich_markup: bool = True) -> str:
|
|
31
|
+
"""Get status icon for terminal output.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
state: One of "valid", "invalid", "warning", "neutral"
|
|
35
|
+
colored: If True, use colors; if False, monochrome
|
|
36
|
+
rich_markup: If True, use Rich markup format; if False, use ANSI codes
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Formatted status icon string
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
>>> get_status_icon("valid", rich_markup=True)
|
|
43
|
+
'━━[green](✓)[/green]━━'
|
|
44
|
+
>>> get_status_icon("invalid", colored=False)
|
|
45
|
+
'━━(✗)━━'
|
|
46
|
+
"""
|
|
47
|
+
symbols = {
|
|
48
|
+
"valid": "✓",
|
|
49
|
+
"invalid": "✗",
|
|
50
|
+
"warning": "!",
|
|
51
|
+
"neutral": "○",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Rich color names
|
|
55
|
+
rich_colors = {
|
|
56
|
+
"valid": "green",
|
|
57
|
+
"invalid": "red",
|
|
58
|
+
"warning": "yellow",
|
|
59
|
+
"neutral": "bright_black",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
symbol = symbols.get(state, symbols["neutral"])
|
|
63
|
+
|
|
64
|
+
if not colored:
|
|
65
|
+
return f"━━({symbol})━━"
|
|
66
|
+
|
|
67
|
+
if rich_markup:
|
|
68
|
+
# Use Rich markup format for console.print()
|
|
69
|
+
color = rich_colors.get(state, rich_colors["neutral"])
|
|
70
|
+
return f"━━[{color}]({symbol})[/{color}]━━"
|
|
71
|
+
else:
|
|
72
|
+
# Use ANSI codes for direct print()
|
|
73
|
+
color = COLORS.get(state, COLORS["neutral"])
|
|
74
|
+
reset = COLORS["reset"]
|
|
75
|
+
return f"━━{color}({symbol}){reset}━━"
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# ASCII art logo banner
|
|
79
|
+
LOGO_BANNER = """
|
|
80
|
+
╔══════════════════════════╗
|
|
81
|
+
║ ━━━━━(○)━━━━━ ║
|
|
82
|
+
║ ║
|
|
83
|
+
║ T R I P W I R E ║
|
|
84
|
+
║ ║
|
|
85
|
+
║ Config validation ║
|
|
86
|
+
║ that fails fast ║
|
|
87
|
+
╚══════════════════════════╝
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
LOGO_SIMPLE = "━━(○)━━ tripwire"
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def print_banner() -> None:
|
|
94
|
+
"""Print the TripWire ASCII art banner."""
|
|
95
|
+
print(LOGO_BANNER)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def print_status(message: str, state: str = "neutral", colored: bool = True) -> None:
|
|
99
|
+
"""Print a status message with icon.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
message: The message to print
|
|
103
|
+
state: Status state (valid/invalid/warning/neutral)
|
|
104
|
+
colored: Whether to use colors
|
|
105
|
+
|
|
106
|
+
Example:
|
|
107
|
+
>>> print_status("DATABASE_URL is valid", "valid")
|
|
108
|
+
━━(✓)━━ DATABASE_URL is valid
|
|
109
|
+
"""
|
|
110
|
+
icon = get_status_icon(state, colored)
|
|
111
|
+
print(f"{icon} {message}")
|