maproom 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.
- maproom/__init__.py +14 -0
- maproom/__main__.py +10 -0
- maproom/analyze/__init__.py +1 -0
- maproom/analyze/accel_families.py +45 -0
- maproom/analyze/account_azure_activity.py +260 -0
- maproom/analyze/account_azure_quota_requests.py +177 -0
- maproom/analyze/account_cloudtrail.py +316 -0
- maproom/analyze/account_quota_requests.py +180 -0
- maproom/analyze/analyze_v1_orchestration.py +1194 -0
- maproom/analyze/catalog.py +353 -0
- maproom/analyze/change_detection.py +652 -0
- maproom/analyze/context_client.py +99 -0
- maproom/analyze/context_lookup.py +142 -0
- maproom/analyze/cover_analyze.py +344 -0
- maproom/analyze/cover_client.py +65 -0
- maproom/analyze/cover_lookup.py +242 -0
- maproom/analyze/engine.py +644 -0
- maproom/analyze/fleetfit_endpoints.py +217 -0
- maproom/analyze/fleetfit_policy.py +66 -0
- maproom/analyze/instance_price_analyze.py +221 -0
- maproom/analyze/instance_price_client.py +108 -0
- maproom/analyze/instance_price_lookup.py +60 -0
- maproom/analyze/local_reads.py +484 -0
- maproom/analyze/lookup_http.py +280 -0
- maproom/analyze/metric_format.py +20 -0
- maproom/analyze/migration_method.py +130 -0
- maproom/analyze/move_list.py +93 -0
- maproom/analyze/operator_context.py +156 -0
- maproom/analyze/performance_rank.py +97 -0
- maproom/analyze/primary_recommendation.py +422 -0
- maproom/analyze/provider_comparison.py +401 -0
- maproom/analyze/quota_analyze.py +481 -0
- maproom/analyze/quota_client.py +75 -0
- maproom/analyze/quota_lookup.py +110 -0
- maproom/analyze/quota_outcome_steer.py +105 -0
- maproom/analyze/recommend_batch.py +199 -0
- maproom/analyze/recommend_client.py +362 -0
- maproom/analyze/recommend_share.py +118 -0
- maproom/analyze/recommendation.py +591 -0
- maproom/analyze/reservation_pack.py +883 -0
- maproom/analyze/reservation_read.py +461 -0
- maproom/analyze/safe_analyze.py +1134 -0
- maproom/analyze/safe_move.py +195 -0
- maproom/analyze/safe_moves.py +571 -0
- maproom/analyze/safe_moves_catalog.py +127 -0
- maproom/analyze/safe_moves_client.py +70 -0
- maproom/analyze/series_analyze.py +491 -0
- maproom/analyze/series_client.py +106 -0
- maproom/analyze/series_lookup.py +663 -0
- maproom/analyze/shape.py +254 -0
- maproom/analyze/size_analyze.py +883 -0
- maproom/analyze/size_client.py +81 -0
- maproom/analyze/size_keep.py +409 -0
- maproom/analyze/size_lookup.py +368 -0
- maproom/analyze/specs.py +325 -0
- maproom/analyze/spot_analyze.py +392 -0
- maproom/analyze/spot_client.py +74 -0
- maproom/analyze/spot_lookup.py +213 -0
- maproom/analyze/token_client.py +97 -0
- maproom/analyze/utilization.py +190 -0
- maproom/analyze/workload.py +104 -0
- maproom/analyze/workset.py +762 -0
- maproom/aws_region.py +78 -0
- maproom/cache/__init__.py +1 -0
- maproom/cache/catalog.py +372 -0
- maproom/cache/commands.py +215 -0
- maproom/cache/instances.py +460 -0
- maproom/cli.py +2084 -0
- maproom/cli_argv.py +329 -0
- maproom/cli_floors.py +89 -0
- maproom/cliio/__init__.py +1 -0
- maproom/cliio/registry.py +377 -0
- maproom/cliio/runner.py +489 -0
- maproom/consent/__init__.py +33 -0
- maproom/consent/gate.py +238 -0
- maproom/consent/policy.py +20 -0
- maproom/consent/prompt.py +61 -0
- maproom/consent/service_upload_gate.py +318 -0
- maproom/consent/service_upload_prompt.py +62 -0
- maproom/consent/stdin.py +45 -0
- maproom/consent/storage.py +24 -0
- maproom/consent/write_token.py +29 -0
- maproom/contracts/__init__.py +6 -0
- maproom/contracts/schema_diff.py +119 -0
- maproom/contracts/validate.py +113 -0
- maproom/data/__init__.py +1 -0
- maproom/data/clear.py +76 -0
- maproom/data/commands.py +14 -0
- maproom/doctor/__init__.py +1 -0
- maproom/doctor/aws_session.py +226 -0
- maproom/doctor/checks.py +701 -0
- maproom/doctor/context.py +32 -0
- maproom/doctor/display.py +96 -0
- maproom/doctor/inventory_display.py +377 -0
- maproom/doctor/runner.py +1467 -0
- maproom/errors.py +43 -0
- maproom/exitcodes.py +70 -0
- maproom/inventory/__init__.py +1 -0
- maproom/inventory/account_identity.py +79 -0
- maproom/inventory/accounts.py +155 -0
- maproom/inventory/command.py +961 -0
- maproom/inventory/messages.py +264 -0
- maproom/inventory/reservations_refresh.py +37 -0
- maproom/mock_environment/__init__.py +28 -0
- maproom/mock_environment/load.py +241 -0
- maproom/mock_environment/runner.py +387 -0
- maproom/output/__init__.py +1 -0
- maproom/output/json_envelope.py +241 -0
- maproom/output/redact.py +11 -0
- maproom/output/terminal.py +129 -0
- maproom/parsers.py +284 -0
- maproom/paths.py +105 -0
- maproom/plan/__init__.py +1 -0
- maproom/plan/accept.py +59 -0
- maproom/plan/analysis_context.py +78 -0
- maproom/plan/analyze_selection.py +279 -0
- maproom/plan/commands.py +586 -0
- maproom/plan/current.py +59 -0
- maproom/plan/errors.py +10 -0
- maproom/plan/export.py +36 -0
- maproom/plan/formatting.py +91 -0
- maproom/plan/ids.py +13 -0
- maproom/plan/migration_options.py +75 -0
- maproom/plan/model.py +265 -0
- maproom/plan/names.py +24 -0
- maproom/plan/store.py +193 -0
- maproom/plan/tty.py +34 -0
- maproom/pricing/__init__.py +5 -0
- maproom/pricing/prices.py +119 -0
- maproom/privacy/__init__.py +6 -0
- maproom/privacy/commands.py +159 -0
- maproom/privacy/delete_uploads.py +204 -0
- maproom/privacy/fleetfit_policy.py +125 -0
- maproom/privacy/fleetfit_statement.py +104 -0
- maproom/privacy/format.py +76 -0
- maproom/privacy/manifests.py +342 -0
- maproom/privacy/statement.py +58 -0
- maproom/quotas/__init__.py +21 -0
- maproom/quotas/aws.py +204 -0
- maproom/quotas/azure.py +75 -0
- maproom/quotas/commands.py +240 -0
- maproom/quotas/family_coverage.py +122 -0
- maproom/quotas/fetch.py +124 -0
- maproom/quotas/load.py +41 -0
- maproom/quotas/model.py +178 -0
- maproom/quotas/outcome_ledger.py +245 -0
- maproom/quotas/quota_request_sync.py +221 -0
- maproom/quotas/show.py +73 -0
- maproom/quotas/status.py +206 -0
- maproom/quotas/store.py +161 -0
- maproom/redaction.py +157 -0
- maproom/reference_data/__init__.py +1 -0
- maproom/reference_data/aws/aws_prices.csv +25562 -0
- maproom/reference_data/aws/capabilities.csv +1346 -0
- maproom/reference_data/aws/instance_types.csv +1346 -0
- maproom/reference_data/azure/azure_prices.csv +1 -0
- maproom/reference_data/azure/vm_types.csv +1 -0
- maproom/reference_data/benchmarks/cpu-lscpu-v2-instances.json +27 -0
- maproom/reference_data/benchmarks/safe-moves-v1.json +328 -0
- maproom/reference_data/manifest.json +174 -0
- maproom/reference_data/manifest.py +69 -0
- maproom/reservations/__init__.py +17 -0
- maproom/reservations/aws.py +76 -0
- maproom/reservations/azure.py +36 -0
- maproom/reservations/commands.py +149 -0
- maproom/reservations/load.py +41 -0
- maproom/reservations/model.py +316 -0
- maproom/reservations/show.py +64 -0
- maproom/reservations/status.py +181 -0
- maproom/reservations/store.py +391 -0
- maproom/resources.py +54 -0
- maproom/root_help.py +251 -0
- maproom/saving_plans/__init__.py +15 -0
- maproom/saving_plans/aws.py +73 -0
- maproom/saving_plans/commands.py +122 -0
- maproom/saving_plans/load.py +41 -0
- maproom/saving_plans/model.py +101 -0
- maproom/saving_plans/show.py +64 -0
- maproom/saving_plans/status.py +118 -0
- maproom/saving_plans/store.py +173 -0
- maproom/secret_egress_gate.py +108 -0
- maproom/service/install_id.py +60 -0
- maproom/settings/__init__.py +1 -0
- maproom/settings/defaults.py +73 -0
- maproom/settings/init.py +143 -0
- maproom/settings/model.py +105 -0
- maproom/settings/product_version_change.py +343 -0
- maproom/settings/product_versions.py +68 -0
- maproom/settings/set.py +347 -0
- maproom/settings/show.py +227 -0
- maproom/settings/write.py +273 -0
- maproom/snapshot_time.py +27 -0
- maproom-0.2.0.dist-info/METADATA +263 -0
- maproom-0.2.0.dist-info/RECORD +199 -0
- maproom-0.2.0.dist-info/WHEEL +5 -0
- maproom-0.2.0.dist-info/entry_points.txt +2 -0
- maproom-0.2.0.dist-info/licenses/LICENSE +201 -0
- maproom-0.2.0.dist-info/licenses/NOTICE +72 -0
- maproom-0.2.0.dist-info/top_level.txt +1 -0
maproom/redaction.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""Secret egress redaction contract for maproom-cli."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import atexit
|
|
6
|
+
import logging
|
|
7
|
+
import re
|
|
8
|
+
import sys
|
|
9
|
+
import traceback
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
_SENSITIVE_KEY_RE = re.compile(
|
|
13
|
+
r"password|secret|token|credential|api_key|db_url|authorization",
|
|
14
|
+
re.IGNORECASE,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
PATTERNS: tuple[tuple[str, re.Pattern[str], str], ...] = (
|
|
18
|
+
(
|
|
19
|
+
"db_url",
|
|
20
|
+
re.compile(
|
|
21
|
+
r"((?:postgresql|postgres|mysql)(?:\+\w+)?)://([^:@/\s]+):([^@/\s]+)@",
|
|
22
|
+
re.IGNORECASE,
|
|
23
|
+
),
|
|
24
|
+
r"\1://\2:***@",
|
|
25
|
+
),
|
|
26
|
+
(
|
|
27
|
+
"password_eq",
|
|
28
|
+
re.compile(r"password\s*=\s*[^\s'\"\\]+", re.IGNORECASE),
|
|
29
|
+
"password=***",
|
|
30
|
+
),
|
|
31
|
+
(
|
|
32
|
+
"credential_assignment",
|
|
33
|
+
re.compile(
|
|
34
|
+
r"(AWS_SECRET_ACCESS_KEY|AWS_SESSION_TOKEN|AWS_ACCESS_KEY_ID|"
|
|
35
|
+
r"client_secret|AZURE_CLIENT_SECRET)(\s*[=:]\s*)([^\s'\"\\]+)",
|
|
36
|
+
re.IGNORECASE,
|
|
37
|
+
),
|
|
38
|
+
r"\1\2***",
|
|
39
|
+
),
|
|
40
|
+
(
|
|
41
|
+
"akia",
|
|
42
|
+
re.compile(r"AKIA[0-9A-Z]{16}"),
|
|
43
|
+
"AKIA***",
|
|
44
|
+
),
|
|
45
|
+
(
|
|
46
|
+
"presigned",
|
|
47
|
+
re.compile(r"https?://[^\s'\"\\]+(?:X-Amz-|AWSAccessKeyId=)[^\s'\"\\]+"),
|
|
48
|
+
"https://***",
|
|
49
|
+
),
|
|
50
|
+
(
|
|
51
|
+
"authorization_header",
|
|
52
|
+
re.compile(r"(Authorization:\s*)([^\r\n]+)", re.IGNORECASE),
|
|
53
|
+
r"\1***",
|
|
54
|
+
),
|
|
55
|
+
(
|
|
56
|
+
"example_secret_material",
|
|
57
|
+
re.compile(r"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
|
|
58
|
+
"[REDACTED_SECRET]",
|
|
59
|
+
),
|
|
60
|
+
(
|
|
61
|
+
"pem_private_key",
|
|
62
|
+
re.compile(
|
|
63
|
+
r"-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?"
|
|
64
|
+
r"-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----"
|
|
65
|
+
),
|
|
66
|
+
"-----BEGIN PRIVATE KEY----- *** -----END PRIVATE KEY-----",
|
|
67
|
+
),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
_INSTALLED_ATTR = "_maproom_redacting_sinks_installed"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def redact_text(text: str) -> str:
|
|
74
|
+
if not text:
|
|
75
|
+
return text
|
|
76
|
+
redacted = text
|
|
77
|
+
for _name, pattern, replacement in PATTERNS:
|
|
78
|
+
redacted = pattern.sub(replacement, redacted)
|
|
79
|
+
return redacted
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def redact_tree(value: Any) -> Any:
|
|
83
|
+
if isinstance(value, dict):
|
|
84
|
+
return {
|
|
85
|
+
key: ("***" if isinstance(key, str) and _SENSITIVE_KEY_RE.search(key) else redact_tree(item))
|
|
86
|
+
for key, item in value.items()
|
|
87
|
+
}
|
|
88
|
+
if isinstance(value, list):
|
|
89
|
+
return [redact_tree(item) for item in value]
|
|
90
|
+
if isinstance(value, str):
|
|
91
|
+
return redact_text(value)
|
|
92
|
+
return value
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class RedactingTextIO:
|
|
96
|
+
def __init__(self, stream: Any) -> None:
|
|
97
|
+
self._stream = stream
|
|
98
|
+
self._buffer = ""
|
|
99
|
+
atexit.register(self.flush)
|
|
100
|
+
|
|
101
|
+
def flush(self) -> None:
|
|
102
|
+
if getattr(self._stream, "closed", False):
|
|
103
|
+
self._buffer = ""
|
|
104
|
+
return
|
|
105
|
+
if self._buffer:
|
|
106
|
+
self._stream.write(redact_text(self._buffer))
|
|
107
|
+
self._buffer = ""
|
|
108
|
+
self._stream.flush()
|
|
109
|
+
|
|
110
|
+
def write(self, data: str) -> int:
|
|
111
|
+
if not data:
|
|
112
|
+
return len(data)
|
|
113
|
+
self._buffer += data
|
|
114
|
+
while "\n" in self._buffer or "\r" in self._buffer:
|
|
115
|
+
split_at = min(
|
|
116
|
+
index for index in (self._buffer.find("\n"), self._buffer.find("\r")) if index != -1
|
|
117
|
+
)
|
|
118
|
+
line = self._buffer[: split_at + 1]
|
|
119
|
+
self._buffer = self._buffer[split_at + 1 :]
|
|
120
|
+
self._stream.write(redact_text(line))
|
|
121
|
+
return len(data)
|
|
122
|
+
|
|
123
|
+
def __getattr__(self, name: str) -> Any:
|
|
124
|
+
return getattr(self._stream, name)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class RedactingFilter(logging.Filter):
|
|
128
|
+
def filter(self, record: logging.LogRecord) -> bool:
|
|
129
|
+
try:
|
|
130
|
+
record.msg = redact_text(record.getMessage())
|
|
131
|
+
record.args = ()
|
|
132
|
+
except Exception:
|
|
133
|
+
pass
|
|
134
|
+
return True
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def install_redacting_sinks() -> None:
|
|
138
|
+
if getattr(sys, _INSTALLED_ATTR, False):
|
|
139
|
+
return
|
|
140
|
+
if not isinstance(sys.stdout, RedactingTextIO):
|
|
141
|
+
sys.stdout = RedactingTextIO(sys.stdout)
|
|
142
|
+
if not isinstance(sys.stderr, RedactingTextIO):
|
|
143
|
+
sys.stderr = RedactingTextIO(sys.stderr)
|
|
144
|
+
filt = RedactingFilter()
|
|
145
|
+
root = logging.getLogger()
|
|
146
|
+
root.addFilter(filt)
|
|
147
|
+
for handler in root.handlers:
|
|
148
|
+
handler.addFilter(filt)
|
|
149
|
+
previous_hook = sys.excepthook
|
|
150
|
+
|
|
151
|
+
def _hook(exc_type, exc_value, exc_tb) -> None:
|
|
152
|
+
sys.stderr.write(redact_text("".join(traceback.format_exception(exc_type, exc_value, exc_tb))))
|
|
153
|
+
if previous_hook is not sys.__excepthook__:
|
|
154
|
+
previous_hook(exc_type, exc_value, exc_tb)
|
|
155
|
+
|
|
156
|
+
sys.excepthook = _hook
|
|
157
|
+
setattr(sys, _INSTALLED_ATTR, True)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Shipped reference tables under maproom/reference_data/."""
|