elan-cli 0.1.5__tar.gz → 0.1.6__tar.gz
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.
- {elan_cli-0.1.5 → elan_cli-0.1.6}/CHANGELOG.md +19 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/PKG-INFO +1 -1
- {elan_cli-0.1.5 → elan_cli-0.1.6}/pyproject.toml +1 -1
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/main.py +29 -1
- elan_cli-0.1.6/src/elan_cli/scan.py +172 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/.gitignore +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/LICENSE +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/README.md +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/__init__.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/adk.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/auth.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/child.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/client.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/config.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/deploy.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/destroy.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/doctor.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/env.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/files.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/invoke.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/logs.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/manifests.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/project.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/projects.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/prompt.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/rollback.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/scaffold.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/secret.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/stream.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/tenant.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/validate.py +0 -0
- {elan_cli-0.1.5 → elan_cli-0.1.6}/src/elan_cli/wallet.py +0 -0
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
Versions follow the tag that published them — `cli/v*`. A version with no date
|
|
4
4
|
has not been published yet.
|
|
5
5
|
|
|
6
|
+
## 0.1.6 — 2026-11-15
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- **`elan scan` re-scans what your project runs, now.** A deploy checks its image
|
|
10
|
+
once, so a vulnerability published afterwards is found only by checking
|
|
11
|
+
again. For each image it prints the counts by severity and each CRITICAL
|
|
12
|
+
finding, as `elan deploy` does. Anything new since the last scan that would
|
|
13
|
+
refuse a deploy today is listed separately; your organization's admins are
|
|
14
|
+
told about it too. A link to the project's Security page in the console
|
|
15
|
+
follows. If the vulnerability database has not changed since the image's
|
|
16
|
+
last scan, the answer is the same, so it says so and nothing is charged.
|
|
17
|
+
Pass `--project` outside a project directory.
|
|
18
|
+
- **`elan scan schedule` shows or sets how often running images are re-scanned:**
|
|
19
|
+
`off`, `daily`, `weekly` (Sunday), `monthly` (the 1st), or `every <N>` days
|
|
20
|
+
from 1 to 90, for example `elan scan schedule every 14`. It prints the next
|
|
21
|
+
check, the last one and the platform's estimate of scans a month. Re-scans
|
|
22
|
+
are off until you choose a schedule, because each completed one is charged.
|
|
23
|
+
Times are midnight UTC, printed in your own time zone.
|
|
24
|
+
|
|
6
25
|
## 0.1.5 — 2026-11-15
|
|
7
26
|
|
|
8
27
|
### Added
|
|
@@ -37,6 +37,7 @@ from elan_cli import doctor as doctor_cmd
|
|
|
37
37
|
from elan_cli import invoke as invoke_cmd
|
|
38
38
|
from elan_cli import logs as logs_cmd
|
|
39
39
|
from elan_cli import projects as projects_cmd
|
|
40
|
+
from elan_cli import scan as scan_cmd
|
|
40
41
|
from elan_cli.auth import AuthError
|
|
41
42
|
from elan_cli.client import Api, ApiError
|
|
42
43
|
from elan_cli.config import Config, ConfigError
|
|
@@ -62,7 +63,8 @@ from elan_cli.wallet import WalletError
|
|
|
62
63
|
#: subclasses and asserts each one appears here — guilty until named, because a
|
|
63
64
|
#: positive predicate over an open set is a sampling method rather than a guard.
|
|
64
65
|
REFUSALS = (ProjectError, ConfigError, AuthError, ApiError, SecretError,
|
|
65
|
-
WalletError, FilesError, ManifestError, StreamError
|
|
66
|
+
WalletError, FilesError, ManifestError, StreamError,
|
|
67
|
+
scan_cmd.ScanError)
|
|
66
68
|
|
|
67
69
|
|
|
68
70
|
def version_line() -> str:
|
|
@@ -235,6 +237,22 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
235
237
|
status = sub.add_parser("status", help="how a deployment is getting on")
|
|
236
238
|
status.add_argument("deployment_id")
|
|
237
239
|
|
|
240
|
+
# RE-SCANS OF WHAT IS RUNNING (ADR-0240). `--project` IS DECLARED ON BOTH
|
|
241
|
+
# LEVELS UNDER TWO NAMES, because argparse lets a subparser's default
|
|
242
|
+
# overwrite its parent's value: one dest would make
|
|
243
|
+
# `elan scan --project x schedule` forget the `x`.
|
|
244
|
+
scan = sub.add_parser("scan", help="re-scan what this project runs, now")
|
|
245
|
+
scan.add_argument("--project", default="",
|
|
246
|
+
help="defaults to the project in elan.yaml")
|
|
247
|
+
scan_sub = scan.add_subparsers(dest="scan_command")
|
|
248
|
+
scan_schedule = scan_sub.add_parser(
|
|
249
|
+
"schedule", help="show or set how often running images are re-scanned")
|
|
250
|
+
scan_schedule.add_argument(
|
|
251
|
+
"when", nargs="*",
|
|
252
|
+
help="off | daily | weekly | monthly | every <N> (N from 1 to 90 days)")
|
|
253
|
+
scan_schedule.add_argument("--project", dest="schedule_project", default="",
|
|
254
|
+
help="defaults to the project in elan.yaml")
|
|
255
|
+
|
|
238
256
|
# PLATFORM STAFF ONLY, enforced by the service rather than here. A CLI that
|
|
239
257
|
# refused locally would be a second rule to keep in step with the one that
|
|
240
258
|
# actually holds the credential.
|
|
@@ -514,6 +532,16 @@ def _dispatch(args, parser) -> int:
|
|
|
514
532
|
finally:
|
|
515
533
|
api.close()
|
|
516
534
|
|
|
535
|
+
if args.command == "scan":
|
|
536
|
+
api = Api(Config.load())
|
|
537
|
+
try:
|
|
538
|
+
if args.scan_command == "schedule":
|
|
539
|
+
project = scan_cmd.project_of(args.schedule_project or args.project)
|
|
540
|
+
return scan_cmd.schedule(api, project, args.when)
|
|
541
|
+
return scan_cmd.now(api, scan_cmd.project_of(args.project))
|
|
542
|
+
finally:
|
|
543
|
+
api.close()
|
|
544
|
+
|
|
517
545
|
if args.command == "agents":
|
|
518
546
|
config = Config.load()
|
|
519
547
|
api = Api(config)
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""`elan scan`: re-scan what a project runs, and how often that happens by itself.
|
|
2
|
+
|
|
3
|
+
A DEPLOY CHECKS ITS IMAGE ONCE. A vulnerability published the next day is
|
|
4
|
+
found only by checking again — on the project's schedule, or now. Both cost
|
|
5
|
+
the tenant a scan (`security.rescan`), which is why the schedule is off until
|
|
6
|
+
somebody chooses one, and why `elan scan schedule` prints the monthly estimate
|
|
7
|
+
the platform computes beside whatever it sets (ADR-0240).
|
|
8
|
+
|
|
9
|
+
EVERY RULE AND EVERY LINK IS THE PLATFORM'S. What a schedule may be, when it
|
|
10
|
+
next runs and what it is estimated to cost all come back from the API, so this
|
|
11
|
+
package spells no slot rule and no console path that could drift from the
|
|
12
|
+
service's.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from datetime import datetime
|
|
18
|
+
from urllib.parse import quote
|
|
19
|
+
|
|
20
|
+
from elan_cli.client import Api
|
|
21
|
+
from elan_cli.deploy import SEVERITIES, SHOWN
|
|
22
|
+
from elan_cli.project import ProjectError, find
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ScanError(Exception):
|
|
26
|
+
"""A scan command that cannot be sent, already phrased for the developer."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def project_of(explicit: str) -> str:
|
|
30
|
+
"""The project to act in: what was asked for, or what `elan.yaml` says —
|
|
31
|
+
the rule `elan wallet` and `elan deploy` already follow."""
|
|
32
|
+
if explicit.strip():
|
|
33
|
+
return explicit.strip()
|
|
34
|
+
try:
|
|
35
|
+
return find().spec.project
|
|
36
|
+
except ProjectError as exc:
|
|
37
|
+
raise ScanError("which project? run this inside one, or pass --project "
|
|
38
|
+
f"({exc})") from exc
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _path(project: str, tail: str) -> str:
|
|
42
|
+
return f"/v1/projects/{quote(project, safe='')}/{tail}"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _when(iso: str) -> str:
|
|
46
|
+
"""An instant in the reader's own zone, named, so nobody converts in their
|
|
47
|
+
head. The service sends UTC."""
|
|
48
|
+
if not iso:
|
|
49
|
+
return ""
|
|
50
|
+
moment = datetime.fromisoformat(iso.replace("Z", "+00:00")).astimezone()
|
|
51
|
+
return moment.strftime("%Y-%m-%d %H:%M %Z")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def now(api: Api, project: str) -> int:
|
|
55
|
+
"""Scan every image the project runs, now, and say what came back."""
|
|
56
|
+
print(f"scanning what {project} runs…")
|
|
57
|
+
result = api.request("POST", _path(project, "scans"))
|
|
58
|
+
for image in result.get("images") or []:
|
|
59
|
+
_image(image)
|
|
60
|
+
link = (result.get("links") or {}).get("security", "")
|
|
61
|
+
if link:
|
|
62
|
+
print(f"\n full report: {link}")
|
|
63
|
+
# A SCAN THAT COULD NOT BE RECORDED is the service's fault, and a script
|
|
64
|
+
# running this must be able to tell.
|
|
65
|
+
return 1 if result.get("errors") else 0
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _image(image: dict) -> None:
|
|
69
|
+
targets = ", ".join(image.get("targets") or []) or image.get("image_digest", "")
|
|
70
|
+
print(f"\n {targets}")
|
|
71
|
+
if image.get("skipped"):
|
|
72
|
+
print(f" skipped: {image['skipped']}")
|
|
73
|
+
return
|
|
74
|
+
found = image.get("result")
|
|
75
|
+
if not found:
|
|
76
|
+
return
|
|
77
|
+
scan = found.get("scan") or {}
|
|
78
|
+
if found.get("deduped"):
|
|
79
|
+
print(" unchanged: the vulnerability database has not moved since the "
|
|
80
|
+
"last scan, so the answer is the same and this was not charged")
|
|
81
|
+
elif not scan.get("completed"):
|
|
82
|
+
reason = scan.get("incomplete_reason") or "no reason recorded"
|
|
83
|
+
print(f" not scanned: {reason}")
|
|
84
|
+
print(" which is not the same as clean")
|
|
85
|
+
return
|
|
86
|
+
_findings(scan)
|
|
87
|
+
fresh = image.get("newly_blocking") or []
|
|
88
|
+
if fresh:
|
|
89
|
+
print(f" NEW since the last scan, and each would refuse a deploy today "
|
|
90
|
+
f"({len(fresh)}); your organization's admins have been told:")
|
|
91
|
+
for finding in fresh[:SHOWN]:
|
|
92
|
+
print(f" {finding.get('severity')} {finding.get('cve')} "
|
|
93
|
+
f"{finding.get('package')} {finding.get('installed_version')} "
|
|
94
|
+
f"(fixed in {finding.get('fixed_version')})")
|
|
95
|
+
if len(fresh) > SHOWN:
|
|
96
|
+
print(f" … and {len(fresh) - SHOWN} more")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _findings(scan: dict) -> None:
|
|
100
|
+
"""The tally and the CRITICAL findings, as `elan deploy` prints them."""
|
|
101
|
+
findings = scan.get("findings") or []
|
|
102
|
+
if not findings:
|
|
103
|
+
print(" nothing found")
|
|
104
|
+
return
|
|
105
|
+
counts = scan.get("counts") or {}
|
|
106
|
+
tally = ", ".join(f"{counts[name]} {label}"
|
|
107
|
+
for name, label in SEVERITIES.items() if counts.get(name))
|
|
108
|
+
print(f" {len(findings)} findings — {tally}")
|
|
109
|
+
critical = sorted((f for f in findings if f.get("severity") == "CRITICAL"),
|
|
110
|
+
key=lambda f: not f.get("fixable"))
|
|
111
|
+
for finding in critical[:SHOWN]:
|
|
112
|
+
fix = (f"fixed in {finding.get('fixed_version')}" if finding.get("fixable")
|
|
113
|
+
else "no fix available")
|
|
114
|
+
print(f" CRITICAL {finding.get('cve')} {finding.get('package')} "
|
|
115
|
+
f"{finding.get('installed_version')} ({fix})")
|
|
116
|
+
if len(critical) > SHOWN:
|
|
117
|
+
print(f" … and {len(critical) - SHOWN} more critical")
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
#: What `elan scan schedule` accepts, as the reader types it.
|
|
121
|
+
WORDS = ("off", "daily", "weekly", "monthly")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _body(words: list[str]) -> dict:
|
|
125
|
+
"""`["every", "14"]` to the API's body. The NUMBER is the service's to
|
|
126
|
+
judge, so a bad one is refused there, in the service's own words."""
|
|
127
|
+
said = [word.lower() for word in words]
|
|
128
|
+
if said and said[-1] == "days":
|
|
129
|
+
said = said[:-1]
|
|
130
|
+
if len(said) == 1 and said[0] in WORDS:
|
|
131
|
+
return {"schedule": said[0]}
|
|
132
|
+
if said and said[0] == "every":
|
|
133
|
+
if len(said) != 2:
|
|
134
|
+
raise ScanError("say how many days: elan scan schedule every 14")
|
|
135
|
+
return {"schedule": "interval", "interval_days": said[1]}
|
|
136
|
+
raise ScanError("choose one of: off, daily, weekly, monthly, or every <N> "
|
|
137
|
+
"(for example: elan scan schedule every 14)")
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def schedule(api: Api, project: str, words: list[str]) -> int:
|
|
141
|
+
"""Show how often the project's running images are re-scanned, or set it."""
|
|
142
|
+
path = _path(project, "scan-schedule")
|
|
143
|
+
if words:
|
|
144
|
+
view = api.request("PUT", path, json=_body(words))
|
|
145
|
+
print(f"{project}: re-scans set to {view.get('label', '')}")
|
|
146
|
+
else:
|
|
147
|
+
view = api.request("GET", path)
|
|
148
|
+
print(f"{project}: re-scans {view.get('label', '')}")
|
|
149
|
+
_view(view)
|
|
150
|
+
return 0
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _view(view: dict) -> None:
|
|
154
|
+
images = view.get("images", 0)
|
|
155
|
+
if view.get("schedule") == "off":
|
|
156
|
+
print(" next: never — re-scans are off, and nothing is charged for them")
|
|
157
|
+
elif view.get("next_run_is_due"):
|
|
158
|
+
print(" next: due now — the hourly check scans it within the hour")
|
|
159
|
+
elif view.get("next_run"):
|
|
160
|
+
print(f" next: {_when(view['next_run'])} (within the hour after)")
|
|
161
|
+
else:
|
|
162
|
+
print(" next: once something is deployed")
|
|
163
|
+
last = _when(view.get("last_run", ""))
|
|
164
|
+
print(f" last: {last or 'never'}")
|
|
165
|
+
if view.get("schedule") != "off":
|
|
166
|
+
estimate = view.get("estimated_scans_per_month", 0)
|
|
167
|
+
print(f" estimate: about {estimate:g} scans a month "
|
|
168
|
+
f"({images} image{'' if images == 1 else 's'}; one image is one "
|
|
169
|
+
"scan however many agents run it)")
|
|
170
|
+
link = (view.get("links") or {}).get("security", "")
|
|
171
|
+
if link:
|
|
172
|
+
print(f" manage: {link}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|