Repository navigation
feat(rules): add Move review rules - #959
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). |
72dc259 to
7af2b97
Compare
wu21-web
left a comment
There was a problem hiding this comment.
I suggest putting **/*.move and **/Move.toml together in the site documentation for readability, but it is a minor issue. LGTM.
1ecd1b1 to
7a0f081
Compare
|
@lizhengfeng101 Please review and merge this. Future main updates might cause more conflicts. I resolved conflicts 3 times now... Thanks :) |
7a0f081 to
8015655
Compare
|
@lizhengfeng101 Rebased onto main and conflicts resolved. Please review and merge this. Thanks :) |
|
@lizhengfeng101 Rebased onto main and conflicts resolved again. Please review this. Thanks :) |
|
Thanks for the contribution! The rule doc is well-structured and the test coverage looks solid. Since Move is still a relatively niche language, I'd prefer to hold off on merging for now and wait for community members who actively develop in Move (or language experts) to review the rule doc for accuracy. Smart contract review rules carry high stakes — an incorrect rule could either produce false positives or, worse, miss real vulnerabilities. I'll leave this open and revisit once we get domain-expert feedback. |
Qiyuanqiii
left a comment
There was a problem hiding this comment.
Thanks for the thorough implementation. I reviewed the proposed default rule documents against the official Move, Sui, and Aptos documentation. The allowlist, routing, and test work looks solid, but several statements in move.md and move_toml.md currently contradict documented platform semantics or restate compiler-enforced checks as review findings. Because these documents would be injected as the defaults for every Move review, those statements would create systematic false positives.
I am requesting changes only for the seven concrete accuracy and platform-gating issues called out inline. Please revise or remove those rules while preserving the useful Sui/Aptos/core-Move distinction already established by the document.
This is an evidence-based documentation review. I am not presenting it as a substitute for the active Move-developer review requested by the maintainer.
| @@ -0,0 +1,18 @@ | |||
| #### Move Package Manifest Hygiene | |||
| - Git dependencies pinned to a branch or moving tag rather than a full commit hash: `rev = "main"`, `rev = "mainnet"`, and `rev = "framework/testnet"` all resolve differently over time, so the bytecode published today may not be the bytecode published tomorrow | |||
There was a problem hiding this comment.
This would flag official manifests. The Move Reference explicitly allows rev to be a branch, tag, or commit, and explains that a committed Move.lock records fixed dependency revisions for reproducible builds. The official Aptos package example itself uses rev = "mainnet".
Please narrow this to evidence that resolution is not fixed - for example, a missing or uncommitted lockfile, or an unexpected Move.lock resolution change - rather than treating a branch or tag as a defect by itself.
Sources: Move package reference | Aptos package guide
| - `local =` paths that are absolute or reach outside the repository, which do not resolve on another machine or in CI | ||
| - Dependencies added to `[dependencies]` when they are only used by tests, which publishes them as part of the package | ||
|
|
||
| #### Addresses and Publication |
There was a problem hiding this comment.
"_" is a documented named-address parameter, not inherently an invalid publication address. The Move package reference shows that it can be instantiated by a dependent package, and the official Aptos create-package example deliberately declares hello_blockchain = "_".
Please flag this only when the effective build or publish inputs leave a required address unresolved or resolve it to the wrong address, rather than flagging the placeholder itself.
Sources: Move package reference | Aptos package guide
|
|
||
| #### Addresses and Publication | ||
| - `[addresses]` entries left as the `"_"` placeholder in a package that is meant to be published, which fails or resolves to an unintended address | ||
| - Named addresses changed in place for an already-published package, silently retargeting every reference |
There was a problem hiding this comment.
The documented package semantics do not allow these sections to silently leak into an ordinary build: [dev-dependencies] and [dev-addresses] are included only in dev/test modes.
Please remove this rule or require concrete evidence that the project build explicitly enables a dev/test mode (or uses nonstandard tooling with different semantics).
Source: Move package manifest reference
| - `acquires` annotations that no longer reflect the resources a function reaches after the change | ||
| - Aborts raised with a bare integer where the module otherwise uses categorized `error::` constructors, losing the client-visible error category | ||
|
|
||
| #### Object Model and Sharing (Sui) |
There was a problem hiding this comment.
This describes a successful Owned -> Shared conversion, but Sui documents the opposite behavior: only an object created in the same transaction can be shared, and attempting to share an already-owned object aborts with ESharedNonNewObject.
Please rewrite this as a reachable-abort check when a pre-existing owned object can reach share_object. Whether a newly created object should be shared is a separate authorization/design question and needs evidence from the intended access policy.
Source: Sui storage functions - Share
| - `transfer::transfer` versus `transfer::public_transfer` chosen inconsistently with the type's `store` ability and the custody the caller expects | ||
| - A value sent to `ctx.sender()` where returning it to the caller would compose better and keeps the PTB in control of its destination (`self_transfer`) | ||
| - Wrapping a shared or frozen object inside another object, which strands it (`freeze_wrapped`) | ||
| - `&TxContext` on a public function that will need mutation later, forcing a breaking signature change (`prefer_mut_tx_context`) |
There was a problem hiding this comment.
Please revise both this rule and the earlier generic underlying-id rule. The id: UID layout is an additional Sui-verifier requirement, not a generic key rule, so the first half is compiler-enforced on Sui and does not apply to Aptos/core Move. Even on Sui, retaining a UID after destroying the containing object can be intentional (the documented proof-of-deletion pattern), so unconditional id.delete() is not always required.
A higher-confidence lifecycle check is deleting a parent UID before removing its dynamic fields or received children, which can leave state permanently inaccessible.
Sources: Move abilities reference | Sui key ability | Sui UID lifecycle | Sui dynamic fields
| - Wrapping a shared or frozen object inside another object, which strands it (`freeze_wrapped`) | ||
| - `&TxContext` on a public function that will need mutation later, forcing a breaking signature change (`prefer_mut_tx_context`) | ||
| - A `key` struct whose first field is not `id: UID`, or a destroy path that does not call `id.delete()` | ||
|
|
There was a problem hiding this comment.
For current Sui Move, public is already transaction-callable and adding entry gives the function no additional permissions or restrictions. That is why the compiler reports public_entry as an unnecessary-modifier lint; it does not by itself widen the callable surface.
Please remove this as a security finding or platform-qualify it around a concrete authorization/composability defect rather than the modifier alone.
Sources: Sui visibility modifiers | Sui lint reference
| - Named `const E*` abort code values changed or renumbered: clients and indexers match on them, so a renumbering is a breaking change even though the code still compiles | ||
| - State changes that indexers depend on made without emitting the corresponding event, or an event's fields changed in place | ||
| - Struct fields or public function signatures changed in ways that violate Sui upgrade compatibility or Aptos `upgrade_policy = "compatible"` | ||
| - `#[test_only]` mint, admin, or fixture functions reachable from a non-test build, or test-only imports leaking into published bytecode |
There was a problem hiding this comment.
Under the documented Sui compilation model, #[test_only] items are compiled only in test mode and are excluded from normal builds. Artifacts built with any mode enabled, including test mode, are explicitly non-publishable. Therefore these items cannot normally leak into published bytecode.
Please remove this rule or gate it on evidence that a nonstandard toolchain bypasses the documented compile-time and publishability checks.
Sources: Sui compilation modes | Move unit-testing reference
|
While I’ve put forward this change proposal, it is no substitute for a proper review from Move community developers. As @lizhengfeng101 noted, Move is still a relatively niche language. My knowledge of it only comes from what I picked up incidentally while learning Rust — after all, Move’s ownership model draws inspiration from Rust, and the core Move VM is also implemented in Rust. That said, I have no hands-on experience building with Move. It’s a purpose-built language for virtual machines, primarily used for digital tokens and financial-related scenarios. I haven’t worked with it extensively, so this will need further review from someone with deep expertise in the language. |
|
@chethanuk HEADS UP: If no activity occurs on this pull, I will closed this as superseded by #1829 |
So the author of this new PR clearly does not meet the criteria for active Move developers mentioned by lizhengfeng… In my opinion, this is quite rough |
|
@Qiyuanqiii Quality is the only standard. |
Move source files were not reviewed: `.move` was absent from the extension allowlist, so both filter call sites dropped them at the `IsAllowedExt` gate before any rule could run. `Move.toml` was already reachable (`.toml` is allowlisted) but fell through to `default.md`. Adds `.move` to the allowlist, four Move-scoped exclude patterns, and two rule docs wired into `path_rule_map`: `move.md` for source and `move_toml.md` for the manifest, following the existing `cargo_toml.md` split. Data only, no Go source changes. The exclude patterns are scoped by extension (`**/build/**/*.move`, not a bare `**/build/**`) because `IsExcludedPath` applies every pattern to every path with no language dispatch; an unscoped `build/` pattern would also drop Java, Gradle, TypeScript and CMake output. Three negative rows in `TestIsExcludedPath` pin that down and fail if the pattern is broadened. Both `*_test.move` and `*_tests.move` are excluded. The singular is as common as the plural and frequently sits in `sources/` rather than `tests/` (e.g. aptos-core's `move-examples/hello_blockchain/sources/hello_blockchain_test.move`), where neither the `tests/` nor the plural pattern reaches it. This mirrors the singular/plural pairs the file already carries for Java and Swift. Behaviour change: `.move` diffs that were previously skipped are now reviewed. Users opt out via user exclude globs, which are checked before the allowlist. Evidence: `go test -race ./...` passes; `TestResolve_DefaultRules` resolves `.move` to move.md and `Move.toml` to move_toml.md via unique heading anchors.
Several rules flagged documented, valid Move patterns: branch revs that Move.lock pins, the "_" address placeholder, dev-only manifest sections, and #[test_only] items that never reach published bytecode. Others described behaviour Sui rejects (sharing an owned object aborts) or restated compiler checks (id: UID layout, public entry on Sui). Narrow or replace each one and gate the platform-specific ones to Sui or Aptos. The Move.toml precedence test now anchors on Move.lock, since the rev = "main" example is gone. Signed-off-by: ChethanUK <[email protected]>
…ources Drop bullets the compiler or upgrade check already rejects (acquires, overlapping borrows, struct/signature upgrade changes, weakened upgrade_policy), fix the transfer, freeze_wrapped, entry and dev-dependencies claims, add Sui version-gating after upgrade, and exempt #[test_only]. Add nested-package exclusion test rows. Signed-off-by: ChethanUK <[email protected]>
04be87d to
a03f607
Compare
|
Two concrete follow-ups from reviewing head 1. Required correction: distinguish valid Sui environment overrides from actual mismatchesIn For example, the default dependency can use commit A while the mainnet replacement uses commit B and points to the mainnet package published from B. That difference alone is not a bug. Likewise, independently deployed testnet and mainnet packages can legitimately have different IDs. Please revise these checks to require evidence of a mismatch between the effective dependency and publication data within the selected environment, rather than differences between defaults and overrides or between networks. Otherwise, valid multi-environment configurations become false-positive targets. 2. Verification: supplement routing tests with focused semantic checksThe added tests establish extension filtering and rule routing, but heading/pattern assertions cannot validate the Move-specific advice. Please add or record a small Sui/Aptos review sanity check, identifying the toolchain versions and including:
A short recorded smoke test is sufficient for this targeted validation; this is not a request for a full blockchain benchmark. It would complement, not replace, the domain-expert review already requested in this thread. Please also rerun the affected tests with For transparency, the supporting OCR run completed with zero findings across three selected items; that result does not establish coverage or correctness of the new rule prose. AI disclosure: This feedback was prepared with Codex; OpenCodeReview ( |
|
Hi @chethanuk, a quick follow-up on the two items above: any update on the Sui environment-override rule correction and the small Sui/Aptos sanity check? Please let us know if you are blocked on either item. Thanks! |
Signed-off-by: ChethanUK <[email protected]>
|
Thanks this looks great too with the requested changes! |
Description
.movefiles were never reviewed. The extension is missing fromsupported_file_types.json, soIsAllowedExtdrops them at the filter gate before any rule can run.Move.tomlwas already reachable (.tomlis allowlisted) but fell through to the genericdefault.md.This adds
.moveto the allowlist and registers two rule docs inpath_rule_map:**/*.move→move.mdfor source,**/Move.toml→move_toml.mdfor the package manifest. The manifest gets its own short doc for the same reasoncargo_toml.mdandpom_xml.mddo — what goes wrong there (git deps pinned torev = "main", named addresses changed in place on a published package,dep-replacementsdrifting between testnet and mainnet) has nothing to do with the source-level checks. Data only, no Go source changes.The four exclude patterns are scoped by extension (
**/build/**/*.move, not a bare**/build/**).IsExcludedPathapplies every pattern to every path with no language dispatch, so an unscopedbuild/pattern would also drop Java, Gradle, TypeScript and CMake output. That is why the file already carries**/Tests/**/*.swiftand**/tests/**/*.nimrather than the directory alone. Three negative rows inTestIsExcludedPathfail if anyone broadens it later.Both
*_test.moveand*_tests.moveare excluded. The singular is as common as the plural in Move and usually sits insources/next to the code rather than undertests/, where the directory pattern never reaches it.Limitation
.movediffs that used to be skipped are now reviewed. Anyone who does not want that opts out with user exclude globs, which are checked before the allowlist.Type of Change
How Has This Been Tested?
make testpasses locallyRows appended to the existing table tests, plus one new test:
TestIsAllowedExt—.moveand.MOVE.TestIsExcludedPath— the four new patterns, plus three negatives (frontend/build/index.ts,build/classes/com/example/Foo.java,build/main.go) that fail if thebuild/pattern loses its extension scope.TestResolve_DefaultRules— source and manifest paths resolve by heading anchors unique to each doc.TestResolveDetail_SystemMoveTomlPatternPrecedesMove(new) — pinsMove.tomlto the**/Move.tomlpattern, including the uppercase spelling.Checklist
go fmt,go vet)The rule table in
pages/src/content/docs/{en,ja,ru,zh}/review-rules.mdlists both new patterns.Related Issues
Part of #470.