cyberchef/tests/operations/tests/RegularExpression.mjs
GCHQ Developer 85297 535838146c
Regular Expression operation email address regex: Support IPv4 domains (#2167)
Co-authored-by: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com>
2026-04-13 13:04:33 +01:00

76 lines
2.1 KiB
JavaScript

/**
* Regular Expression tests.
*
* @author C85297 [95289555+C85297@users.noreply.github.com]
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
import { EMAIL_REGEX } from "../../../src/core/lib/Extract.mjs";
TestRegister.addTests([
{
name: "Regular Expression - built in email regex - IP address",
input: "yaunwfkb\nexample@[127.0.0.1]\n091nvka",
expectedOutput: "example@[127.0.0.1]",
recipeConfig: [
{
op: "Regular expression",
args: [
"Email address",
EMAIL_REGEX.source,
true,
true,
false,
false,
false,
false,
"List matches",
],
},
],
},
{
name: "Regular Expression - built in email regex - invalid IP address",
input: "yaunwfkb\nfalse_positive@[1.2.3.]\n091nvka",
expectedOutput: "",
recipeConfig: [
{
op: "Regular expression",
args: [
"Email address",
EMAIL_REGEX.source,
true,
true,
false,
false,
false,
false,
"List matches",
],
},
],
},
{
name: "Regular Expression - built in email regex - IPv4 from #2318",
input: "user@[1.2.3.4]\ntest@[192.168.0.1]\nno-match@[1.2.3.]",
expectedOutput: "user@[1.2.3.4]\ntest@[192.168.0.1]",
recipeConfig: [
{
op: "Regular expression",
args: [
"Email address",
EMAIL_REGEX.source,
true,
true,
false,
false,
false,
false,
"List matches",
],
},
],
},
]);