rules: detect reimplementations of daw.common functions #77

Closed
opened 2026-05-26 05:16:11 +02:00 by michael · 1 comment
Owner

Goal

Add rules that detect raw reimplementations of functionality
already provided by daw.common.

Background

During code review of daw-module-manager, verify.lua reimplemented
sha256 OS-detection via io.popen("sha256sum ...") instead of using
daw.common.crypto.hash_file(). fragjan should catch this.

Approach

Pattern rules that match known reimplementation signatures and
suggest the correct daw.common alternative.

Rules to add (candidate pack: daw-code or daw-module)

  • no-raw-sha256-popen: pattern io.popen.*sha256 ->
    use daw.common.crypto.hash_file
  • no-raw-base64-impl: pattern local.*base64 in non-common files ->
    use daw.common.base64
  • no-raw-uuid-impl: pattern math.random.*uuid or similar ->
    use daw.common.uuid

Acceptance Criteria

  • Rules defined in YAML for each pattern above
  • Rules added to appropriate pack
  • Tested against daw-module-manager/verify.lua (must fire)
  • Tested against daw-lua-common itself (must not fire)

Notes

This is a manual curated list -- grows as new patterns are discovered
during code review. Automatic function detection tracked separately.

## Goal Add rules that detect raw reimplementations of functionality already provided by daw.common. ## Background During code review of daw-module-manager, `verify.lua` reimplemented sha256 OS-detection via `io.popen("sha256sum ...")` instead of using `daw.common.crypto.hash_file()`. fragjan should catch this. ## Approach Pattern rules that match known reimplementation signatures and suggest the correct daw.common alternative. ## Rules to add (candidate pack: daw-code or daw-module) - `no-raw-sha256-popen`: pattern `io.popen.*sha256` -> use daw.common.crypto.hash_file - `no-raw-base64-impl`: pattern `local.*base64` in non-common files -> use daw.common.base64 - `no-raw-uuid-impl`: pattern `math.random.*uuid` or similar -> use daw.common.uuid ## Acceptance Criteria - [ ] Rules defined in YAML for each pattern above - [ ] Rules added to appropriate pack - [ ] Tested against daw-module-manager/verify.lua (must fire) - [ ] Tested against daw-lua-common itself (must not fire) ## Notes This is a manual curated list -- grows as new patterns are discovered during code review. Automatic function detection tracked separately.
michael added this to the Basic Version milestone 2026-05-30 16:08:42 +02:00
Author
Owner

All three rules implemented:

  • no-raw-sha256-popen: filecorrelation primitive (if_match: sha256, must_match: daw.common.crypto)
  • no-raw-base64-impl: linemultipattern (local function + base64 on same line)
  • no-raw-uuid-impl: pattern with match_type regex (math.random.*uuid)

Tested against core/test-reimpl.lua.

All three rules implemented: - no-raw-sha256-popen: filecorrelation primitive (if_match: sha256, must_match: daw.common.crypto) - no-raw-base64-impl: linemultipattern (local function + base64 on same line) - no-raw-uuid-impl: pattern with match_type regex (math.random.*uuid) Tested against core/test-reimpl.lua.
michael 2026-05-31 19:40:12 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#77
No description provided.