codeimprint 0.5.0a17__tar.gz → 0.5.0a18__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.
Files changed (26) hide show
  1. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/CHANGELOG.md +17 -0
  2. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/PKG-INFO +1 -1
  3. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/pyproject.toml +1 -1
  4. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/__init__.py +1 -1
  5. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/chainseal.py +5 -0
  6. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/gitrepo.py +19 -0
  7. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/.gitignore +0 -0
  8. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/LICENSE +0 -0
  9. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/NOTICE +0 -0
  10. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/README.pypi.md +0 -0
  11. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint/__init__.py +0 -0
  12. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint/__main__.py +0 -0
  13. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/__main__.py +0 -0
  14. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/api.py +0 -0
  15. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/cli.py +0 -0
  16. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/config.py +0 -0
  17. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/imprint_file.py +0 -0
  18. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/linecount.py +0 -0
  19. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/ownership.py +0 -0
  20. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/project.py +0 -0
  21. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/receipt.py +0 -0
  22. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/records.py +0 -0
  23. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/timestamp.py +0 -0
  24. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/transparency.py +0 -0
  25. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/trust.py +0 -0
  26. {codeimprint-0.5.0a17 → codeimprint-0.5.0a18}/src/codeimprint_cli/tsa_roots.py +0 -0
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0a18 — Seals send recent commit IDs for clone detection [CIM-BE-33-v1]
4
+
5
+ For engine 0.7.0a22. Older engines still work: they ignore the two new fields.
6
+
7
+ - **Changed: what `imprint seal` sends in a Git repository.** Besides the commit and its
8
+ parents, each seal now sends the IDs of up to 50 first-parent ancestor commits and of
9
+ the repository's root commits. **IDs only**: no commit messages, authors, dates or
10
+ paths.
11
+ - The server (engine 0.7.0a22) keeps them as keyed hashes and uses them to find projects
12
+ that share sealed commits (clone detection). It does that later, in batches, so a seal
13
+ is exactly as fast as before and its output is unchanged.
14
+ - A shallow clone (for example `actions/checkout` with its default depth) sends no
15
+ roots, because its oldest commits are cut-off points.
16
+ - If Git cannot list the history, the seal goes ahead without the two fields.
17
+ - No new command and no new output.
18
+ - Tests: `tests/test_ancestors.py`.
19
+
3
20
  ## 0.5.0a17 — `imprint init --new-project` declares a private link to the origin [CIM-BE-32-v1]
4
21
 
5
22
  For engine 0.7.0a21. Older engines still work: the project is made and the link is skipped
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeimprint
3
- Version: 0.5.0a17
3
+ Version: 0.5.0a18
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.0a17"
9
+ version = "0.5.0a18"
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"
@@ -5,4 +5,4 @@ A thin client for a CodeImprint server: it zips a project, asks the server to se
5
5
  it, and verifies Imprint files offline. All analysis happens on the server.
6
6
  """
7
7
 
8
- __version__ = "0.5.0a17"
8
+ __version__ = "0.5.0a18"
@@ -110,6 +110,11 @@ def seal_commit(client, root: Path, project: str, commit: str, kind: str, key,
110
110
  else:
111
111
  body.update(tree=info["tree"], commit=commit, parents=info["parents"],
112
112
  ref=info["ref"], kind=kind, exclude=list(exclude or []), lines=lines)
113
+ try: # commit IDs only (engine 0.7.0a22+ keeps them keyed)
114
+ body.update(ancestors=gitrepo.ancestors(top, commit),
115
+ roots=gitrepo.roots(top, commit))
116
+ except gitrepo.GitError:
117
+ pass # the seal does not depend on them
113
118
  if kind == "release" and tag:
114
119
  body.update(tag=tag, public_tag=public_tag)
115
120
  resp = client.plan(project, body)
@@ -102,6 +102,25 @@ def commit_info(root: Path, commit: str) -> dict:
102
102
  return {"commit": commit, "tree": tree, "parents": line[1:], "ref": ref or None}
103
103
 
104
104
 
105
+ ANCESTORS = 50 # first-parent ancestors sent with a seal
106
+ ROOTS = 20
107
+
108
+
109
+ def ancestors(root: Path, commit: str, limit: int = ANCESTORS) -> list[str]:
110
+ """Up to ``limit`` first-parent ancestors of a commit, nearest first."""
111
+ listed = _git(root, "rev-list", "--first-parent", f"--max-count={limit + 1}",
112
+ commit).decode().split()
113
+ return listed[1:]
114
+
115
+
116
+ def roots(root: Path, commit: str, limit: int = ROOTS) -> list[str]:
117
+ """The root commits of a commit's history. None for a shallow clone: there the oldest
118
+ commits present are cut-off points, not roots."""
119
+ if _git(root, "rev-parse", "--is-shallow-repository").strip() == b"true":
120
+ return []
121
+ return _git(root, "rev-list", "--max-parents=0", commit).decode().split()[:limit]
122
+
123
+
105
124
  def tags_at(root: Path, commit: str) -> list[str]:
106
125
  """Tags pointing at a commit, sorted (``git tag --points-at``)."""
107
126
  return sorted(_git(root, "tag", "--points-at", commit).decode().split())
File without changes
File without changes