forked from 2233admin/opencli-Razormind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistry.py
More file actions
79 lines (67 loc) · 2.3 KB
/
Copy pathregistry.py
File metadata and controls
79 lines (67 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""Versioned managed-acquisition capabilities backed by real OpenCLI commands."""
from dataclasses import dataclass
OHMYOPENCLI_COMMIT = "73cc60c83586ef2c95469b3b70d6cfc80fa5bc53"
OFFICIAL_SITE_CAPABILITY_COMMIT = "73cc60c83586ef2c95469b3b70d6cfc80fa5bc53"
OPENCLI_VERSION = "1.8.6"
@dataclass(frozen=True)
class CapabilityRegistration:
capability_id: str
capability_version: str
output_schema_version: str
source_commit: str
invocation: dict[str, str]
probe_args: tuple[str, ...]
help_marker: str
route_probe_args: tuple[str, ...]
route_probe_error: str
required_profile_kind: str = "anonymous"
@property
def identity(self) -> tuple[str, str, str]:
return (
self.capability_id,
self.capability_version,
self.output_schema_version,
)
def runtime_identity(self) -> dict[str, str]:
return {
"ohmyopencli_repo_commit": OHMYOPENCLI_COMMIT,
"capability_source_commit": self.source_commit,
"opencli_version": OPENCLI_VERSION,
}
_REGISTRATIONS = (
CapabilityRegistration(
capability_id="official-site.observe",
capability_version="1.0.0",
output_schema_version="1",
source_commit=OFFICIAL_SITE_CAPABILITY_COMMIT,
invocation={
"site": "official-site",
"command": "observe",
"format": "json",
},
probe_args=("official-site", "observe", "--help"),
help_marker="official-site observe",
route_probe_args=(
"official-site",
"observe",
"--url",
"https://example.invalid",
"-f",
"json",
),
route_probe_error="CDP not reachable at http://127.0.0.1:9",
),
)
def list_capability_registrations() -> tuple[CapabilityRegistration, ...]:
"""Return the audited capabilities that Admin is allowed to dispatch."""
return _REGISTRATIONS
def get_capability_registration(
capability_id: str,
capability_version: str,
output_schema_version: str,
) -> CapabilityRegistration | None:
identity = (capability_id, capability_version, output_schema_version)
return next(
(registration for registration in _REGISTRATIONS if registration.identity == identity),
None,
)