Repository navigation
Add the deception command group and Deception SDK class - #482
Conversation
Typed subcommands for every user-facing request of the ext-deception extension (plan, deploy, rollout-status, decoys and hosts, verify, rotate, remove, coverage, test-fire, test runs and paths, hits, readers, drops, restore-rules, uninstall) and config get/set/enable on the extension_config record with compare-and-set on its etag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/lc-review |
Self-review (adversarial), head 676d1f0Checked every subcommand's request fields against the extension's published request schema ( Checked hive semantics for Low, not fixed (noted for a follow-up if anyone cares):
Verdict: APPROVED (0 High, 0 Medium, 2 Low) |
There was a problem hiding this comment.
AI Code Review Summary
Verdict: NOT_APPROVED (0 High, 1 Medium, 3 Low)
This is a first-round review. I read every changed file in full: the SDK class, the CLI group, the discovery, module-map and lazy-loading changes, the docs, the changelog and the tests.
General Feedback
- Low Priority: Many commands have no test that checks how their flags map to request fields:
list-hosts,list-readers,list-test-runs,list-test-paths,coverage,test-fire,drops list,drops draft-documentandkinds. Most of these are pass-through mappings, so a mistyped field name (for examplemanaged_by,last_hit_sinceorinclude_deleted) would reach users without any test failing. One test per command that assertsext.calls(liketest_list_sends_states_and_flags_only_when_set) would cover this. - Note (not counted): the
config settests mockHiveentirely. Nothing tests the premise behind_CREATE_ONLY_ETAG: that the hive ignores an etag when no record exists and refuses it when a record exists. If that premise is wrong, every firstconfig seton an org fails. Please confirm it against the hive's behaviour. test-time-budget: no check run was found on this commit. The check is not required onmaster(branch protection and rulesets list no required checks).
Blast radius
The new code lives in its own modules (limacharlie/commands/deception.py, limacharlie/sdk/deception.py). These modules are loaded lazily through _COMMAND_MODULE_MAP. The shared code changes only by adding entries: one module-map entry and one discovery profile, deception. Code that lists PROFILES or the top-level commands (help, discovery output, completion) will now show the new group. Hive, HiveRecord and Extensions are used but not modified, so existing commands behave as before. On a live org, config set writes the shared extension_config/ext-deception record. extension config-set, hive and sync edit the same record.
This review was generated automatically by Claude Code.
config set checks the record exists on every path (a stale etag of a deleted record is refused, a new record is written create-only), and --enabled on an existing record writes on the etag its metadata was read with. Tables show a list's rows and the rest of the answer as YAML so nothing is cut. restore-rules fails unless every rule reads back enabled. --save refuses a url or hostname drop before creating it and reports write errors cleanly. An empty --draft-policy file is refused. More mapping tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/lc-review |
There was a problem hiding this comment.
AI Code Review Summary
Verdict: APPROVED (0 High, 0 Medium, 2 Low)
This is a re-review of the changes since 676d1f0. Four files changed: limacharlie/sdk/deception.py, limacharlie/commands/deception.py, doc/cli/deception.md and tests/unit/test_cli_deception.py. I read each of them in full again. The other PR files have not changed since the last round.
Earlier findings
- All three earlier threads are fixed. I verified each one and replied on its thread.
- The earlier General Feedback Low (no request-mapping tests for
list-hosts,list-readers,list-test-runs,list-test-paths,coverage,test-fire,drops list,drops draft-document,kinds) is fixed byTestMoreRequests.test_mapping.
General Feedback
drops rotate --saveon a url or hostname drop repeats the problem fixed fordrops create. See the inline thread.test-time-budget: no check run was found on this commit. The check is not required onmaster(branch protection and rulesets list no required checks).
Blast radius
This round's changes stay inside the deception modules. _out changes only how deception commands print in table mode: lists print as a table plus YAML, and every other answer prints as YAML. JSON, YAML, CSV, --filter and --fields still go through command_output, so scripts that parse non-table output see no change. set_config now always reads the metadata first, so every config set needs ext.conf.get or ext.conf.get.mtd. restore-rules now exits 1 more often: when any row lacks enabled: true, carries an error, or the answer has no rows. Scripts that check its exit code will see this.
This review was generated automatically by Claude Code.
|
Second reviewer, round 2: one Medium (a delete in the instant between config set's metadata read and its write recreates the record, because the hive ignores an etag for a missing record) and one Low (atomic --save write). The Medium is the same class as round 1's and cannot be closed client-side: it needs an atomic must-exist condition in the hive, and hive set --etag has the same window. Recorded in the PR description; the Lows go to the follow-up PR. /lc-review approved b8d7bc6. |
There was a problem hiding this comment.
AI Code Review Summary
Verdict: APPROVED (0 High, 0 Medium, 3 Low)
This is a re-review at b8d7bc6, the same commit my last review covered. The compare returned identical, not ahead, so I treated every file as changed and read all of them in full again: the SDK class, the CLI group, cli.py, discovery.py, the docs, the changelog and the three test files. I found no new High or Medium issue.
Earlier findings
drops rotate --saveon a url or hostname drop (thread atlimacharlie/commands/deception.py:985, resolved): still open in the code. The drop is rotated before_save_pastefails, so a retry on exit 1 rotates it again. The author has moved it to a follow-up PR. Carried over as Low.restore-rulesexit tests (thread atlimacharlie/commands/deception.py:651, resolved): still open. There is still no test that a fully successful answer exits 0, and none forenabled: falsealone orerroralone. Moved to the follow-up PR. Carried over as Low.- The three round-1 threads stay fixed.
General Feedback
- Low Priority:
_save_paste(limacharlie/commands/deception.py:139-158) opens the target withopen(path, "wb")and writes to it directly. If the write fails partway (disk full, I/O error), a truncated file is left atpath, but the message says "nothing was written". The PR description already plans the fix: write to a temporary file in the same directory, thenos.replaceit ontopath, and remove the temporary file on error. - Answer to the reviewer instructions (not counted): I agree that the window between
config set's metadata read and its write cannot be closed from the client. When the record exists, the data-only path could send the etag it just read, but by the PR's own premise (sdk/deception.py:34-37) the hive ignores an etag once the record is gone. So a delete inside that window still recreates the record. Closing it needs a "must exist" condition on the hive side.hive set --etaghas the same limit, and the PR description records it. I do not count it against this PR. - Note (not counted): the instructions said the open Lows go to a follow-up PR. That does not change how I review: I listed them above and counted them in the Verdict line.
- Note (not counted): as in the last round, the
create-onlyetag premise is only tested against a mockedHive. Its correctness depends on how the hive behaves. test-time-budget: no check run was found on this commit. The check is not required onmaster(branch protection and rulesets list no required checks).
Blast radius
The new code is limited to limacharlie/commands/deception.py and limacharlie/sdk/deception.py. Both load lazily through _COMMAND_MODULE_MAP. Shared code only gains entries: one module-map entry and the deception discovery profile. So top-level help, completion and discovery listings now show the group. Hive, HiveRecord, Extensions and the output helpers are used but not changed. _out changes table-mode printing for deception commands only. At runtime, config set and config enable write the shared extension_config/ext-deception record. extension config-set, hive and sync edit the same record.
This review was generated automatically by Claude Code.
What
A new
limacharlie deceptioncommand group and SDK class (limacharlie.sdk.deception.Deception) for theext-deceptionextension. Until now the CLI had nothing Deception-specific: every action went throughextension request --data '<json>'.Each user-facing request of the extension gets a subcommand with typed flags, named after the extension's own request fields:
config get/set/enableextension_configrecordext-deceptionkinds,plan,deploy,rollout-status,restore-ruleslist_kinds,plan,deploy,rollout_status,restore_ruleslist,list-hosts,verify,rotate,removelist,list_hosts,verify,rotate,removecoverage,test-fire,list-test-runs,list-test-pathslist-hits,list-readerslist_hits,list_readersdrops create/list/get/update/rotate/delete/draft-documentcreate_drop,list_drops,get_drop,update_drop,rotate_drop,delete_drop,draft_drop_documentuninstall,uninstall-statusuninstall,uninstall_statusChoices made:
config settakes the bare configuration or a record asconfig getprints it. The etag in that record (or--etag) makes the write a compare-and-set, soconfig get > f; edit; config set --input-file fnever overwrites someone else's save. A record that does not exist yet is created enabled: a disabled record gives the extension an empty configuration, which is the trap the docs warn about forextension config-set. Creation is conditional (create-only etag), so a record created meanwhile is not replaced. An existing record keeps its metadata unless--enabled/--disabledor ausr_mtdblock is given.--confirm:remove,drops delete, anduninstall(except--cancel).drops update/drops rotateare compare-and-set on the drop's version;--versiondefaults to the current one, read just before.--save PATHondrops create/get/rotatewrites the document (checked against itssha256) or the QR code SVG. The answer is printed first, so a create's value is never lost if the file cannot be written.list-hits --event-typeis repeatable: one value sendsevent_type, several sendevent_types.--auto-response-outcomeis repeatable and sent comma-joined, as the extension expects.The three hand-maintained maps are updated:
_COMMAND_MODULE_MAP, a newdeceptiondiscovery profile (no existing profile fits a product group, as withemail_securityandinvestigation_engine), anddoc/cli/deception.md. The SDK class is documented indoc/sdk/security-products.md.Permissions
No new permission: requests need
ext.requestand the record needsext.conf.get/ext.conf.set, asextension requestandextension config-get/config-setalready do.config setreads the stored metadata first (ext.conf.getorext.conf.get.mtd). Stated in the changelog.Tests
tests/unit/test_cli_deception.pyruns the commands through the real SDK with only the extension request and the hive mocked, and checks the exact request the extension receives: flag-to-field mapping, list encodings, the confirm gates, draft plan file loading, drop version read-before-write,--save(including a hash mismatch that writes nothing but still prints the answer), and everyconfig setmetadata and etag case. Discovery coverage of the group is pinned both ways, and every leaf command has an--ai-helptext.pytest tests/unit/ tests/microbenchmarks/: 6620 passed (151 skipped, all pre-existing).Review rounds
Round 1 (both reviewers NOT_APPROVED) was fixed in b8d7bc6:
config setchecks the record exists on every path, and--enabledwrites on the etag its metadata was read with. In a terminal, lists show their rows as a table and the rest as YAML, and other answers print as YAML, so no token is cut.restore-rulesfails unless every rule reads back enabled.--saverefuses url/hostname drops before creating them. Round 2:/lc-reviewAPPROVED.Left open:
config set's metadata read and its write recreates the record, because the hive ignores an etag once the record is gone. No client can close that window; it needs an atomic "must exist and match" condition in the hive.hive set --etaghas the same behaviour.drops rotate --saveon a url or hostname drop should refuse before rotating.restore-rulesexit tests for an all-successful answer,enabled: falsealone anderroralone.--saveshould write to a temporary file and rename it, so a failed write never leaves a truncated file behind a message saying nothing was written.🤖 Generated with Claude Code