twsrt 2.1.0__tar.gz → 2.2.0__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 (27) hide show
  1. {twsrt-2.1.0 → twsrt-2.2.0}/PKG-INFO +19 -5
  2. {twsrt-2.1.0 → twsrt-2.2.0}/README.md +18 -4
  3. {twsrt-2.1.0 → twsrt-2.2.0}/pyproject.toml +2 -2
  4. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/bin/cli.py +16 -9
  5. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/doctor.py +90 -0
  6. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt.egg-info/PKG-INFO +19 -5
  7. {twsrt-2.1.0 → twsrt-2.2.0}/setup.cfg +0 -0
  8. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/__init__.py +0 -0
  9. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/bin/__init__.py +0 -0
  10. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/__init__.py +0 -0
  11. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/agent.py +0 -0
  12. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/claude.py +0 -0
  13. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/codex.py +0 -0
  14. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/composition.py +0 -0
  15. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/config.py +0 -0
  16. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/copilot.py +0 -0
  17. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/jsonc.py +0 -0
  18. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/models.py +0 -0
  19. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/probe.py +0 -0
  20. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/profiles.py +0 -0
  21. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/sources.py +0 -0
  22. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt/lib/symlink.py +0 -0
  23. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt.egg-info/SOURCES.txt +0 -0
  24. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt.egg-info/dependency_links.txt +0 -0
  25. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt.egg-info/entry_points.txt +0 -0
  26. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt.egg-info/requires.txt +0 -0
  27. {twsrt-2.1.0 → twsrt-2.2.0}/src/twsrt.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: twsrt
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Agent security configuration generator — translates canonical security rules into agent-specific configs
5
5
  Author-email: sysid <sysid@gmx.de>
6
6
  License-Expression: BSD-3-Clause
@@ -180,7 +180,7 @@ Profiles extend each other but only ever *add*:
180
180
  uv tool install twsrt # or: pip install twsrt
181
181
 
182
182
  twsrt config --init # writes ~/.config/twsrt/config.toml + starter fragments
183
- twsrt edit # opens the profile's fragments: deny paths, domains, command rules
183
+ twsrt edit # opens every fragment: deny paths, domains, command rules
184
184
 
185
185
  twsrt show # print the compiled canonical ~/.srt-settings.json
186
186
  twsrt generate claude # preview the Claude translation; writes nothing
@@ -408,8 +408,8 @@ is preserved. Restart Codex after generation.
408
408
 
409
409
  ### Copilot CLI
410
410
 
411
- Copilot has no settings file, so twsrt emits a flag snippet for the launch
412
- command (to stdout, or to `copilot_output`). Nothing kernel-guards Copilot's
411
+ twsrt does not manage Copilot's `~/.copilot/settings.json`; it emits a flag
412
+ snippet for the launch command (to stdout, or to `copilot_output`). Nothing kernel-guards Copilot's
413
413
  tools, so run it under the SRT wrapper, which enforces the paths and domains:
414
414
 
415
415
  ```bash
@@ -421,6 +421,12 @@ starts with `--yolo` and keeps only `--deny-tool` and `--deny-url`; deny
421
421
  flags still take precedence over `--yolo`.
422
422
  [Copilot flags](doc/REFERENCE.md#copilot-flags).
423
423
 
424
+ **`--add-dir` is a trust grant.** Besides file access, Copilot loads the added
425
+ directory's `.github/skills` and `.github/agents` as trusted configuration.
426
+ Start Copilot inside the repository instead, or add only directories whose
427
+ agent definitions you trust. twsrt does not emit `--add-dir`
428
+ ([SECURITY_CONCEPT.md §7.1](SECURITY_CONCEPT.md#71-what-twsrt-does-not-protect-against)).
429
+
424
430
  ## Verifying the policy
425
431
 
426
432
  Three read-only commands answer three different questions:
@@ -488,7 +494,7 @@ Threat model, rationale and every known gap:
488
494
  | Command | Effect |
489
495
  |---|---|
490
496
  | `twsrt config [--init]` | Open `config.toml` in `$EDITOR` (fallback `vi`); `--init` first creates it and starter fragments, never overwriting an existing file |
491
- | `twsrt edit [srt\|bash] [-p P] [-n]` | Open the profile's fragments in `$EDITOR`, then report whether targets are stale; `-n` only names them |
497
+ | `twsrt edit [srt\|bash] [-p P] [-n]` | Open every registered fragment (only profile P's with `-p`) in `$EDITOR`, then report whether targets are stale; `-n` only names them |
492
498
  | `twsrt profiles` | Table of every profile with its parents and resolved fragments per source kind; `*` marks `default_profile`, inherited fragments are dimmed, `invalid` marks one that cannot compile on its own |
493
499
  | `twsrt show [srt\|bash] [-p P]` | Print the compiled canonical document exactly as `-w` would write it. Writes nothing |
494
500
  | `twsrt generate [agent] [-p P]` | Print the agent translation (`claude`, `codex`, `copilot`, default `all`). Writes nothing |
@@ -531,3 +537,11 @@ make ty # type check with ty
531
537
  make static-analysis # all of the above
532
538
  make install # uv tool install -e . plus shell completion
533
539
  ```
540
+
541
+ `scripts/srt-schema.mjs` prints the config key tree of the installed srt (Node; srt ships no JSON
542
+ schema). Run it after an srt upgrade to spot new keys; srt silently drops unknown keys outside
543
+ `credentials`.
544
+
545
+ `scripts/copilot-schema.py` does the same for the `sandbox` key of Copilot CLI's
546
+ `~/.copilot/settings.json` (uv script), read from the JSON schema shipped with the newest build
547
+ under `~/.copilot/pkg/`.
@@ -166,7 +166,7 @@ Profiles extend each other but only ever *add*:
166
166
  uv tool install twsrt # or: pip install twsrt
167
167
 
168
168
  twsrt config --init # writes ~/.config/twsrt/config.toml + starter fragments
169
- twsrt edit # opens the profile's fragments: deny paths, domains, command rules
169
+ twsrt edit # opens every fragment: deny paths, domains, command rules
170
170
 
171
171
  twsrt show # print the compiled canonical ~/.srt-settings.json
172
172
  twsrt generate claude # preview the Claude translation; writes nothing
@@ -394,8 +394,8 @@ is preserved. Restart Codex after generation.
394
394
 
395
395
  ### Copilot CLI
396
396
 
397
- Copilot has no settings file, so twsrt emits a flag snippet for the launch
398
- command (to stdout, or to `copilot_output`). Nothing kernel-guards Copilot's
397
+ twsrt does not manage Copilot's `~/.copilot/settings.json`; it emits a flag
398
+ snippet for the launch command (to stdout, or to `copilot_output`). Nothing kernel-guards Copilot's
399
399
  tools, so run it under the SRT wrapper, which enforces the paths and domains:
400
400
 
401
401
  ```bash
@@ -407,6 +407,12 @@ starts with `--yolo` and keeps only `--deny-tool` and `--deny-url`; deny
407
407
  flags still take precedence over `--yolo`.
408
408
  [Copilot flags](doc/REFERENCE.md#copilot-flags).
409
409
 
410
+ **`--add-dir` is a trust grant.** Besides file access, Copilot loads the added
411
+ directory's `.github/skills` and `.github/agents` as trusted configuration.
412
+ Start Copilot inside the repository instead, or add only directories whose
413
+ agent definitions you trust. twsrt does not emit `--add-dir`
414
+ ([SECURITY_CONCEPT.md §7.1](SECURITY_CONCEPT.md#71-what-twsrt-does-not-protect-against)).
415
+
410
416
  ## Verifying the policy
411
417
 
412
418
  Three read-only commands answer three different questions:
@@ -474,7 +480,7 @@ Threat model, rationale and every known gap:
474
480
  | Command | Effect |
475
481
  |---|---|
476
482
  | `twsrt config [--init]` | Open `config.toml` in `$EDITOR` (fallback `vi`); `--init` first creates it and starter fragments, never overwriting an existing file |
477
- | `twsrt edit [srt\|bash] [-p P] [-n]` | Open the profile's fragments in `$EDITOR`, then report whether targets are stale; `-n` only names them |
483
+ | `twsrt edit [srt\|bash] [-p P] [-n]` | Open every registered fragment (only profile P's with `-p`) in `$EDITOR`, then report whether targets are stale; `-n` only names them |
478
484
  | `twsrt profiles` | Table of every profile with its parents and resolved fragments per source kind; `*` marks `default_profile`, inherited fragments are dimmed, `invalid` marks one that cannot compile on its own |
479
485
  | `twsrt show [srt\|bash] [-p P]` | Print the compiled canonical document exactly as `-w` would write it. Writes nothing |
480
486
  | `twsrt generate [agent] [-p P]` | Print the agent translation (`claude`, `codex`, `copilot`, default `all`). Writes nothing |
@@ -517,3 +523,11 @@ make ty # type check with ty
517
523
  make static-analysis # all of the above
518
524
  make install # uv tool install -e . plus shell completion
519
525
  ```
526
+
527
+ `scripts/srt-schema.mjs` prints the config key tree of the installed srt (Node; srt ships no JSON
528
+ schema). Run it after an srt upgrade to spot new keys; srt silently drops unknown keys outside
529
+ `credentials`.
530
+
531
+ `scripts/copilot-schema.py` does the same for the `sandbox` key of Copilot CLI's
532
+ `~/.copilot/settings.json` (uv script), read from the JSON schema shipped with the newest build
533
+ under `~/.copilot/pkg/`.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "twsrt"
3
- version = "2.1.0"
3
+ version = "2.2.0"
4
4
  description = "Agent security configuration generator — translates canonical security rules into agent-specific configs"
5
5
  readme = "README.md"
6
6
  license = "BSD-3-Clause"
@@ -45,7 +45,7 @@ dev = [
45
45
  ]
46
46
 
47
47
  [tool.bumpversion]
48
- current_version = "2.1.0"
48
+ current_version = "2.2.0"
49
49
  commit = true
50
50
  tag = false
51
51
  tag_name = "v{new_version}"
@@ -16,7 +16,7 @@ import typer
16
16
 
17
17
  from twsrt.lib.models import AppConfig, CompilationResult, yolo_path
18
18
 
19
- __version__ = "2.1.0"
19
+ __version__ = "2.2.0"
20
20
 
21
21
  app = typer.Typer(
22
22
  name="twsrt",
@@ -383,11 +383,14 @@ def edit(
383
383
  False, "--dry-run", "-n", help="Name the fragments, open nothing"
384
384
  ),
385
385
  ) -> None:
386
- """Open the profile's canonical-source fragments in $EDITOR.
386
+ """Open canonical-source fragments in $EDITOR.
387
+
388
+ Without --profile every registered fragment opens; with it, only the
389
+ fragments that profile resolves to (inherited ones included).
387
390
 
388
391
  The complement of `config`: that opens the registry, this opens the policy.
389
- Only the profile is resolved, never compiled, so a fragment with a syntax
390
- error still opens -- that is exactly when you need an editor.
392
+ Fragments are never compiled before opening, so one with a syntax error
393
+ still opens -- that is exactly when you need an editor.
391
394
  """
392
395
  from twsrt.lib.config import load_config
393
396
  from twsrt.lib.profiles import resolve_profile
@@ -395,7 +398,13 @@ def edit(
395
398
  config_path: Path = ctx.obj["config_path"]
396
399
  try:
397
400
  config = load_config(config_path)
398
- resolved = resolve_profile(config, profile)
401
+ if profile is None:
402
+ fragments_by_kind = {
403
+ source_kind: list(source.fragments.values())
404
+ for source_kind, source in config.sources.items()
405
+ }
406
+ else:
407
+ fragments_by_kind = resolve_profile(config, profile).fragments
399
408
  except (OSError, ValueError) as exc:
400
409
  log.debug("Edit setup failed", exc_info=True)
401
410
  _error(str(exc))
@@ -411,13 +420,11 @@ def edit(
411
420
  for source_kind in config.sources:
412
421
  if kind not in ("all", source_kind):
413
422
  continue
414
- for fragment in resolved.fragments.get(source_kind, []):
423
+ for fragment in fragments_by_kind.get(source_kind, []):
415
424
  if fragment.path not in paths:
416
425
  paths.append(fragment.path)
417
426
 
418
- log.debug(
419
- "Editing profile %r kind=%s fragments=%d", resolved.name, kind, len(paths)
420
- )
427
+ log.debug("Editing profile %r kind=%s fragments=%d", profile, kind, len(paths))
421
428
  for path in paths:
422
429
  try:
423
430
  absent = not path.exists()
@@ -30,6 +30,58 @@ _DOMAIN_LISTS = ("allowedDomains", "deniedDomains")
30
30
  _BASH_LISTS = ("allow", "ask", "deny")
31
31
  _ALLOW_PATH_LISTS = ("allowWrite", "allowRead")
32
32
 
33
+ # Keys srt's config schema accepts; srt strips anything else without a word.
34
+ # ponytail: hand-copied from SandboxRuntimeConfigSchema in sandbox-runtime
35
+ # 0.0.78 (dist/sandbox/sandbox-config.js); a newer srt key is reported until
36
+ # added here. Upgrade path: read the schema from the installed srt.
37
+ _SRT_SCHEMA_KEYS = {
38
+ "": {
39
+ "network",
40
+ "filesystem",
41
+ "credentials",
42
+ "ignoreViolations",
43
+ "enableWeakerNestedSandbox",
44
+ "enableWeakerNetworkIsolation",
45
+ "allowAppleEvents",
46
+ "ripgrep",
47
+ "mandatoryDenySearchDepth",
48
+ "allowPty",
49
+ "seccomp",
50
+ "bwrapPath",
51
+ "socatPath",
52
+ "javaAgentJarPath",
53
+ "windows",
54
+ "git",
55
+ # Not in srt's schema, but twsrt maps it to Claude's sandbox.enabled.
56
+ "enabled",
57
+ },
58
+ "network": {
59
+ "allowedDomains",
60
+ "deniedDomains",
61
+ "deniedDomainReasons",
62
+ "strictAllowlist",
63
+ "deniedResolvedAddresses",
64
+ "allowUnixSockets",
65
+ "allowAllUnixSockets",
66
+ "allowLocalBinding",
67
+ "allowMachLookup",
68
+ "httpProxyPort",
69
+ "socksProxyPort",
70
+ "mitmProxy",
71
+ "filterRequest",
72
+ "tlsTerminate",
73
+ "parentProxy",
74
+ },
75
+ "filesystem": {
76
+ "disabled",
77
+ "denyRead",
78
+ "allowRead",
79
+ "allowWrite",
80
+ "denyWrite",
81
+ "allowGitConfig",
82
+ },
83
+ }
84
+
33
85
  # `// doctor-ignore` or `// doctor-ignore: free-text reason` after an entry.
34
86
  _IGNORE_DIRECTIVE = re.compile(r"//\s*doctor-ignore\b")
35
87
  # A JSON string literal that is a value, not an object key.
@@ -72,6 +124,7 @@ def diagnose(
72
124
  for profile in resolved.values():
73
125
  _check_profile_lists(profile, loaded, ignores, base_dir, findings)
74
126
  _check_patterns(config, loaded, ignores, base_dir, findings)
127
+ _check_unknown_srt_keys(config, loaded, base_dir, findings)
75
128
  _check_symlinked_denies(config, loaded, ignores, base_dir, findings)
76
129
  _check_broad_allow_write(config, loaded, ignores, base_dir, findings)
77
130
  _check_claude_files(claude_files, findings)
@@ -479,6 +532,43 @@ def _path_trap(key: str, entry: str) -> str | None:
479
532
  return None
480
533
 
481
534
 
535
+ def _check_unknown_srt_keys(
536
+ config: AppConfig,
537
+ loaded: dict[Path, dict[str, Any]],
538
+ base_dir: Path,
539
+ findings: list[Finding],
540
+ ) -> None:
541
+ """A key outside srt's schema is stripped by srt and dropped by twsrt.
542
+
543
+ Typical cause: a Claude-only setting such as excludedCommands placed in a
544
+ fragment, where it silently does nothing.
545
+ """
546
+ for fragment in config.sources["srt"].fragments.values():
547
+ document = loaded.get(fragment.path, {})
548
+ unknown: list[str] = []
549
+ for section, known in _SRT_SCHEMA_KEYS.items():
550
+ container = document.get(section, {}) if section else document
551
+ if not isinstance(container, dict):
552
+ continue
553
+ unknown += [
554
+ repr(f"{section}.{key}" if section else key)
555
+ for key in container
556
+ if key not in known
557
+ ]
558
+ if unknown:
559
+ findings.append(
560
+ Finding(
561
+ "warning",
562
+ "unknown-srt-key",
563
+ _show(fragment.path, base_dir),
564
+ f"{_count(unknown, 'key', 'keys')} srt ignores and twsrt maps "
565
+ "to no agent; Claude-only settings belong in "
566
+ "[sandbox_overrides]",
567
+ tuple(unknown),
568
+ )
569
+ )
570
+
571
+
482
572
  def _count(items: list[str], singular: str, plural: str) -> str:
483
573
  return f"{len(items)} {singular if len(items) == 1 else plural}"
484
574
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: twsrt
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Agent security configuration generator — translates canonical security rules into agent-specific configs
5
5
  Author-email: sysid <sysid@gmx.de>
6
6
  License-Expression: BSD-3-Clause
@@ -180,7 +180,7 @@ Profiles extend each other but only ever *add*:
180
180
  uv tool install twsrt # or: pip install twsrt
181
181
 
182
182
  twsrt config --init # writes ~/.config/twsrt/config.toml + starter fragments
183
- twsrt edit # opens the profile's fragments: deny paths, domains, command rules
183
+ twsrt edit # opens every fragment: deny paths, domains, command rules
184
184
 
185
185
  twsrt show # print the compiled canonical ~/.srt-settings.json
186
186
  twsrt generate claude # preview the Claude translation; writes nothing
@@ -408,8 +408,8 @@ is preserved. Restart Codex after generation.
408
408
 
409
409
  ### Copilot CLI
410
410
 
411
- Copilot has no settings file, so twsrt emits a flag snippet for the launch
412
- command (to stdout, or to `copilot_output`). Nothing kernel-guards Copilot's
411
+ twsrt does not manage Copilot's `~/.copilot/settings.json`; it emits a flag
412
+ snippet for the launch command (to stdout, or to `copilot_output`). Nothing kernel-guards Copilot's
413
413
  tools, so run it under the SRT wrapper, which enforces the paths and domains:
414
414
 
415
415
  ```bash
@@ -421,6 +421,12 @@ starts with `--yolo` and keeps only `--deny-tool` and `--deny-url`; deny
421
421
  flags still take precedence over `--yolo`.
422
422
  [Copilot flags](doc/REFERENCE.md#copilot-flags).
423
423
 
424
+ **`--add-dir` is a trust grant.** Besides file access, Copilot loads the added
425
+ directory's `.github/skills` and `.github/agents` as trusted configuration.
426
+ Start Copilot inside the repository instead, or add only directories whose
427
+ agent definitions you trust. twsrt does not emit `--add-dir`
428
+ ([SECURITY_CONCEPT.md §7.1](SECURITY_CONCEPT.md#71-what-twsrt-does-not-protect-against)).
429
+
424
430
  ## Verifying the policy
425
431
 
426
432
  Three read-only commands answer three different questions:
@@ -488,7 +494,7 @@ Threat model, rationale and every known gap:
488
494
  | Command | Effect |
489
495
  |---|---|
490
496
  | `twsrt config [--init]` | Open `config.toml` in `$EDITOR` (fallback `vi`); `--init` first creates it and starter fragments, never overwriting an existing file |
491
- | `twsrt edit [srt\|bash] [-p P] [-n]` | Open the profile's fragments in `$EDITOR`, then report whether targets are stale; `-n` only names them |
497
+ | `twsrt edit [srt\|bash] [-p P] [-n]` | Open every registered fragment (only profile P's with `-p`) in `$EDITOR`, then report whether targets are stale; `-n` only names them |
492
498
  | `twsrt profiles` | Table of every profile with its parents and resolved fragments per source kind; `*` marks `default_profile`, inherited fragments are dimmed, `invalid` marks one that cannot compile on its own |
493
499
  | `twsrt show [srt\|bash] [-p P]` | Print the compiled canonical document exactly as `-w` would write it. Writes nothing |
494
500
  | `twsrt generate [agent] [-p P]` | Print the agent translation (`claude`, `codex`, `copilot`, default `all`). Writes nothing |
@@ -531,3 +537,11 @@ make ty # type check with ty
531
537
  make static-analysis # all of the above
532
538
  make install # uv tool install -e . plus shell completion
533
539
  ```
540
+
541
+ `scripts/srt-schema.mjs` prints the config key tree of the installed srt (Node; srt ships no JSON
542
+ schema). Run it after an srt upgrade to spot new keys; srt silently drops unknown keys outside
543
+ `credentials`.
544
+
545
+ `scripts/copilot-schema.py` does the same for the `sandbox` key of Copilot CLI's
546
+ `~/.copilot/settings.json` (uv script), read from the JSON schema shipped with the newest build
547
+ under `~/.copilot/pkg/`.
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