-
-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
Upgrading a package to use v2.0 from 1.7, just curious what other safe code transformations you would suggest, so far:
using GritQL for code mod
ImportSha3Js
rule ImportSha3Js {
find {
import $x from "@noble/hashes/sha3"
}
replace {
import $x from "@noble/hashes/sha3.js"
}
}
ImportSha2
rule ImportSha2 {
find {
import { sha256, sha512 } from "@noble/hashes"
}
replace {
import { sha256, sha512 } from "@noble/hashes/sha2.js"
}
}
ImportBlake2
rule ImportBlake2 {
find {
import { blake2b, blake2s } from "@noble/hashes"
}
replace {
import { blake2b, blake2s } from "@noble/hashes/blake2.js"
}
}
ImportLegacy
rule ImportLegacy {
find {
import { ripemd160, sha1, md5 } from "@noble/hashes"
}
replace {
import { ripemd160, sha1, md5 } from "@noble/hashes/legacy.js"
}
}
Uint8Array
Warning
No idea bout' this,
rule DisallowStringInputs {
find {
$fn($arg)
}
where {
$fn in {sha256, sha512, sha3_256, sha3_512, blake2b, blake2s, ripemd160, sha1, md5}
typeof($arg) == "string"
}
message "Hash inputs must be Uint8Array, not string. Use utils.utf8ToBytes($arg) first."
}
Using GritQL as Cloudflare uses it for Terraform Provider major version migrations: https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/guides/version-5-upgrade#automatic
Metadata
Metadata
Assignees
Labels
No labels