Repository navigation
fix: apply workspace lints to every crate; random serve token - #1
Open
StephanSchipal wants to merge 1 commit into
Open
StephanSchipal wants to merge 1 commit into
StephanSchipal wants to merge 1 commit into
Conversation
Workspace lints: Cargo.toml declares [workspace.lints.clippy] (deny unwrap_used, expect_used, panic, unimplemented, todo), but no crate had `[lints] workspace = true`, so the table applied nowhere. Only devcraft-app enforced the rules through its own #![deny]. An unwrap() added to devcraft-core passed `cargo clippy -D warnings`; with this change it is rejected. A root clippy.toml allows unwrap, expect and panic in tests. No existing code needed a change. Serve token: `devcraft-mcp serve` created .devcraft/mobile.token as hex(nanos since epoch) + hex(pid), which narrows to a small search space for anyone who can guess when the companion first ran. It is now 32 bytes from the OS random source (getrandom 0.4, already in the tree), 64 hex characters. authorized() compares tokens without an early exit. An existing token file is kept; deleting it rotates the token. Tests: new_token shape and uniqueness, mobile_token create-then-reuse, token_eq, authorized() for query and Bearer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small hardening fixes.
1. Workspace lints now apply to every crate
Cargo.tomldeclares[workspace.lints.clippy], which deniesunwrap_used,expect_used,panic,unimplementedandtodo. A workspace lint table only takes effect in crates that opt in with[lints] workspace = true, and none did. So onlydevcraft-app, through its own#![deny(...)]inmain.rs, enforced the rules.devcraft-coreanddevcraft-mcpweren't checked.Proof: a temporary
pub fn probe() -> u32 { "1".parse().unwrap() }indevcraft-corepassedcargo clippy -p devcraft-core -- -D warningsonmain. With this change it fails withused unwrap() on a Result value. The probe isn't committed.[lints] workspace = trueadded to all three crates.clippy.tomlwithallow-unwrap-in-tests,allow-expect-in-testsandallow-panic-in-tests, so test code keeps itsunwraps.cargo clippy --workspace --all-targets -- -D warningspasses.2.
devcraft-mcp serve: token from OS randomness, compared without an early exitmobile_token()created the token asformat!("{:x}{:x}", nanos_since_epoch, pid). Anyone who can estimate when the companion first started only has to search a narrow range of timestamps times the possible PIDs. The token gates/api/*on the Tailnet port 11259.new_token()returns 32 bytes from the OS random source as 64 hex characters. It usesgetrandom0.4, which is already in the dependency tree, so this adds no new crate to the build.token_eq()compares the presented token without stopping at the first differing byte, andauthorized()uses it for both?token=andAuthorization: Bearer..devcraft/mobile.tokenis kept, so current bookmarks keep working. Deleting the file rotates the token; the new URL is printed atservestart-up as before.Not changed here: the token still travels in the query string (
?token=) for the iPad Safari links, so it can end up in browser history.Observation, not changed
Cargo warns that
devcraft-coredoesn't usedatabasecraft-store,thiserrorortokio; those warnings are already onmain. No source file indevcraft-corereferencesdatabasecraft_store. If that holds, dropping the dependency would also let CI and new contributors skip checking out thedatabasecraftsibling repo.Test plan
serve.rs:new_token_is_long_random_hex,mobile_token_is_created_random_then_reused(fails onmain: 20-character token),token_eq_compares_the_whole_value,authorized_needs_the_exact_token_in_query_or_bearer.cargo test --workspace: 138 passed, 1 ignored (the Today pixel test, ignored on Windows as designed). That's the baseline's 134 plus the 4 new tests.cargo clippy --workspace --all-targets -- -D warningscargo fmt --all --checkmainof craft-biz, databasecraft and egui_gantt, checked out as siblings.🤖 Generated with Claude Code