@mokuyoaxis/agent-guard 0.2.4 → 0.2.5-rc2

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 (38) hide show
  1. package/README.md +166 -573
  2. package/README.zh-CN.md +138 -489
  3. package/SECURITY.md +53 -0
  4. package/adapters/INTEGRATION.md +4 -2
  5. package/adapters/dsh/README.md +7 -0
  6. package/assets/linux-do-community.svg +19 -0
  7. package/core/audit.py +170 -25
  8. package/core/classifier.py +25 -1
  9. package/core/lab.py +77 -7
  10. package/core/policy.py +17 -9
  11. package/core/recovery.py +5 -1
  12. package/core/redaction.py +122 -21
  13. package/docs/README.md +18 -5
  14. package/docs/design/architecture.md +25 -6
  15. package/docs/design/compatibility.md +106 -1
  16. package/docs/design/threat-model.md +6 -4
  17. package/docs/guides/audit-metadata.md +77 -0
  18. package/docs/guides/getting-started.md +106 -0
  19. package/docs/guides/harness-capabilities.md +5 -0
  20. package/docs/history/friction.md +85 -0
  21. package/docs/lab/guard-lab.md +15 -1
  22. package/docs/releases/release-notes-0.2.5-rc1.md +91 -0
  23. package/docs/releases/release-notes-0.2.5-rc2.md +101 -0
  24. package/guard_lab.py +11 -0
  25. package/package.json +4 -2
  26. package/skills/delete-guard/SKILL.md +45 -7
  27. package/skills/delete-guard/references/policy.md +90 -4
  28. package/skills/delete-guard/scripts/check.py +3 -0
  29. package/skills/delete-guard/scripts/gc.py +18 -3
  30. package/skills/delete-guard/scripts/restore.py +22 -7
  31. package/skills/delete-guard/scripts/safe_delete.py +52 -29
  32. package/skills/delete-guard/scripts/status.py +9 -7
  33. package/skills/exfil-guard/SKILL.md +23 -11
  34. package/skills/exfil-guard/references/channels.md +8 -1
  35. package/skills/exfil-guard/references/rules.md +86 -6
  36. package/skills/exfil-guard/scripts/_payload.py +20 -0
  37. package/skills/exfil-guard/scripts/check_span.py +5 -1
  38. package/skills/exfil-guard/scripts/sanitize.py +6 -3
@@ -12,6 +12,26 @@ from core.classifier import discover_workspace
12
12
  DEFAULT_STDIN_TIMEOUT_SEC = 10.0
13
13
 
14
14
 
15
+ def emit_exemption_diagnostics(info):
16
+ """CLI warnings on stderr; text comes only from the static catalog."""
17
+ for row in info.get("diagnostics", []):
18
+ code = row.get("code")
19
+ message = redaction.EXEMPTION_DIAGNOSTICS.get(code)
20
+ if message is None:
21
+ continue
22
+ source = row.get("source")
23
+ if source not in (redaction.DEFAULT_ALLOWFILE, redaction.DEFAULT_IGNOREFILE):
24
+ source = "<provided>"
25
+ location = source
26
+ if type(row.get("line")) is int and row["line"] > 0:
27
+ location += ":" + str(row["line"])
28
+ print(f"exfil-guard warning: {code} {location}: {message}", file=sys.stderr)
29
+ omitted = info.get("diagnostics_omitted", 0)
30
+ if type(omitted) is int and omitted > 0:
31
+ print(f"exfil-guard warning: {omitted} additional configuration diagnostics omitted",
32
+ file=sys.stderr)
33
+
34
+
15
35
  class StdinIdle(Exception):
16
36
  """No first byte arrived within the configured wait."""
17
37
 
@@ -39,7 +39,8 @@ from core.redaction import (
39
39
  CHANNELS, UNREACHABLE_CHANNELS, get_channel, scan_text,
40
40
  )
41
41
  from core import policy
42
- from _payload import PayloadTooLarge, StdinIdle, read_payload, resolve_context
42
+ from _payload import (PayloadTooLarge, StdinIdle, emit_exemption_diagnostics,
43
+ read_payload, resolve_context)
43
44
 
44
45
 
45
46
  def build_redaction_plan(spans, decisions, channel) -> list:
@@ -112,6 +113,8 @@ def main() -> int:
112
113
  max_bytes=args.max_bytes, path=args.path)
113
114
  out["scanned"] = scan.scanned
114
115
  out["exempted"] = scan.exempted
116
+ if scan.exemption_info:
117
+ out["exemption"] = scan.exemption_info
115
118
  if args.path:
116
119
  out["path"] = args.path
117
120
  if not scan.scanned:
@@ -157,6 +160,7 @@ def _emit(out, decision, code, spans, plan, args, exit_code,
157
160
  if args.as_json:
158
161
  print(json.dumps(out, ensure_ascii=False, indent=2))
159
162
  else:
163
+ emit_exemption_diagnostics(out.get("exemption", {}))
160
164
  print(f"{decision} [{code}] {len(spans)} span(s) on "
161
165
  f"channel {out.get('channel')}")
162
166
  if out.get("explanation"):
@@ -36,8 +36,8 @@ import _bootstrap # noqa: F401
36
36
 
37
37
  from core import policy, redaction
38
38
  from core.redaction import get_channel, scan_text
39
- from _payload import (PayloadTooLarge, StdinIdle, read_bounded_text,
40
- read_payload, resolve_context)
39
+ from _payload import (PayloadTooLarge, StdinIdle, emit_exemption_diagnostics,
40
+ read_bounded_text, read_payload, resolve_context)
41
41
 
42
42
  REDACTED = "<REDACTED>"
43
43
  PATH_PLACEHOLDER = "<PATH>"
@@ -154,7 +154,8 @@ def sanitize_text(text: str, channel_name: str, workspace=None,
154
154
  for span, verdict in zip(scan.spans, verdicts)
155
155
  if verdict.decision == policy.DECISION_SANITIZE]
156
156
  if decision not in (policy.DECISION_ALLOW, policy.DECISION_SANITIZE):
157
- return {"text": "", "plan": derived, "decision": decision}
157
+ return {"text": "", "plan": derived, "decision": decision,
158
+ "exemption": exemption.safe()}
158
159
  applied = derived if plan is None else _checked_plan(text, plan, derived)
159
160
  rewritten = apply_plan(text, applied)
160
161
  checked = scan_text(rewritten, channel=channel_name, workspace=workspace,
@@ -168,6 +169,7 @@ def sanitize_text(text: str, channel_name: str, workspace=None,
168
169
  "text": rewritten,
169
170
  "plan": applied,
170
171
  "decision": decision,
172
+ "exemption": exemption.safe(),
171
173
  }
172
174
 
173
175
 
@@ -216,6 +218,7 @@ def main() -> int:
216
218
  except (OSError, UnicodeError, ValueError, RuntimeError):
217
219
  print("sanitize: payload or plan validation failed", file=sys.stderr)
218
220
  return 1
221
+ emit_exemption_diagnostics(result["exemption"])
219
222
  if result["decision"] in (policy.DECISION_BLOCK, policy.DECISION_ASK):
220
223
  print("sanitize: " + result["decision"] + " payload withheld", file=sys.stderr)
221
224
  return 2 if result["decision"] == policy.DECISION_BLOCK else 3