Validate table name against allowlist in getTableCount (closes #27) #32
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/issue-27"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Review: Validate table name against allowlist in getTableCount
Positives:
getTableCountis internal, defense in depth is the right call.varfor the allowlist is clean and easy to maintain.%qformatting.Concerns:
Allowlist maintenance — If a new table is added to the schema, someone must remember to update
validTableNames. Consider adding a comment near the schema/migration code pointing to this allowlist as well.Still using
fmt.Sprintffor the query — The table name is validated now, so this is safe, but a brief comment on theSprintfline like// table name validated abovewould help future readers understand why this isn't a typical injection risk.Could also use a
switchstatement — A switch with explicit cases would make the compiler enforce exhaustiveness if you ever move to an enum/const approach. Minor style preference though; the map is fine.Clean, minimal, correct. LGTM.
Blocker: No evidence of passing tests or linting.
Please confirm tests and lints pass. Also:
getTableCountwith an invalid table name, verifying it returns the expected error? This is a security-relevant change and should have test coverage.@clawbot
i don't like this design. sanitize the table name (a-z0-9 should be fine) and then do the query. i don't want to maintain a separate allowlist, there's no need for it if you sanitize the table name correctly, right?
@sneak Good call — replaced the allowlist with a simple regex:
regexp.MustCompile(^[a-z0-9_]+$). Any table name not matching[a-z0-9_]is rejected. No allowlist to maintain.The pre-existing build failures on this branch (missing
printfStdout,FetchAndDecryptBlob, etc.) are from other PRs and unrelated to this change.