codeimprint 0.5.0a27__tar.gz → 0.5.0a30__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.
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/CHANGELOG.md +34 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/PKG-INFO +1 -1
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/pyproject.toml +1 -1
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/__init__.py +1 -1
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/api.py +6 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/cli.py +105 -1
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/.gitignore +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/LICENSE +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/NOTICE +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/README.pypi.md +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint/__init__.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint/__main__.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/__main__.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/chainseal.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/config.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/gitrepo.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/imprint_file.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/linecount.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/ownership.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/project.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/receipt.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/records.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/timestamp.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/transparency.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/trust.py +0 -0
- {codeimprint-0.5.0a27 → codeimprint-0.5.0a30}/src/codeimprint_cli/tsa_roots.py +0 -0
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0a30 — `imprint github link` warns about sealing twice [CIM-BE-44-v1]
|
|
4
|
+
|
|
5
|
+
For engine 0.7.0a35 (works with any engine).
|
|
6
|
+
|
|
7
|
+
- **New warning in `imprint github link`:** when the repository also has
|
|
8
|
+
`.github/workflows/codeimprint.yml`, it says: "This repository also has
|
|
9
|
+
.github/workflows/codeimprint.yml, so each push is sealed twice. Delete that file to use
|
|
10
|
+
the GitHub App only." A warning only: the file is never deleted, and the exit code is
|
|
11
|
+
unchanged.
|
|
12
|
+
- No other change. Tests: `tests/test_github_link.py`.
|
|
13
|
+
|
|
14
|
+
## 0.5.0a29 — `imprint plan` [CIM-BE-43-v1]
|
|
15
|
+
|
|
16
|
+
For engine 0.7.0a34.
|
|
17
|
+
|
|
18
|
+
- **New: `imprint plan`** (read-only): the plan, its status and period end, usage (active
|
|
19
|
+
projects of the plan's limit, with the 80% and 100% alerts, and whether the limit is
|
|
20
|
+
enforced), an open invoice request, an unpaid invoice, and the hub's billing page.
|
|
21
|
+
`--org <ID>` for an organisation you administer, `--json` for the server's answer. Plans
|
|
22
|
+
are bought and changed on the hub, never from the client.
|
|
23
|
+
- No other change. Tests: `tests/test_plan.py`.
|
|
24
|
+
|
|
25
|
+
## 0.5.0a28 — `imprint init` and the GitHub App [CIM-BE-41-v1]
|
|
26
|
+
|
|
27
|
+
For engine 0.7.0a33.
|
|
28
|
+
|
|
29
|
+
- **Changed: `imprint init` adds no CI workflow when the CodeImprint GitHub App already seals
|
|
30
|
+
the repository** (its key is authorised on the project), and says so: "This repository is
|
|
31
|
+
sealed by the GitHub App; no CI workflow added." Anything unknown (not signed in, an older
|
|
32
|
+
engine, no answer, the App not yet authorised) adds the workflow as before.
|
|
33
|
+
- **New: `imprint init --ci`** adds the workflow anyway. `--ci` and `--no-ci` together are
|
|
34
|
+
refused.
|
|
35
|
+
- Tests: `tests/test_repository.py`.
|
|
36
|
+
|
|
3
37
|
## 0.5.0a27 — One project per repository; archiving a duplicate [CIM-BE-40-v1]
|
|
4
38
|
|
|
5
39
|
For engine 0.7.0a32.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: codeimprint
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.0a30
|
|
4
4
|
Summary: CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline.
|
|
5
5
|
Project-URL: Homepage, https://codeimprint.ai
|
|
6
6
|
Project-URL: Hub, https://app.codeimprint.ai
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
# Published on PyPI as `codeimprint`. The import package stays `codeimprint_cli` and the
|
|
7
7
|
# command `imprint`.
|
|
8
8
|
name = "codeimprint"
|
|
9
|
-
version = "0.5.
|
|
9
|
+
version = "0.5.0a30"
|
|
10
10
|
description = "CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline."
|
|
11
11
|
readme = "README.pypi.md"
|
|
12
12
|
license = "Apache-2.0"
|
|
@@ -225,6 +225,12 @@ class Client:
|
|
|
225
225
|
{"project": project, "days": days,
|
|
226
226
|
**({"label": label} if label else {})})
|
|
227
227
|
|
|
228
|
+
def billing_status(self, org_id: str | None = None) -> dict:
|
|
229
|
+
"""The signed-in account's (or an organisation's) plan, status and usage (read-only;
|
|
230
|
+
engine 0.7.0a34+)."""
|
|
231
|
+
path = "/api/v1/me/billing" + (f"?org_id={quote(org_id)}" if org_id else "")
|
|
232
|
+
return self._request("GET", path)
|
|
233
|
+
|
|
228
234
|
def tokens(self) -> list[dict]:
|
|
229
235
|
return self._request("GET", "/api/v1/me/tokens").get("items") or []
|
|
230
236
|
|
|
@@ -583,10 +583,15 @@ def cmd_login(args) -> int:
|
|
|
583
583
|
return 0
|
|
584
584
|
|
|
585
585
|
|
|
586
|
+
APP_SEALS = "This repository is sealed by the GitHub App; no CI workflow added."
|
|
587
|
+
|
|
588
|
+
|
|
586
589
|
def cmd_init(args) -> int:
|
|
587
590
|
root = Path(args.path).resolve()
|
|
588
591
|
if not root.is_dir():
|
|
589
592
|
raise Abort(f"no such folder: {root}")
|
|
593
|
+
if getattr(args, "ci", False) and args.no_ci:
|
|
594
|
+
raise Abort("choose one: --ci adds the build workflow, --no-ci leaves it out")
|
|
590
595
|
cfg_path = root / project.CONFIG_DIR / project.CONFIG_FILE
|
|
591
596
|
existing = project.load_config(root)
|
|
592
597
|
link = getattr(args, "link_origin", False)
|
|
@@ -637,7 +642,11 @@ def cmd_init(args) -> int:
|
|
|
637
642
|
_say(f"updated {cfg_path.relative_to(root).as_posix()} (developer key)")
|
|
638
643
|
else:
|
|
639
644
|
write(cfg_path, json.dumps(cfg, indent=2) + "\n")
|
|
640
|
-
|
|
645
|
+
ci = not args.no_ci
|
|
646
|
+
if ci and not getattr(args, "ci", False) and _app_seals_here(args, root, existing):
|
|
647
|
+
ci = False # every push is sealed already (CIM-BE-41-v1)
|
|
648
|
+
_say(f"skipped CI workflow: {APP_SEALS} (`imprint init --ci` adds it anyway)")
|
|
649
|
+
if ci:
|
|
641
650
|
rel, text, shared = ci_file(root, cfg["fail_above"])
|
|
642
651
|
if shared and (root / rel).exists(): # the repository's one pipeline file
|
|
643
652
|
_say(f"kept {rel} (it is your pipeline: add the CodeImprint job from the "
|
|
@@ -665,6 +674,26 @@ def cmd_init(args) -> int:
|
|
|
665
674
|
return 0
|
|
666
675
|
|
|
667
676
|
|
|
677
|
+
def _app_seals_here(args, root: Path, existing: dict) -> bool:
|
|
678
|
+
"""The CodeImprint GitHub App seals this repository's project with an authorised key,
|
|
679
|
+
so a CI workflow would seal every push twice. Asked of the server for the signed-in
|
|
680
|
+
account's own projects here; anything unknown (no server, not signed in, an engine
|
|
681
|
+
before 0.7.0a33, no answer) counts as no, and the workflow is added as before."""
|
|
682
|
+
ident = _identity(root)
|
|
683
|
+
settings = config.resolve(getattr(args, "url", None))
|
|
684
|
+
if not ident or not settings.url:
|
|
685
|
+
return False
|
|
686
|
+
try:
|
|
687
|
+
client = _signed_in(settings.url, settings.token)
|
|
688
|
+
if client.auth != "session":
|
|
689
|
+
return False
|
|
690
|
+
items = client.own_projects_here(ident)
|
|
691
|
+
except (ApiError, NetworkError, Abort):
|
|
692
|
+
return False
|
|
693
|
+
named = [i for i in items if i["project_id"] == existing.get("project_id")]
|
|
694
|
+
return any(i.get("github_app_seals") for i in (named or items))
|
|
695
|
+
|
|
696
|
+
|
|
668
697
|
def _origin_place(args, root: Path, existing: dict) -> tuple[str, str | None]:
|
|
669
698
|
"""For `imprint init` in a folder whose config already names a project: is this the
|
|
670
699
|
repository that project lives in ("same", "different" or "unknown"), and why the project
|
|
@@ -2272,6 +2301,58 @@ def cmd_key(args) -> int:
|
|
|
2272
2301
|
|
|
2273
2302
|
|
|
2274
2303
|
# -- project names and the GitHub App (CIM-BE-19-v1) ---------------------------------------
|
|
2304
|
+
ALERTS = {"near_limit": "close to your plan's limit",
|
|
2305
|
+
"limit_reached": "your plan's limit is reached"}
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
def cmd_plan(args) -> int:
|
|
2309
|
+
"""`imprint plan`: the plan, its status and usage, read-only. Plans are bought and
|
|
2310
|
+
changed on the hub's billing page, never from here."""
|
|
2311
|
+
sc = _session_client(args)
|
|
2312
|
+
try:
|
|
2313
|
+
s = sc.billing_status(getattr(args, "org", None))
|
|
2314
|
+
except ApiError as exc:
|
|
2315
|
+
if exc.status == 404 and exc.code != "org_not_found":
|
|
2316
|
+
raise Abort(f"{sc.url} has no billing yet (engine 0.7.0a34 or later)") from exc
|
|
2317
|
+
raise Abort(_explain(sc, exc, "could not read the plan")) from exc
|
|
2318
|
+
except NetworkError as exc:
|
|
2319
|
+
raise Abort(f"could not read the plan: {exc}") from exc
|
|
2320
|
+
if getattr(args, "json", False):
|
|
2321
|
+
print(json.dumps(s, indent=2, sort_keys=True))
|
|
2322
|
+
return 0
|
|
2323
|
+
plan, sub, use = s["plan"], s.get("subscription"), s["usage"]
|
|
2324
|
+
limit = f"{plan['projects']} active projects" if plan.get("projects") else "custom limit"
|
|
2325
|
+
line = f"Plan {plan['name']} ({limit})"
|
|
2326
|
+
if sub and sub["plan"] == plan["key"]:
|
|
2327
|
+
until = (sub.get("period_end") or "")[:10]
|
|
2328
|
+
line += f" · {sub['status']}, {sub.get('interval') or 'yearly'}" + (
|
|
2329
|
+
f", until {until}" if until else "")
|
|
2330
|
+
elif sub and sub["status"] in ("pending", "lapsed", "canceled", "past_due"):
|
|
2331
|
+
line += f" · your {sub['plan']} plan is {sub['status']}"
|
|
2332
|
+
lines = [line]
|
|
2333
|
+
if use.get("limit"):
|
|
2334
|
+
usage = (f"Usage {use['active_projects']} of {use['limit']} active projects "
|
|
2335
|
+
f"({use['percent']}%)")
|
|
2336
|
+
if use.get("alert"):
|
|
2337
|
+
usage += f": {ALERTS[use['alert']]}"
|
|
2338
|
+
if not use.get("enforced"):
|
|
2339
|
+
usage += " (shown only: sealing is not limited)"
|
|
2340
|
+
lines.append(usage)
|
|
2341
|
+
else:
|
|
2342
|
+
lines.append(f"Usage {use['active_projects']} active projects")
|
|
2343
|
+
lines.append(" (active: sealed in the last 12 months, not archived)")
|
|
2344
|
+
req = s.get("invoice_request")
|
|
2345
|
+
if req:
|
|
2346
|
+
lines.append(f"Invoice request {req['id']} for {req['plan']} ({req['status']})")
|
|
2347
|
+
inv = s.get("latest_invoice")
|
|
2348
|
+
if inv and inv.get("status") not in (None, "paid"):
|
|
2349
|
+
lines.append(f"Invoice {inv.get('number') or inv['id']}: {inv['status']}"
|
|
2350
|
+
+ (f", due {inv['due'][:10]}" if inv.get("due") else ""))
|
|
2351
|
+
lines.append(f"Manage {s.get('billing_page')}")
|
|
2352
|
+
_say(*lines)
|
|
2353
|
+
return 0
|
|
2354
|
+
|
|
2355
|
+
|
|
2275
2356
|
def cmd_token(args) -> int:
|
|
2276
2357
|
"""`imprint token create | list | revoke`: CI tokens of the signed-in account. A token
|
|
2277
2358
|
acts as the account for one project, on the sealing routes, until it expires."""
|
|
@@ -2658,6 +2739,7 @@ def cmd_github(args) -> int:
|
|
|
2658
2739
|
_say(f"Repository {repository}", f"Project {prep['project_id']} (custody: "
|
|
2659
2740
|
f"{prep.get('custody', 'owner')})", f"Already authorised by your key {fp} "
|
|
2660
2741
|
f"({prep['authorisation']}): nothing to do.")
|
|
2742
|
+
_warn_workflow(root)
|
|
2661
2743
|
return 0
|
|
2662
2744
|
doc = prep["document"]
|
|
2663
2745
|
if doc.get("authorised_by") != fp or doc.get("project") != prep["project_id"]:
|
|
@@ -2693,9 +2775,21 @@ def cmd_github(args) -> int:
|
|
|
2693
2775
|
_say(f"Authorised {done['authorisation']} (log entry #{done['receipt']['log']['index']})",
|
|
2694
2776
|
f"Custody {done['custody']}: your key {fp} controls the project's chain; the App "
|
|
2695
2777
|
"seals each push with its own key, authorised by yours")
|
|
2778
|
+
_warn_workflow(root)
|
|
2696
2779
|
return 0
|
|
2697
2780
|
|
|
2698
2781
|
|
|
2782
|
+
SEALED_TWICE = ("This repository also has .github/workflows/codeimprint.yml, so each push is "
|
|
2783
|
+
"sealed twice. Delete that file to use the GitHub App only.")
|
|
2784
|
+
|
|
2785
|
+
|
|
2786
|
+
def _warn_workflow(root: Path) -> None:
|
|
2787
|
+
"""CIM-BE-44-v1: the App now seals every push; the Actions workflow `imprint init` wrote
|
|
2788
|
+
would seal each one again. Only a warning: the file is never deleted here."""
|
|
2789
|
+
if (root / ".github" / "workflows" / "codeimprint.yml").is_file():
|
|
2790
|
+
_warn(SEALED_TWICE)
|
|
2791
|
+
|
|
2792
|
+
|
|
2699
2793
|
def _print_result(r: dict, fail_above: float) -> None:
|
|
2700
2794
|
_say(f"Reference {r.get('reference')}",
|
|
2701
2795
|
f"Suspect {r.get('suspect')}",
|
|
@@ -3120,6 +3214,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
3120
3214
|
n.add_argument("path", nargs="?", default=".")
|
|
3121
3215
|
n.add_argument("--no-ci", action="store_true", help="do not add a build workflow (GitHub Actions, GitLab "
|
|
3122
3216
|
"CI or Bitbucket Pipelines, by the remote)")
|
|
3217
|
+
n.add_argument("--ci", action="store_true",
|
|
3218
|
+
help="add the build workflow even when the CodeImprint GitHub App already "
|
|
3219
|
+
"seals this repository")
|
|
3123
3220
|
n.add_argument("--no-key", action="store_true", help="do not create a developer key")
|
|
3124
3221
|
n.add_argument("--force", action="store_true", help="overwrite files that already exist")
|
|
3125
3222
|
n.add_argument("--url", help="server URL for creating the project (else login or "
|
|
@@ -3153,6 +3250,13 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
3153
3250
|
ky.add_argument("--url", help="server URL (overrides login and CODEIMPRINT_URL)")
|
|
3154
3251
|
ky.set_defaults(func=cmd_key)
|
|
3155
3252
|
|
|
3253
|
+
pl = sub.add_parser("plan", help="your plan, its status and usage (read-only; buy or "
|
|
3254
|
+
"change it on the hub's billing page)")
|
|
3255
|
+
pl.add_argument("--org", help="an organisation you administer, by its ID")
|
|
3256
|
+
pl.add_argument("--json", action="store_true", help="the server's answer as JSON")
|
|
3257
|
+
pl.add_argument("--url", help="server URL (overrides login and CODEIMPRINT_URL)")
|
|
3258
|
+
pl.set_defaults(func=cmd_plan)
|
|
3259
|
+
|
|
3156
3260
|
tk = sub.add_parser("token", help="CI tokens for automated builds (CODEIMPRINT_TOKEN): "
|
|
3157
3261
|
"create, list, revoke")
|
|
3158
3262
|
tk.add_argument("action", choices=["create", "list", "revoke"])
|
|
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
|