conventions.j
use io;
use json;
use xml;
use strings;
use crypto;
def deep as string init strings.replicate("[", 2000) + strings.replicate("]", 2000);
try {
json.decode($deep);
} catch (e) {
io.printf("json.decode, too deep: %s\n", $e.kind);
}
def nested as string init strings.replicate("<a>", 2000) + strings.replicate("</a>", 2000);
try {
xml.decode($nested);
} catch (e) {
io.printf("xml.decode, too deep: %s\n", $e.kind);
}
try {
json.decode('{"a":');
} catch (e) {
io.printf("json.decode, malformed: %s\n", $e.kind);
}
def key as bytes init crypto.randBytes(32);
def nonce as bytes init crypto.randBytes(12);
try {
crypto.decrypt("aes-gcm", crypto.randBytes(40), $key, $nonce, crypto.randBytes(0));
} catch (e) {
io.printf("crypto.decrypt, forged: %s\n", $e.kind);
}