fix: crypto.lua -- assert(), wrong temp prefix, io.* direct #27

Closed
opened 2026-05-25 19:18:11 +02:00 by michael · 2 comments
Owner

Problems

  1. Header path outdated: src/lib/src/daw/lua/common/crypto.lua

  2. assert() used for argument validation instead of returning nil, err.
    Violates DAW error handling standard. All three functions affected.

  3. Hardcoded project name in temp file: /tmp/steurjan_hash_
    must be /tmp/daw_hash_ (hmac_* functions already use correct prefix).

  4. io.popen and io.open used directly -- should migrate to sys.run
    and fs.write_file long-term. Not blocking but tracked here.

  5. HMAC key written to temp file and read via $(cat ...) shell
    substitution. Key is briefly on filesystem. Check if openssl supports
    -passin file:<path> to avoid shell substitution.

## Problems 1. Header path outdated: `src/lib/src/daw/lua/common/crypto.lua` 2. `assert()` used for argument validation instead of returning nil, err. Violates DAW error handling standard. All three functions affected. 3. Hardcoded project name in temp file: `/tmp/steurjan_hash_` must be `/tmp/daw_hash_` (hmac_* functions already use correct prefix). 4. `io.popen` and `io.open` used directly -- should migrate to sys.run and fs.write_file long-term. Not blocking but tracked here. 5. HMAC key written to temp file and read via `$(cat ...)` shell substitution. Key is briefly on filesystem. Check if openssl supports `-passin file:<path>` to avoid shell substitution.
Author
Owner

Also: openssl dependency for HMAC is justified (no standard alternative for keyed-hash), but should be documented prominently in the header, separate from the sha256 section.

Also: openssl dependency for HMAC is justified (no standard alternative for keyed-hash), but should be documented prominently in the header, separate from the sha256 section.
Author
Owner

assert() replaced with nil,err. Hardcoded /tmp/steurjan_hash_* and /tmp/daw_hmac_* replaced with daw.common.fs.temp (mktemp, no custom prefix). io.open/io.popen replaced with daw.common.fs.file / daw.common.sys. Also added: shell-quoting for the user-supplied path in hash_file() (was previously interpolated unquoted into the shell command). Covered in test_crypto.lua / test_crypto_hmac.lua.

assert() replaced with nil,err. Hardcoded /tmp/steurjan_hash_* and /tmp/daw_hmac_* replaced with daw.common.fs.temp (mktemp, no custom prefix). io.open/io.popen replaced with daw.common.fs.file / daw.common.sys. Also added: shell-quoting for the user-supplied path in hash_file() (was previously interpolated unquoted into the shell command). Covered in test_crypto.lua / test_crypto_hmac.lua.
michael 2026-07-19 17:55:20 +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/daw-lua-common#27
No description provided.