@runeditrun/rer 0.2.118 → 0.2.120

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 (35) hide show
  1. package/cli/README.md +40 -0
  2. package/cli/business/agent-args.mjs +60 -0
  3. package/cli/business/agent-help.mjs +53 -0
  4. package/cli/business/agent-output.mjs +38 -0
  5. package/cli/business/agent-table.mjs +32 -0
  6. package/cli/business/agent-verbs.mjs +132 -0
  7. package/cli/business/agent-wait.mjs +28 -0
  8. package/cli/business/command.mjs +18 -2
  9. package/cli/business/mcp-bridge.mjs +58 -0
  10. package/cli/business/questions.mjs +32 -9
  11. package/cli/business/run-child.mjs +42 -0
  12. package/cli/business/run-grant.mjs +65 -0
  13. package/cli/business/run-mask.mjs +21 -0
  14. package/cli/deploy-command.mjs +13 -7
  15. package/cli/deploy-inputs.mjs +1 -4
  16. package/cli/deploy-settings.mjs +15 -9
  17. package/cli/deploy.mjs +1 -1
  18. package/cli/managed-data-schema.mjs +2 -0
  19. package/cli/portability-worker.mjs +3 -1
  20. package/cli/portability.mjs +1 -1
  21. package/global/CHANGELOG.md +34 -0
  22. package/modules/portability/README.md +8 -0
  23. package/modules/portability/archive-step.mjs +11 -0
  24. package/modules/portability/export.mjs +34 -25
  25. package/modules/portability/import-safety.mjs +4 -3
  26. package/modules/portability/import-staging.mjs +4 -4
  27. package/modules/portability/import.mjs +14 -5
  28. package/modules/portability/index.mjs +2 -1
  29. package/modules/portability/object-inventory.mjs +45 -0
  30. package/modules/portability/storage.mjs +4 -3
  31. package/package.json +1 -1
  32. package/scripts/publish-check/README.md +5 -1
  33. package/scripts/publish-check/checksum_maps.py +9 -5
  34. package/scripts/publish-check/hit_location.py +20 -9
  35. package/scripts/publish-check/json_identity.py +15 -14
@@ -1,3 +1,4 @@
1
+ import { metadataJson, loadInventory, clearInventory } from './object-inventory.mjs';
1
2
  import { canonicalJson } from './hash.mjs';
2
3
  // Installed helpers and copied runtimes can coexist in one Worker. Share only
3
4
  // constructor-issued identities, so arbitrary objects with code/status fields
@@ -26,10 +27,10 @@ export async function state(db) {
26
27
  export async function job(db,id,kind) {
27
28
  const row=await statement(db,'SELECT * FROM rer_portability_jobs WHERE id=?',id).first();
28
29
  insist(row && (!kind || row.kind===kind),'job_not_found',404);
29
- return {...row, metadata:JSON.parse(row.metadata)};
30
+ return loadInventory(db,{...row, metadata:JSON.parse(row.metadata)});
30
31
  }
31
32
  export function save(db,row) {
32
- return statement(db,'UPDATE rer_portability_jobs SET phase=?,completed=?,metadata=? WHERE id=?',row.phase,row.completed,canonicalJson(row.metadata),row.id);
33
+ return statement(db,'UPDATE rer_portability_jobs SET phase=?,completed=?,metadata=? WHERE id=?',row.phase,row.completed,metadataJson(row.metadata),row.id);
33
34
  }
34
35
  export function partStatements(db,id,part) {
35
36
  return partQueries(id,part).map(({sql,params})=>statement(db,sql,...params));
@@ -64,7 +65,7 @@ export function dropCopyStatements(db,row) {
64
65
  return transferTables(row).map(name=>db.prepare(`DROP TABLE IF EXISTS ${quote(name)}`));
65
66
  }
66
67
  export function cleanCopyStatements(db,row) {
67
- return [...dropCopyStatements(db,row),statement(db,'DELETE FROM rer_portability_parts WHERE job=?',row.id),
68
+ return [...dropCopyStatements(db,row),...clearInventory(db,row),statement(db,'DELETE FROM rer_portability_parts WHERE job=?',row.id),
68
69
  statement(db,'DELETE FROM rer_portability_segments WHERE job=?',row.id)];
69
70
  }
70
71
  export async function cleanCopies(db,row) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeditrun/rer",
3
- "version": "0.2.118",
3
+ "version": "0.2.120",
4
4
  "description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -148,7 +148,11 @@ entry that does not prove, a 40-hex value, a key that names no tree file, or a h
148
148
  value with no file-name key keeps the native finding. Historical matches use only
149
149
  that commit's blobs and working-tree preimages reject linked paths. There is no
150
150
  path, filename, hash-value or repository exemption. `hit_location.py` resolves
151
- the native match's exact bytes for both proofs.
151
+ the native match's exact bytes for both proofs. Gitleaks directory fragments can
152
+ start mid-line without reporting their starting column. The resolver therefore
153
+ locates full matches within the reported LF-delimited lines. An unresolved match
154
+ retains its finding; repeated matches must all satisfy the structural and digest
155
+ proofs above, even if a reported column appears to identify just one of them.
152
156
 
153
157
  `trust_bundle.py` classifies an email match as public CA certificate metadata
154
158
  only when all of these hold: the file's path is an artifact listed by a committed
@@ -35,18 +35,22 @@ class ChecksumMaps:
35
35
  def matches(self, data, hit):
36
36
  if hit.get('RuleID') not in ('generic-api-key', 'hex-api-key'):
37
37
  return False
38
+ spans = match_spans(data, hit)
39
+ if not spans:
40
+ return False
38
41
  entries = list(ENTRY.finditer(data))
39
- for left, right in match_spans(data, hit):
42
+ for left, right in spans:
40
43
  keyed = [i for i, e in enumerate(entries)
41
44
  if left <= e.start('digest') and e.end('digest') <= right
42
45
  and e.group('digest').decode() == hit.get('Secret')]
43
46
  if len(keyed) != 1:
44
- continue
47
+ return False
45
48
  first = last = keyed[0]
46
49
  while first > 0 and SEPARATOR.fullmatch(data, entries[first - 1].end(), entries[first].start()):
47
50
  first -= 1
48
51
  while last + 1 < len(entries) and SEPARATOR.fullmatch(data, entries[last].end(), entries[last + 1].start()):
49
52
  last += 1
50
- return all(self.names_file((e.group('quoted') or e.group('bare')).decode('utf-8', 'replace'),
51
- e.group('digest').decode()) for e in entries[first:last + 1])
52
- return False
53
+ if not all(self.names_file((e.group('quoted') or e.group('bare')).decode('utf-8', 'replace'),
54
+ e.group('digest').decode()) for e in entries[first:last + 1]):
55
+ return False
56
+ return True
@@ -1,18 +1,29 @@
1
- """Resolve a native Gitleaks hit to the exact byte spans of its match."""
1
+ """Resolve a native Gitleaks hit to its possible full-match byte spans."""
2
2
 
3
3
 
4
4
  def match_spans(data, hit):
5
- lines = data.splitlines(keepends=True)
6
5
  try:
6
+ # Gitleaks counts LF bytes, not Python's broader set of line breaks.
7
+ lines = data.split(b'\n')
7
8
  first, last = hit['StartLine'] - 1, hit['EndLine'] - 1
8
9
  if not (0 <= first <= last < len(lines)):
9
10
  return []
10
- start = sum(map(len, lines[:first])) + hit['StartColumn'] - 1
11
- end = sum(map(len, lines[:last])) + hit['EndColumn']
12
- # Gitleaks 8.30.1 includes the preceding newline in columns
13
- # after fragment line one; Git fragments may begin mid-file.
14
- # Resolve that one-byte difference only against the exact match.
15
- return [(start - shift, end - shift) for shift in (0, 1)
16
- if data[start - shift:end - shift] == hit['Match'].encode('utf-8')]
11
+ match = hit['Match'].encode('utf-8')
12
+ if not match:
13
+ return []
14
+ left = sum(len(line) + 1 for line in lines[:first])
15
+ right = left + sum(len(line) + 1 for line in lines[first:last + 1])
16
+ # Directory fragments can start mid-line. Their columns are relative
17
+ # to that fragment, whose starting column is absent from the report.
18
+ # Later fragment lines also count the preceding LF in their columns.
19
+ # Bind the full match within the reported lines instead. Even an
20
+ # apparently exact column cannot disambiguate repeated occurrences.
21
+ # Callers must prove every candidate, never just the first one.
22
+ spans = []
23
+ start = data.find(match, left, right)
24
+ while start >= 0:
25
+ spans.append((start, start + len(match)))
26
+ start = data.find(match, start + 1, right)
27
+ return spans
17
28
  except (KeyError, TypeError, IndexError, UnicodeError):
18
29
  return []
@@ -80,19 +80,20 @@ class Document:
80
80
  secret = hit.get('Secret', '').encode('utf-8')
81
81
  if not secret:
82
82
  return False
83
- located = set()
84
- for left, right in match_spans(self.data, hit):
83
+ spans = match_spans(self.data, hit)
84
+ if not spans:
85
+ return False
86
+ allowed = [self.spans[pointer] for pointer in pointers if pointer in self.spans]
87
+ for left, right in spans:
85
88
  start = self.data.find(secret, left, right)
86
89
  if start < 0 or self.data.find(secret, start + 1, right) >= 0:
87
- continue
88
- for pointer in pointers:
89
- span = self.spans.get(pointer)
90
- if span:
91
- a, b, value = span
92
- # Native fragments can truncate a digest capture. Bind the
93
- # captured secret's bytes, including a partial capture, to
94
- # this exact unescaped JSON value.
95
- if (a + 1 <= start and start + len(secret) <= b - 1
96
- and self.data[a + 1:b - 1] == value.encode('ascii')):
97
- located.add((a, b))
98
- return len(located) == 1
90
+ return False
91
+ # Location alone is not proof. Every possible native occurrence
92
+ # must bind its captured bytes (even a truncated capture) to an
93
+ # exact unescaped JSON value at a proved pointer. An identical
94
+ # credential elsewhere on the line therefore retains the finding.
95
+ if not any(a + 1 <= start and start + len(secret) <= b - 1
96
+ and self.data[a + 1:b - 1] == value.encode('ascii')
97
+ for a, b, value in allowed):
98
+ return False
99
+ return True