Weak hash
This is how the comment reads inline, under the flagged line.
Why it matters
MD5 and SHA-1 have practical collisions. Fine for cache keys, wrong for passwords, signatures or integrity checks.
What to do
SHA-256 for integrity, a password hash (argon2, bcrypt, scrypt) for passwords. Mark non-security uses explicitly.
Examples
crypto.createHash('md5').update(password)await argon2.hash(password)
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
crypto.createHash('md5');src/app.py
hashlib.md5(b)
Left alone
crypto.createHash('sha256');Research
MD5 or SHA-1 for security, and `Math.random` or `random` for tokens. Hashes collide, and tokens become predictable.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"weak-hash"
],
"severity": {
"weak-hash": "medium"
}
}
}
createHash('md5')is broken for security use.