diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index e90ab51f..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.github/ISSUE_TEMPLATE/operation-request.md b/.github/ISSUE_TEMPLATE/operation-request.md index d88e6703..05231a86 100644 --- a/.github/ISSUE_TEMPLATE/operation-request.md +++ b/.github/ISSUE_TEMPLATE/operation-request.md @@ -7,8 +7,14 @@ assignees: '' --- -## Summary +**Is your operation request related to a problem? Please describe.** +A clear and concise description of what the problem is. E.g. I'm always frustrated when [...] -### Example Input +**Describe the solution you'd like** +A clear and concise description of the new operation you would like. -### Example Output +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Example input and output** +Provide an example input to the operation, along with the output that you would expect. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..8d6cc970 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +**Description** +Provide a description of the pull request and the changes that it makes. + +**Existing Issue** +If this pull request relates to an existing issue in the repository, please link it here. + +**Screenshots** +If the pull request changes any visual aspects of CyberChef, please include screenshots. + +**AI disclosure** +If you have used any AI tools while creating this code, **you must declare your usage along with the name of the tools that you used**. +Regardless of AI tool usage, you are responsible for any code that you submit, and we expect you to have checked the code and have enough of an understanding of it to answer any questions we might have. + +**Test Coverage** +Please ensure you have added test coverage for your changes. diff --git a/.github/CONTRIBUTING.md b/CONTRIBUTING.md similarity index 100% rename from .github/CONTRIBUTING.md rename to CONTRIBUTING.md diff --git a/package-lock.json b/package-lock.json index 607aeca3..ed4d1c8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "file-saver": "^2.0.5", "flat": "^6.0.1", "geodesy": "1.1.3", - "handlebars": "^4.7.8", + "handlebars": "^4.7.9", "hash-wasm": "^4.12.0", "highlight.js": "^11.11.1", "ieee754": "^1.2.1", @@ -75,7 +75,7 @@ "moment": "^2.30.1", "moment-timezone": "^0.6.1", "ngeohash": "^0.6.3", - "node-forge": "^1.3.3", + "node-forge": "^1.4.0", "node-md6": "^0.1.0", "nodom": "^2.4.0", "notepack.io": "^3.0.1", @@ -114,14 +114,14 @@ "@babel/preset-env": "^7.29.2", "@babel/runtime": "^7.29.2", "@codemirror/commands": "^6.10.3", - "@codemirror/language": "^6.12.2", + "@codemirror/language": "^6.12.3", "@codemirror/search": "^6.6.0", "@codemirror/state": "^6.5.4", "@codemirror/view": "^6.40.0", "autoprefixer": "^10.4.27", "babel-loader": "^10.1.1", "base64-loader": "^1.0.0", - "chromedriver": "^130.0.4", + "chromedriver": "^146.0.6", "cli-progress": "^3.12.0", "colors": "^1.4.0", "compression-webpack-plugin": "^11.1.0", @@ -145,7 +145,7 @@ "grunt-zip": "^1.0.0", "html-webpack-plugin": "^5.6.6", "imports-loader": "^5.0.0", - "mini-css-extract-plugin": "2.10.1", + "mini-css-extract-plugin": "2.10.2", "modify-source-webpack-plugin": "^4.1.0", "nightwatch": "^3.15.0", "postcss": "^8.5.8", @@ -1853,9 +1853,9 @@ } }, "node_modules/@codemirror/language": { - "version": "6.12.2", - "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.2.tgz", - "integrity": "sha512-jEPmz2nGGDxhRTg3lTpzmIyGKxz3Gp3SJES4b0nAuE5SWQoKdT5GoQ69cwMmFd+wvFUhYirtDTr0/DRHpQAyWg==", + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.3.tgz", + "integrity": "sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==", "dev": true, "license": "MIT", "dependencies": { @@ -6246,26 +6246,36 @@ } }, "node_modules/chromedriver": { - "version": "130.0.4", - "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-130.0.4.tgz", - "integrity": "sha512-lpR+PWXszij1k4Ig3t338Zvll9HtCTiwoLM7n4pCCswALHxzmgwaaIFBh3rt9+5wRk9D07oFblrazrBxwaYYAQ==", + "version": "146.0.6", + "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-146.0.6.tgz", + "integrity": "sha512-FIRi3hy0nRiyirK03etVXEpYTIodevFcvTBAM5ZCq+pX3w31jLm6JE8BVW1ypAVLvSp6HJDvboCcdgUroS3miw==", "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { "@testim/chrome-version": "^1.1.4", - "axios": "^1.7.4", + "axios": "^1.13.5", "compare-versions": "^6.1.0", "extract-zip": "^2.0.1", - "proxy-agent": "^6.4.0", - "proxy-from-env": "^1.1.0", + "proxy-agent": "^6.5.0", + "proxy-from-env": "^2.0.0", "tcp-port-used": "^1.0.2" }, "bin": { "chromedriver": "bin/chromedriver" }, "engines": { - "node": ">=18" + "node": ">=20" + } + }, + "node_modules/chromedriver/node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" } }, "node_modules/ci-info": { @@ -7127,9 +7137,9 @@ } }, "node_modules/cspell-glob/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", "engines": { @@ -10628,9 +10638,9 @@ "license": "MIT" }, "node_modules/handlebars": { - "version": "4.7.8", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", - "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", + "version": "4.7.9", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.9.tgz", + "integrity": "sha512-4E71E0rpOaQuJR2A3xDZ+GM1HyWYv1clR58tC8emQNeQe3RH7MAzSbat+V0wG78LQBo6m6bzSG/L4pBuCsgnUQ==", "license": "MIT", "dependencies": { "minimist": "^1.2.5", @@ -13103,9 +13113,9 @@ } }, "node_modules/mini-css-extract-plugin": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.10.1.tgz", - "integrity": "sha512-k7G3Y5QOegl380tXmZ68foBRRjE9Ljavx835ObdvmZjQ639izvZD8CS7BkWw1qKPPzHsGL/JDhl0uyU1zc2rJw==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.10.2.tgz", + "integrity": "sha512-AOSS0IdEB95ayVkxn5oGzNQwqAi2J0Jb/kKm43t7H73s8+f5873g0yuj0PNvK4dO75mu5DHg4nlgp4k6Kga8eg==", "dev": true, "license": "MIT", "dependencies": { @@ -13768,9 +13778,9 @@ } }, "node_modules/node-forge": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.3.tgz", - "integrity": "sha512-rLvcdSyRCyouf6jcOIPe/BgwG/d7hKjzMKOas33/pHEr6gbq18IK9zV7DiPvzsz0oBJPme6qr6H6kGZuI9/DZg==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.0.tgz", + "integrity": "sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==", "license": "(BSD-3-Clause OR GPL-2.0)", "engines": { "node": ">= 6.13.0" @@ -14678,9 +14688,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", "dev": true, "license": "MIT", "engines": { @@ -17214,9 +17224,9 @@ } }, "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 4c188560..3dbf2c8f 100644 --- a/package.json +++ b/package.json @@ -45,14 +45,14 @@ "@babel/preset-env": "^7.29.2", "@babel/runtime": "^7.29.2", "@codemirror/commands": "^6.10.3", - "@codemirror/language": "^6.12.2", + "@codemirror/language": "^6.12.3", "@codemirror/search": "^6.6.0", "@codemirror/state": "^6.5.4", "@codemirror/view": "^6.40.0", "autoprefixer": "^10.4.27", "babel-loader": "^10.1.1", "base64-loader": "^1.0.0", - "chromedriver": "^130.0.4", + "chromedriver": "^146.0.6", "cli-progress": "^3.12.0", "colors": "^1.4.0", "compression-webpack-plugin": "^11.1.0", @@ -76,7 +76,7 @@ "grunt-zip": "^1.0.0", "html-webpack-plugin": "^5.6.6", "imports-loader": "^5.0.0", - "mini-css-extract-plugin": "2.10.1", + "mini-css-extract-plugin": "2.10.2", "modify-source-webpack-plugin": "^4.1.0", "nightwatch": "^3.15.0", "postcss": "^8.5.8", @@ -131,7 +131,7 @@ "file-saver": "^2.0.5", "flat": "^6.0.1", "geodesy": "1.1.3", - "handlebars": "^4.7.8", + "handlebars": "^4.7.9", "hash-wasm": "^4.12.0", "highlight.js": "^11.11.1", "ieee754": "^1.2.1", @@ -158,7 +158,7 @@ "moment": "^2.30.1", "moment-timezone": "^0.6.1", "ngeohash": "^0.6.3", - "node-forge": "^1.3.3", + "node-forge": "^1.4.0", "node-md6": "^0.1.0", "nodom": "^2.4.0", "notepack.io": "^3.0.1", diff --git a/src/core/lib/Modhex.mjs b/src/core/lib/Modhex.mjs index 4f28e9a1..ab4a7c8b 100644 --- a/src/core/lib/Modhex.mjs +++ b/src/core/lib/Modhex.mjs @@ -50,6 +50,7 @@ const HEX_ALPHABET_MAP = HEX_ALPHABET.split(""); export function toModhex(data, delim=" ", padding=2, extraDelim="", lineSize=0) { if (!data) return ""; if (data instanceof ArrayBuffer) data = new Uint8Array(data); + if (data.length === 0) return ""; const regularHexString = toHex(data, "", padding, "", 0); @@ -100,6 +101,7 @@ export function toModhex(data, delim=" ", padding=2, extraDelim="", lineSize=0) export function toModhexFast(data) { if (!data) return ""; if (data instanceof ArrayBuffer) data = new Uint8Array(data); + if (data.length === 0) return ""; const output = []; diff --git a/src/core/operations/ParseEthernetFrame.mjs b/src/core/operations/ParseEthernetFrame.mjs index 9dac5d57..0be5e1a4 100644 --- a/src/core/operations/ParseEthernetFrame.mjs +++ b/src/core/operations/ParseEthernetFrame.mjs @@ -74,17 +74,14 @@ class ParseEthernetFrame extends Operation { const ethType = Utils.byteArrayToChars(input.slice(offset, offset+2)); offset += 2; - - if (ethType === "\x08\x00") { - break; - } else if (ethType === "\x81\x00" || ethType === "\x88\xA8") { + if (ethType === "\x81\x00" || ethType === "\x88\xA8") { // Parse the VLAN tag: // [0000] 0000 0000 0000 // ^^^ PRIO - Ignored // ^ DEI - Ignored // ^^^^ ^^^^ ^^^^ VLAN ID - const vlanTag = input.slice(offset+2, offset+4); - vlans.push((vlanTag[0] & 0b00001111) << 4 | vlanTag[1]); + const vlanTag = input.slice(offset, offset+2); + vlans.push(((vlanTag[0] & 0b00001111) << 8) | vlanTag[1]); offset += 2; } else { diff --git a/tests/browser/02_ops.js b/tests/browser/02_ops.js index 5ab55451..896de7b0 100644 --- a/tests/browser/02_ops.js +++ b/tests/browser/02_ops.js @@ -354,6 +354,7 @@ module.exports = { // testOp(browser, "Tail", "test input", "test_output"); // testOp(browser, "Take bytes", "test input", "test_output"); testOp(browser, "Tar", "test input", /^file\.txt\x00{92}/); + testOp(browser, "Template", "{\"one\": 1, \"two\": 2}", "1 2", ["{{ one }} {{ two }}"]); testOpHtml(browser, "Text Encoding Brute Force", "test input", "tr:nth-of-type(4) td:last-child", /t\u2400e\u2400s\u2400t\u2400/); // testOp(browser, "To BCD", "test input", "test_output"); // testOp(browser, "To Base", "test input", "test_output"); diff --git a/tests/operations/tests/Modhex.mjs b/tests/operations/tests/Modhex.mjs index 1e0f2791..07f38910 100644 --- a/tests/operations/tests/Modhex.mjs +++ b/tests/operations/tests/Modhex.mjs @@ -147,4 +147,24 @@ dc;ii;hv;ig;hr;hf;dc;he;hj;hv;hv;ie;hg;du", } ] }, + { + name: "Empty input through From Hex and To Modhex returns empty output", + input: "", + expectedOutput: "", + recipeConfig: [ + { + "op": "From Hex", + "args": [ + "Auto" + ] + }, + { + "op": "To Modhex", + "args": [ + "Space", + 0 + ] + } + ] + }, ]); diff --git a/tests/operations/tests/ParseEthernetFrame.mjs b/tests/operations/tests/ParseEthernetFrame.mjs index c849e207..063255ed 100644 --- a/tests/operations/tests/ParseEthernetFrame.mjs +++ b/tests/operations/tests/ParseEthernetFrame.mjs @@ -23,7 +23,7 @@ TestRegister.addTests([ { name: "Parse Ethernet frame with one VLAN tag (802.1q)", input: "01000ccdcdd00013c3dfae188100a0760165aaaa", - expectedOutput: "Source MAC: 00:13:c3:df:ae:18\nDestination MAC: 01:00:0c:cd:cd:d0\nVLAN: 117\nData:\naa aa", + expectedOutput: "Source MAC: 00:13:c3:df:ae:18\nDestination MAC: 01:00:0c:cd:cd:d0\nVLAN: 118\nData:\naa aa", recipeConfig: [ { "op": "Parse Ethernet frame", @@ -34,7 +34,7 @@ TestRegister.addTests([ { name: "Parse Ethernet frame with two VLAN tags (802.1ad)", input: "0019aa7de688002155c8f13c810000d18100001408004500", - expectedOutput: "Source MAC: 00:21:55:c8:f1:3c\nDestination MAC: 00:19:aa:7d:e6:88\nVLAN: 16, 128\nData:\n45 00", + expectedOutput: "Source MAC: 00:21:55:c8:f1:3c\nDestination MAC: 00:19:aa:7d:e6:88\nVLAN: 209, 20\nData:\n45 00", recipeConfig: [ { "op": "Parse Ethernet frame",