crimson-crawler-cli 4.1.1__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.
- crimson_crawler_cli/__init__.py +26 -0
- crimson_crawler_cli/__main__.py +13 -0
- crimson_crawler_cli/auth.py +74 -0
- crimson_crawler_cli/cli.py +278 -0
- crimson_crawler_cli/client_factory.py +29 -0
- crimson_crawler_cli/commands/__init__.py +6 -0
- crimson_crawler_cli/commands/_formatters.py +1377 -0
- crimson_crawler_cli/commands/artifact_manager.py +751 -0
- crimson_crawler_cli/commands/assess.py +344 -0
- crimson_crawler_cli/commands/crawl.py +100 -0
- crimson_crawler_cli/commands/enrich.py +669 -0
- crimson_crawler_cli/commands/enrich_artifact.py +204 -0
- crimson_crawler_cli/commands/enrich_inventory.py +159 -0
- crimson_crawler_cli/commands/ingest.py +94 -0
- crimson_crawler_cli/commands/inventory_manager.py +775 -0
- crimson_crawler_cli/commands/reports.py +402 -0
- crimson_crawler_cli/commands/search.py +519 -0
- crimson_crawler_cli/commands/search_techniques.py +43 -0
- crimson_crawler_cli/commands/whoami.py +53 -0
- crimson_crawler_cli/config.py +56 -0
- crimson_crawler_cli/crawl.py +1385 -0
- crimson_crawler_cli/endpoint.py +268 -0
- crimson_crawler_cli/exceptions.py +187 -0
- crimson_crawler_cli/ingest.py +90 -0
- crimson_crawler_cli/inventory.py +356 -0
- crimson_crawler_cli/output.py +144 -0
- crimson_crawler_cli/paths.py +95 -0
- crimson_crawler_cli/playbook.py +160 -0
- crimson_crawler_cli/py.typed +0 -0
- crimson_crawler_cli-4.1.1.dist-info/METADATA +721 -0
- crimson_crawler_cli-4.1.1.dist-info/RECORD +35 -0
- crimson_crawler_cli-4.1.1.dist-info/WHEEL +4 -0
- crimson_crawler_cli-4.1.1.dist-info/entry_points.txt +2 -0
- crimson_crawler_cli-4.1.1.dist-info/licenses/LICENSE +202 -0
- crimson_crawler_cli-4.1.1.dist-info/licenses/NOTICE +14 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Command-line interface for the Crimson Crawler API.
|
|
2
|
+
|
|
3
|
+
The ``ccc`` console script exposes local auth and inventory collection, typed
|
|
4
|
+
enrichment conveniences, scan-to-briefing ingestion, async artifact enrichment,
|
|
5
|
+
and the Artifact Manager, Inventory Manager, and Report Generator command groups.
|
|
6
|
+
Every network call flows through :class:`crimson_crawler_client.CrawlerClient`.
|
|
7
|
+
|
|
8
|
+
Configuration:
|
|
9
|
+
|
|
10
|
+
- ``CRIMSON_CRAWLER_API_KEY`` env var, or ``api_key`` in
|
|
11
|
+
``~/.crimson-crawler/config.toml``. Required.
|
|
12
|
+
|
|
13
|
+
See ``cli`` for the Typer app entry point and ``commands`` for the command
|
|
14
|
+
implementations.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
from importlib.metadata import version as _pkg_version
|
|
21
|
+
|
|
22
|
+
__version__ = _pkg_version("crimson-crawler-cli")
|
|
23
|
+
except Exception: # noqa: BLE001 — fall back when running from source without metadata
|
|
24
|
+
__version__ = "0.0.0+unknown"
|
|
25
|
+
|
|
26
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Allow ``python -m crimson_crawler_cli`` to invoke the same Typer app as ``ccc``.
|
|
2
|
+
|
|
3
|
+
Useful when the console script isn't on PATH (CI containers, broken venv
|
|
4
|
+
activation, debugging). The ``ccc`` entry point in ``pyproject.toml`` remains
|
|
5
|
+
the canonical surface; this just exposes the module form as a fallback.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from .cli import app
|
|
11
|
+
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
app()
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""API-key resolution for the Crimson Crawler CLI.
|
|
2
|
+
|
|
3
|
+
Resolution order:
|
|
4
|
+
|
|
5
|
+
1. ``CRIMSON_CRAWLER_API_KEY`` env var → ``source="env"``.
|
|
6
|
+
2. ``~/.crimson-crawler/config.toml`` ``api_key`` field → ``source="config"``.
|
|
7
|
+
3. Neither → :class:`MissingCredentialsError` (exit code 2).
|
|
8
|
+
|
|
9
|
+
This matches the SDK's env var name on purpose — keys are interchangeable
|
|
10
|
+
between ``ccc`` CLI usage and ``CrawlerClient`` SDK usage.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
from dataclasses import dataclass, field
|
|
17
|
+
from typing import Literal
|
|
18
|
+
|
|
19
|
+
from . import config
|
|
20
|
+
from .exceptions import MissingCredentialsError
|
|
21
|
+
|
|
22
|
+
ENV_API_KEY = "CRIMSON_CRAWLER_API_KEY"
|
|
23
|
+
|
|
24
|
+
AuthSource = Literal["env", "config"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class ResolvedAuth:
|
|
29
|
+
"""The API key plus where it came from. Never log ``key`` directly."""
|
|
30
|
+
|
|
31
|
+
source: AuthSource
|
|
32
|
+
key: str = field(repr=False)
|
|
33
|
+
source_detail: str
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def key_tail(self) -> str:
|
|
37
|
+
"""Last 4 characters of the key. Safe to display."""
|
|
38
|
+
return self.key[-4:] if len(self.key) >= 4 else self.key
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def masked_key(self) -> str:
|
|
42
|
+
"""Key with everything but the last 4 chars replaced by ``•``."""
|
|
43
|
+
if len(self.key) <= 4:
|
|
44
|
+
return self.key
|
|
45
|
+
return "•" * (len(self.key) - 4) + self.key_tail
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def resolve_auth() -> ResolvedAuth:
|
|
49
|
+
"""Return the first available API key, or raise :class:`MissingCredentialsError`."""
|
|
50
|
+
env_value = os.environ.get(ENV_API_KEY)
|
|
51
|
+
if env_value:
|
|
52
|
+
return ResolvedAuth(source="env", key=env_value, source_detail=ENV_API_KEY)
|
|
53
|
+
|
|
54
|
+
loaded = config.load_config_file()
|
|
55
|
+
if loaded is not None:
|
|
56
|
+
key = loaded.get("api_key")
|
|
57
|
+
if isinstance(key, str) and key:
|
|
58
|
+
return ResolvedAuth(
|
|
59
|
+
source="config",
|
|
60
|
+
key=key,
|
|
61
|
+
source_detail=str(config.CONFIG_FILE),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
raise MissingCredentialsError(
|
|
65
|
+
f"No API key found. Set {ENV_API_KEY} or write 'api_key = \"...\"' to {config.CONFIG_FILE}."
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
__all__ = [
|
|
70
|
+
"ENV_API_KEY",
|
|
71
|
+
"AuthSource",
|
|
72
|
+
"ResolvedAuth",
|
|
73
|
+
"resolve_auth",
|
|
74
|
+
]
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"""Typer entry point for the ``ccc`` console script.
|
|
2
|
+
|
|
3
|
+
Registers global flags (``--json``, ``--expand``, ``--version``) and the shipped
|
|
4
|
+
commands. Every ``/v1`` operation is reachable: the ``enrich``, ``search``, and
|
|
5
|
+
``assess`` groups cover the 29 synchronous endpoints, and the two async engines
|
|
6
|
+
(``artifact-enrich``, ``inventory-enrich``) are groups whose callback submits and
|
|
7
|
+
whose ``status ID`` subcommand reads the job back. ``search-techniques`` remains
|
|
8
|
+
as a deprecated top-level alias for ``ccc search techniques``.
|
|
9
|
+
|
|
10
|
+
Every data command also declares :data:`output.JsonFlag` and
|
|
11
|
+
:data:`output.ExpandFlag` so the trailing forms (``ccc enrich cve X --json``,
|
|
12
|
+
``ccc enrich cve X --expand``) work alongside the global prefix forms.
|
|
13
|
+
Command functions are decorated with :func:`handle_errors` (from
|
|
14
|
+
:mod:`exceptions`) which renders :class:`CLIError` subclasses through
|
|
15
|
+
:mod:`output` and exits with ``error.exit_code``.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import Annotated
|
|
22
|
+
|
|
23
|
+
import typer
|
|
24
|
+
|
|
25
|
+
from . import __version__, output
|
|
26
|
+
from .commands import artifact_manager as artifact_manager_cmd
|
|
27
|
+
from .commands import assess as assess_cmd
|
|
28
|
+
from .commands import crawl as crawl_cmd
|
|
29
|
+
from .commands import enrich as enrich_cmd
|
|
30
|
+
from .commands import enrich_artifact as enrich_artifact_cmd
|
|
31
|
+
from .commands import enrich_inventory as enrich_inventory_cmd
|
|
32
|
+
from .commands import ingest as ingest_cmd
|
|
33
|
+
from .commands import inventory_manager as inventory_manager_cmd
|
|
34
|
+
from .commands import reports as reports_cmd
|
|
35
|
+
from .commands import search as search_cmd
|
|
36
|
+
from .commands import search_techniques as search_techniques_cmd
|
|
37
|
+
from .commands import whoami as whoami_cmd
|
|
38
|
+
from .exceptions import ExitCode, handle_errors
|
|
39
|
+
|
|
40
|
+
app = typer.Typer(
|
|
41
|
+
name="ccc",
|
|
42
|
+
help="Command-line interface for the Crimson Crawler API.",
|
|
43
|
+
no_args_is_help=True,
|
|
44
|
+
add_completion=False,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# The two async engines are command groups rather than leaf commands: the group
|
|
48
|
+
# callback IS the submit (so `ccc artifact-enrich --text …` keeps working exactly
|
|
49
|
+
# as it shipped) and `status ID` reads the job back. `invoke_without_command`
|
|
50
|
+
# plus `no_args_is_help=False` is what makes a bare group invocation run the
|
|
51
|
+
# callback instead of printing help.
|
|
52
|
+
artifact_enrich_app = typer.Typer(
|
|
53
|
+
name="artifact-enrich",
|
|
54
|
+
help="Run the async Artifact Enricher engine on free text + files → one graded report.",
|
|
55
|
+
invoke_without_command=True,
|
|
56
|
+
no_args_is_help=False,
|
|
57
|
+
)
|
|
58
|
+
inventory_enrich_app = typer.Typer(
|
|
59
|
+
name="inventory-enrich",
|
|
60
|
+
help="Submit an asset list to the Threat Inventory Enricher engine (see also: ccc ingest).",
|
|
61
|
+
invoke_without_command=True,
|
|
62
|
+
no_args_is_help=False,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
app.add_typer(enrich_cmd.app, name="enrich")
|
|
66
|
+
app.add_typer(search_cmd.app, name="search")
|
|
67
|
+
app.add_typer(assess_cmd.app, name="assess")
|
|
68
|
+
app.add_typer(artifact_enrich_app, name="artifact-enrich")
|
|
69
|
+
app.add_typer(inventory_enrich_app, name="inventory-enrich")
|
|
70
|
+
app.add_typer(artifact_manager_cmd.app, name="artifact-manager")
|
|
71
|
+
app.add_typer(inventory_manager_cmd.app, name="inventory-manager")
|
|
72
|
+
app.add_typer(reports_cmd.app, name="reports")
|
|
73
|
+
app.add_typer(crawl_cmd.app, name="crawl")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _version_callback(value: bool) -> None:
|
|
77
|
+
if value:
|
|
78
|
+
typer.echo(__version__)
|
|
79
|
+
raise typer.Exit(code=ExitCode.OK)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@app.callback()
|
|
83
|
+
def _root(
|
|
84
|
+
json_output: Annotated[
|
|
85
|
+
bool,
|
|
86
|
+
typer.Option(
|
|
87
|
+
"--json",
|
|
88
|
+
help="Emit machine-readable JSON instead of Rich-formatted output.",
|
|
89
|
+
),
|
|
90
|
+
] = False,
|
|
91
|
+
expand: Annotated[
|
|
92
|
+
bool,
|
|
93
|
+
typer.Option(
|
|
94
|
+
"--expand",
|
|
95
|
+
help="Show full, untruncated fields and all sub-table rows (no-op with --json).",
|
|
96
|
+
),
|
|
97
|
+
] = False,
|
|
98
|
+
_version: Annotated[
|
|
99
|
+
bool,
|
|
100
|
+
typer.Option(
|
|
101
|
+
"--version",
|
|
102
|
+
help="Show the CLI version and exit.",
|
|
103
|
+
callback=_version_callback,
|
|
104
|
+
is_eager=True,
|
|
105
|
+
),
|
|
106
|
+
] = False,
|
|
107
|
+
) -> None:
|
|
108
|
+
"""Configure global output flags before dispatching to a subcommand."""
|
|
109
|
+
output.set_json_mode(json_output)
|
|
110
|
+
output.set_expand_mode(expand)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@app.command("whoami", help="Show which API key the CLI will use and where it came from.")
|
|
114
|
+
@handle_errors
|
|
115
|
+
def whoami(_json: output.JsonFlag = False, _expand: output.ExpandFlag = False) -> None:
|
|
116
|
+
"""Resolve auth locally and print the source + masked key tail."""
|
|
117
|
+
whoami_cmd.whoami()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@artifact_enrich_app.callback(invoke_without_command=True)
|
|
121
|
+
@handle_errors
|
|
122
|
+
def artifact_enrich(
|
|
123
|
+
ctx: typer.Context,
|
|
124
|
+
text: Annotated[
|
|
125
|
+
str | None,
|
|
126
|
+
typer.Option("--text", help="Pasted free text to enrich.", show_default=False),
|
|
127
|
+
] = None,
|
|
128
|
+
files: Annotated[
|
|
129
|
+
list[Path] | None,
|
|
130
|
+
typer.Option(
|
|
131
|
+
"--file",
|
|
132
|
+
exists=True,
|
|
133
|
+
dir_okay=False,
|
|
134
|
+
readable=True,
|
|
135
|
+
show_default=False,
|
|
136
|
+
help="Artifact file to upload (repeatable). Read as bytes, base64-encoded.",
|
|
137
|
+
),
|
|
138
|
+
] = None,
|
|
139
|
+
depth: Annotated[
|
|
140
|
+
enrich_artifact_cmd.Depth,
|
|
141
|
+
typer.Option(
|
|
142
|
+
"--depth",
|
|
143
|
+
help="Enrichment depth: fast (minimal include) or full (the engine default).",
|
|
144
|
+
case_sensitive=False,
|
|
145
|
+
),
|
|
146
|
+
] = enrich_artifact_cmd.Depth.full,
|
|
147
|
+
output_path: Annotated[
|
|
148
|
+
Path | None,
|
|
149
|
+
typer.Option("--output", "-o", help="Write the full report JSON to a file instead of summarizing."),
|
|
150
|
+
] = None,
|
|
151
|
+
save: Annotated[
|
|
152
|
+
bool,
|
|
153
|
+
typer.Option("--save", help="Save the finished report into your Artifact Manager library (usage-exempt)."),
|
|
154
|
+
] = False,
|
|
155
|
+
_json: output.JsonFlag = False,
|
|
156
|
+
_expand: output.ExpandFlag = False,
|
|
157
|
+
) -> None:
|
|
158
|
+
"""Submit text + files to the Artifact Enricher engine unless a subcommand was named."""
|
|
159
|
+
if ctx.invoked_subcommand is not None:
|
|
160
|
+
return
|
|
161
|
+
enrich_artifact_cmd.artifact_enrich_command(text=text, files=files, depth=depth, output_path=output_path, save=save)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@artifact_enrich_app.command("status", help="Read one artifact-enrichment job's status and stages.")
|
|
165
|
+
@handle_errors
|
|
166
|
+
def artifact_enrich_status(
|
|
167
|
+
enrichment_id: Annotated[
|
|
168
|
+
str,
|
|
169
|
+
typer.Argument(help="The enrichment id returned by the submit.", show_default=False),
|
|
170
|
+
],
|
|
171
|
+
_json: output.JsonFlag = False,
|
|
172
|
+
_expand: output.ExpandFlag = False,
|
|
173
|
+
) -> None:
|
|
174
|
+
"""Forward to :func:`enrich_artifact_cmd.artifact_enrich_status_command`."""
|
|
175
|
+
enrich_artifact_cmd.artifact_enrich_status_command(enrichment_id)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
@inventory_enrich_app.callback(invoke_without_command=True)
|
|
179
|
+
@handle_errors
|
|
180
|
+
def inventory_enrich(
|
|
181
|
+
ctx: typer.Context,
|
|
182
|
+
items_file: enrich_inventory_cmd.ItemsFileOption = None,
|
|
183
|
+
products: enrich_inventory_cmd.ProductOption = None,
|
|
184
|
+
include: Annotated[
|
|
185
|
+
list[str] | None,
|
|
186
|
+
typer.Option(
|
|
187
|
+
"--include", help="Response layer to include, repeatable (default: the server's).", show_default=False
|
|
188
|
+
),
|
|
189
|
+
] = None,
|
|
190
|
+
attachments_text: Annotated[
|
|
191
|
+
str | None,
|
|
192
|
+
typer.Option(
|
|
193
|
+
"--attachments-text", help="Free text for the engine's artifact-enrichment stage.", show_default=False
|
|
194
|
+
),
|
|
195
|
+
] = None,
|
|
196
|
+
_json: output.JsonFlag = False,
|
|
197
|
+
_expand: output.ExpandFlag = False,
|
|
198
|
+
) -> None:
|
|
199
|
+
"""Submit the asset list to the Threat Inventory Enricher unless a subcommand was named."""
|
|
200
|
+
if ctx.invoked_subcommand is not None:
|
|
201
|
+
return
|
|
202
|
+
enrich_inventory_cmd.inventory_enrich_command(
|
|
203
|
+
items_file=items_file,
|
|
204
|
+
products=products,
|
|
205
|
+
include=include,
|
|
206
|
+
attachments_text=attachments_text,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
@inventory_enrich_app.command("status", help="Read one inventory-enrichment job's status and stages.")
|
|
211
|
+
@handle_errors
|
|
212
|
+
def inventory_enrich_status(
|
|
213
|
+
enrichment_id: Annotated[
|
|
214
|
+
str,
|
|
215
|
+
typer.Argument(help="The enrichment id returned by the submit.", show_default=False),
|
|
216
|
+
],
|
|
217
|
+
_json: output.JsonFlag = False,
|
|
218
|
+
_expand: output.ExpandFlag = False,
|
|
219
|
+
) -> None:
|
|
220
|
+
"""Forward to :func:`enrich_inventory_cmd.inventory_enrich_status_command`."""
|
|
221
|
+
enrich_inventory_cmd.inventory_enrich_status_command(enrichment_id)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@app.command(
|
|
225
|
+
"ingest",
|
|
226
|
+
help="Parse a scan/inventory file (any of 11 formats), enrich the assets, and emit a ranked briefing.",
|
|
227
|
+
)
|
|
228
|
+
@handle_errors
|
|
229
|
+
def ingest(
|
|
230
|
+
scan_format: Annotated[
|
|
231
|
+
str,
|
|
232
|
+
typer.Argument(
|
|
233
|
+
help="Scan/inventory format: json/sbom/csv/nmap/list/grype/trivy/depcheck/nessus/gvm/xlsx.",
|
|
234
|
+
show_default=False,
|
|
235
|
+
),
|
|
236
|
+
],
|
|
237
|
+
scan_file: Annotated[
|
|
238
|
+
Path,
|
|
239
|
+
typer.Argument(
|
|
240
|
+
exists=True,
|
|
241
|
+
dir_okay=False,
|
|
242
|
+
readable=True,
|
|
243
|
+
help="The scan/inventory file to ingest.",
|
|
244
|
+
show_default=False,
|
|
245
|
+
),
|
|
246
|
+
],
|
|
247
|
+
output_path: Annotated[
|
|
248
|
+
Path | None,
|
|
249
|
+
typer.Option("--output", "-o", help="Write the briefing to a file instead of stdout."),
|
|
250
|
+
] = None,
|
|
251
|
+
_json: output.JsonFlag = False,
|
|
252
|
+
_expand: output.ExpandFlag = False,
|
|
253
|
+
) -> None:
|
|
254
|
+
"""Forward to :func:`ingest_cmd.ingest_command`."""
|
|
255
|
+
ingest_cmd.ingest_command(scan_format=scan_format, scan_file=scan_file, output_path=output_path)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
@app.command(
|
|
259
|
+
"search-techniques",
|
|
260
|
+
help="Deprecated — use `ccc search techniques`. Keyword search across the ATT&CK knowledge base.",
|
|
261
|
+
)
|
|
262
|
+
@handle_errors
|
|
263
|
+
def search_techniques(
|
|
264
|
+
keyword: Annotated[str, typer.Argument(help="Search term (e.g. 'credential dumping')", show_default=False)],
|
|
265
|
+
limit: Annotated[
|
|
266
|
+
int,
|
|
267
|
+
typer.Option("--limit", min=1, max=100, help="Maximum number of results to return."),
|
|
268
|
+
] = 20,
|
|
269
|
+
_json: output.JsonFlag = False,
|
|
270
|
+
_expand: output.ExpandFlag = False,
|
|
271
|
+
) -> None:
|
|
272
|
+
"""Forward to :func:`search_techniques_cmd.search_techniques_command`.
|
|
273
|
+
|
|
274
|
+
Deprecated top-level alias for ``ccc search techniques``. It shipped in
|
|
275
|
+
v4.0.0, before the ``search`` group existed, so it stays wired to the same
|
|
276
|
+
implementation — scripts pinned to the old spelling keep working unchanged.
|
|
277
|
+
"""
|
|
278
|
+
search_techniques_cmd.search_techniques_command(keyword, limit=limit)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Factory for the :class:`crimson_crawler_client.CrawlerClient`.
|
|
2
|
+
|
|
3
|
+
Keeping construction in one place lets the test suite mock ``CrawlerClient``
|
|
4
|
+
at a single import path (``crimson_crawler_cli.client_factory.CrawlerClient``)
|
|
5
|
+
regardless of which command imports it.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from crimson_crawler_client import CrawlerClient
|
|
11
|
+
|
|
12
|
+
from .auth import ResolvedAuth
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def build_client(resolved: ResolvedAuth) -> CrawlerClient:
|
|
16
|
+
"""Return a :class:`CrawlerClient` configured with the resolved API key.
|
|
17
|
+
|
|
18
|
+
Honors the SDK's own ``CRIMSON_CRAWLER_BASE_URL`` env-var override —
|
|
19
|
+
the CLI does not expose a separate flag, which keeps the configuration
|
|
20
|
+
surface aligned with the SDK's.
|
|
21
|
+
|
|
22
|
+
``CRIMSON_CRAWLER_VERIFY_SSL`` is also resolved by the SDK itself
|
|
23
|
+
(constructor default ``None`` → env-var fallback) so self-signed-cert
|
|
24
|
+
preview deployments don't need a per-CLI flag either.
|
|
25
|
+
"""
|
|
26
|
+
return CrawlerClient(api_key=resolved.key)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
__all__ = ["CrawlerClient", "build_client"]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Command implementations for the Crimson Crawler CLI.
|
|
2
|
+
|
|
3
|
+
Modules register the local commands, enrichment conveniences, scan ingestion,
|
|
4
|
+
offline inventory crawlers, async Artifact Enricher, and the three Platform
|
|
5
|
+
command groups on :mod:`crimson_crawler_cli.cli`.
|
|
6
|
+
"""
|