Merge branch 'master' into releases/11.0.0

This commit is contained in:
GCHQDeveloper581 2026-04-27 17:17:39 +01:00 committed by GitHub
commit 631ded1812
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 804 additions and 69 deletions

View File

@ -13,6 +13,30 @@ All major and minor version changes will be documented in this file. Details of
## Details
### [10.24.0] - 2026-04-27
- Update CONTRIBUTING.md [@GCHQDeveloper581] | [#2333]
- Fix, and link, Fernet tests [@GCHQDeveloper581] | [#2335]
- [#927] added parity bit operation [@j83305] | [#1036]
- Feature md link blanks [@BjoernAkAManf] [@GCHQDeveloper581] | [#660]
- Accessibility - Add support for screenreaders in operations search [@mattnotmitt] | [#1862]
- Added metadata extraction for UUID strings. [@ko80240] | [#2322]
- chore (deps): bump the patch-updates group with 6 updates | [#2330]
- chore (deps): bump @codemirror/search from 6.6.0 to 6.7.0 | [#2331]
- (Feature) Improve CI [@GCHQDeveloper581] | [#2328]
- Update dependabot.yml [@GCHQDeveloper581] | [#2326]
- chore (deps): bump lodash, grunt-legacy-log and grunt-legacy-util | [#2327]
- chore (deps): bump the patch-updates group with 6 updates [@GCHQDeveloper581] | [#2323]
- chore (deps): bump autoprefixer from 10.4.27 to 10.5.0 | [#2324]
- chore (deps): bump dompurify from 3.3.3 to 3.4.0 | [#2321]
- chore (deps): bump follow-redirects from 1.15.11 to 1.16.0 | [#2320]
- Regular Expression operation email address regex: Support IPv4 domains [@C85297] [@GCHQDeveloper581] | [#2167]
- Rewriting fixCryptoApiImports and fixSnackbarMarkup to js to make it OS agnostic [@BigYellowHammer] | [#2298]
- chore (deps): bump basic-ftp from 5.2.1 to 5.2.2 | [#2317]
- chore (deps): bump axios from 1.13.6 to 1.15.0 | [#2316]
- chore (deps): bump webpack from 5.105.4 to 5.106.0 | [#2315]
- chore (deps): bump basic-ftp from 5.2.0 to 5.2.1 | [#2313]
- Update vulnerable dependencies [@GCHQDeveloper581] | [#2311]
### [10.23.0] - 2026-04-06
- Properly escape HTML entities in sampleDelim to avoid XSS issue [@GCHQDeveloper581] | [#2307]
- chore (deps): bump lodash from 4.17.23 to 4.18.1 | [#2304]
@ -596,6 +620,7 @@ All major and minor version changes will be documented in this file. Details of
## [4.0.0] - 2016-11-28
- Initial open source commit [@n1474335] | [b1d73a72](https://github.com/gchq/CyberChef/commit/b1d73a725dc7ab9fb7eb789296efd2b7e4b08306)
[10.24.0]: https://github.com/gchq/CyberChef/releases/tag/v10.24.0
[10.23.0]: https://github.com/gchq/CyberChef/releases/tag/v10.23.0
[10.22.0]: https://github.com/gchq/CyberChef/releases/tag/v10.22.0
[10.21.0]: https://github.com/gchq/CyberChef/releases/tag/v10.21.0
@ -872,6 +897,10 @@ All major and minor version changes will be documented in this file. Details of
[@aby-jo]: https://github.com/aby-jo
[@atsiv1]: https://github.com/atsiv1
[@fjh1997]: https://github.com/fjh1997
[@j83305]: https://github.com/j83305
[@BjoernAkAManf]: https://github.com/BjoernAkAManf
[@ko80240]: https://github.com/ko80240
[@BigYellowHammer]: https://github.com/BigYellowHammer
[8ad18b]: https://github.com/gchq/CyberChef/commit/8ad18bc7db6d9ff184ba3518686293a7685bf7b7
@ -1141,4 +1170,26 @@ All major and minor version changes will be documented in this file. Details of
[#2194]: https://github.com/gchq/CyberChef/pull/2194
[#2193]: https://github.com/gchq/CyberChef/pull/2193
[#2192]: https://github.com/gchq/CyberChef/pull/2192
[#2333]: https://github.com/gchq/CyberChef/pull/2333
[#2335]: https://github.com/gchq/CyberChef/pull/2335
[#1036]: https://github.com/gchq/CyberChef/pull/1036
[#660]: https://github.com/gchq/CyberChef/pull/660
[#1862]: https://github.com/gchq/CyberChef/pull/1862
[#2322]: https://github.com/gchq/CyberChef/pull/2322
[#2330]: https://github.com/gchq/CyberChef/pull/2330
[#2331]: https://github.com/gchq/CyberChef/pull/2331
[#2328]: https://github.com/gchq/CyberChef/pull/2328
[#2326]: https://github.com/gchq/CyberChef/pull/2326
[#2327]: https://github.com/gchq/CyberChef/pull/2327
[#2323]: https://github.com/gchq/CyberChef/pull/2323
[#2324]: https://github.com/gchq/CyberChef/pull/2324
[#2321]: https://github.com/gchq/CyberChef/pull/2321
[#2320]: https://github.com/gchq/CyberChef/pull/2320
[#2167]: https://github.com/gchq/CyberChef/pull/2167
[#2298]: https://github.com/gchq/CyberChef/pull/2298
[#2317]: https://github.com/gchq/CyberChef/pull/2317
[#2316]: https://github.com/gchq/CyberChef/pull/2316
[#2315]: https://github.com/gchq/CyberChef/pull/2315
[#2313]: https://github.com/gchq/CyberChef/pull/2313
[#2311]: https://github.com/gchq/CyberChef/pull/2311

View File

@ -6,10 +6,13 @@ There are lots of opportunities to contribute to CyberChef. If you want ideas, t
Before your contributions can be accepted, you must:
- Sign the [GCHQ Contributor Licence Agreement](https://cla-assistant.io/gchq/CyberChef)
- Fork the CyberChef repo
- Create a new branch within your fork for the changes
- Push your changes to your fork.
- Sign the [GCHQ Contributor Licence Agreement](https://cla-assistant.io/gchq/CyberChef)
- Submit a pull request.
Please note that we will ***reject*** pull requests from the master branch of your fork owing to the mess it makes of our own working repositories and the extra work entailed.
## Coding conventions

View File

@ -27,7 +27,11 @@ RUN npm run build
#########################################
# Package static build files into nginx #
#########################################
<<<<<<< releases/11.0.0
FROM nginxinc/nginx-unprivileged:1.25.1-alpine3.18 AS cyberchef
=======
FROM nginxinc/nginx-unprivileged:stable-alpine AS cyberchef
>>>>>>> master
LABEL maintainer="GCHQ <oss@gchq.gov.uk>"

54
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "cyberchef",
"version": "10.23.0",
"version": "10.24.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cyberchef",
"version": "10.23.0",
"version": "10.24.0",
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
@ -14,7 +14,7 @@
"@astronautlabs/amf": "^0.0.6",
"@blu3r4y/lzma": "^2.3.3",
"@wavesenterprise/crypto-gost-js": "^2.1.0-RC1",
"@xmldom/xmldom": "^0.8.12",
"@xmldom/xmldom": "^0.8.13",
"argon2-browser": "^1.18.0",
"arrive": "^2.5.3",
"assert": "^2.1.0",
@ -38,7 +38,7 @@
"d3": "7.9.0",
"d3-hexbin": "^0.2.2",
"diff": "^5.2.2",
"dompurify": "^3.4.0",
"dompurify": "^3.4.1",
"es6-promisify": "^7.0.0",
"escodegen": "^2.1.0",
"esprima": "^4.0.1",
@ -62,7 +62,7 @@
"jsonpath-plus": "^10.4.0",
"jsonwebtoken": "9.0.3",
"jsqr": "^1.4.0",
"jsrsasign": "^11.1.2",
"jsrsasign": "^11.1.3",
"kbpgp": "^2.1.17",
"libbzip2-wasm": "0.0.4",
"libyara-wasm": "^1.2.1",
@ -116,9 +116,9 @@
"@babel/runtime": "^7.29.2",
"@codemirror/commands": "^6.10.3",
"@codemirror/language": "^6.12.3",
"@codemirror/search": "^6.6.0",
"@codemirror/search": "^6.7.0",
"@codemirror/state": "^6.5.4",
"@codemirror/view": "^6.41.0",
"@codemirror/view": "^6.41.1",
"autoprefixer": "^10.5.0",
"babel-loader": "^10.1.1",
"base64-loader": "^1.0.0",
@ -144,7 +144,7 @@
"grunt-exec": "~3.0.0",
"grunt-webpack": "^6.0.0",
"grunt-zip": "^1.0.0",
"html-webpack-plugin": "^5.6.6",
"html-webpack-plugin": "^5.6.7",
"imports-loader": "^5.0.0",
"mini-css-extract-plugin": "2.10.2",
"modify-source-webpack-plugin": "^4.1.0",
@ -155,7 +155,7 @@
"postcss-loader": "^8.2.1",
"prompt": "^1.3.0",
"sitemap": "^9.0.1",
"terser": "^5.46.1",
"terser": "^5.46.2",
"webpack": "^5.106.2",
"webpack-bundle-analyzer": "^5.0.0",
"webpack-dev-server": "5.0.4",
@ -1857,9 +1857,9 @@
}
},
"node_modules/@codemirror/search": {
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.6.0.tgz",
"integrity": "sha512-koFuNXcDvyyotWcgOnZGmY7LZqEOXZaaxD/j6n18TCLx2/9HieZJ5H6hs1g8FiRxBD0DNfs0nXn17g872RmYdw==",
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.0.tgz",
"integrity": "sha512-ZvGm99wc/s2cITtMT15LFdn8aH/aS+V+DqyGq/N5ZlV5vWtH+nILvC2nw0zX7ByNoHHDZ2IxxdW38O0tc5nVHg==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -4915,9 +4915,9 @@
}
},
"node_modules/@xmldom/xmldom": {
"version": "0.8.12",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.12.tgz",
"integrity": "sha512-9k/gHF6n/pAi/9tqr3m3aqkuiNosYTurLLUtc7xQ9sxB/wm7WPygCv8GYa6mS0fLJEHhqMC1ATYhz++U/lRHqg==",
"version": "0.8.13",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.13.tgz",
"integrity": "sha512-KRYzxepc14G/CEpEGc3Yn+JKaAeT63smlDr+vjB8jRfgTBBI9wRj/nkQEO+ucV8p8I9bfKLWp37uHgFrbntPvw==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
@ -8580,9 +8580,9 @@
}
},
"node_modules/dompurify": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.0.tgz",
"integrity": "sha512-nolgK9JcaUXMSmW+j1yaSvaEaoXYHwWyGJlkoCTghc97KgGDDSnpoU/PlEnw63Ah+TGKFOyY+X5LnxaWbCSfXg==",
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.1.tgz",
"integrity": "sha512-JahakDAIg1gyOm7dlgWSDjV4n7Ip2PKR55NIT6jrMfIgLFgWo81vdr1/QGqWtFNRqXP9UV71oVePtjqS2ebnPw==",
"license": "(MPL-2.0 OR Apache-2.0)",
"optionalDependencies": {
"@types/trusted-types": "^2.0.7"
@ -11226,9 +11226,9 @@
}
},
"node_modules/html-webpack-plugin": {
"version": "5.6.6",
"resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.6.6.tgz",
"integrity": "sha512-bLjW01UTrvoWTJQL5LsMRo1SypHW80FTm12OJRSnr3v6YHNhfe+1r0MYUZJMACxnCHURVnBWRwAsWs2yPU9Ezw==",
"version": "5.6.7",
"resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.6.7.tgz",
"integrity": "sha512-md+vXtdCAe60s1k6AU3dUyMJnDxUyQAwfwPKoLisvgUF1IXjtlLsk2se54+qfL9Mdm26bbwvjJybpNx48NKRLw==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -12670,9 +12670,9 @@
"license": "Apache-2.0"
},
"node_modules/jsrsasign": {
"version": "11.1.2",
"resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-11.1.2.tgz",
"integrity": "sha512-GJuqiU/Grs6BaBBXMAZM9kxhsBrksZE0pF3qIfpkopMd7OMJ9zZmE/+CpV//97srfEyyyq1Ec0ELQtSlW/gPTA==",
"version": "11.1.3",
"resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-11.1.3.tgz",
"integrity": "sha512-nPnK5D/4lv0Dwr7TlzrKtAd8JlLZwFTqTUUB3NQCbtdobcRcohGFxjbPySDVh74iWUudcCsapYT6OxoyhJLhhA==",
"license": "MIT"
},
"node_modules/jszip": {
@ -17250,9 +17250,9 @@
"license": "MIT"
},
"node_modules/terser": {
"version": "5.46.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.46.1.tgz",
"integrity": "sha512-vzCjQO/rgUuK9sf8VJZvjqiqiHFaZLnOiimmUuOKODxWL8mm/xua7viT7aqX7dgPY60otQjUotzFMmCB4VdmqQ==",
"version": "5.46.2",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.46.2.tgz",
"integrity": "sha512-uxfo9fPcSgLDYob/w1FuL0c99MWiJDnv+5qXSQc5+Ki5NjVNsYi66INnMFBjf6uFz6OnX12piJQPF4IpjJTNTw==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "10.23.0",
"version": "10.24.0",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",
@ -46,9 +46,9 @@
"@babel/runtime": "^7.29.2",
"@codemirror/commands": "^6.10.3",
"@codemirror/language": "^6.12.3",
"@codemirror/search": "^6.6.0",
"@codemirror/search": "^6.7.0",
"@codemirror/state": "^6.5.4",
"@codemirror/view": "^6.41.0",
"@codemirror/view": "^6.41.1",
"autoprefixer": "^10.5.0",
"babel-loader": "^10.1.1",
"base64-loader": "^1.0.0",
@ -74,7 +74,7 @@
"grunt-exec": "~3.0.0",
"grunt-webpack": "^6.0.0",
"grunt-zip": "^1.0.0",
"html-webpack-plugin": "^5.6.6",
"html-webpack-plugin": "^5.6.7",
"imports-loader": "^5.0.0",
"mini-css-extract-plugin": "2.10.2",
"modify-source-webpack-plugin": "^4.1.0",
@ -85,7 +85,7 @@
"postcss-loader": "^8.2.1",
"prompt": "^1.3.0",
"sitemap": "^9.0.1",
"terser": "^5.46.1",
"terser": "^5.46.2",
"webpack": "^5.106.2",
"webpack-bundle-analyzer": "^5.0.0",
"webpack-dev-server": "5.0.4",
@ -97,7 +97,7 @@
"@astronautlabs/amf": "^0.0.6",
"@blu3r4y/lzma": "^2.3.3",
"@wavesenterprise/crypto-gost-js": "^2.1.0-RC1",
"@xmldom/xmldom": "^0.8.12",
"@xmldom/xmldom": "^0.8.13",
"argon2-browser": "^1.18.0",
"arrive": "^2.5.3",
"assert": "^2.1.0",
@ -121,7 +121,7 @@
"d3": "7.9.0",
"d3-hexbin": "^0.2.2",
"diff": "^5.2.2",
"dompurify": "^3.4.0",
"dompurify": "^3.4.1",
"es6-promisify": "^7.0.0",
"escodegen": "^2.1.0",
"esprima": "^4.0.1",
@ -145,7 +145,7 @@
"jsonpath-plus": "^10.4.0",
"jsonwebtoken": "9.0.3",
"jsqr": "^1.4.0",
"jsrsasign": "^11.1.2",
"jsrsasign": "^11.1.3",
"kbpgp": "^2.1.17",
"libbzip2-wasm": "0.0.4",
"libyara-wasm": "^1.2.1",

View File

@ -465,7 +465,8 @@
"Luhn Checksum",
"CRC Checksum",
"TCP/IP Checksum",
"XOR Checksum"
"XOR Checksum",
"Parity Bit"
]
},
{

View File

@ -0,0 +1,50 @@
/**
* Parity Bit functions.
*
* @author j83305 [awz22@protonmail.com]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*
*/
import OperationError from "../errors/OperationError.mjs";
/**
* Function to take the user input and encode using the given arguments
* @param input string of binary
* @param args array
*/
export function calculateParityBit(input, args) {
let count1s = 0;
for (let i = 0; i < input.length; i++) {
const character = input.charAt(i);
if (character === "1") {
count1s++;
} else if (character !== args[3] && character !== "0" && character !== " ") {
throw new OperationError("unexpected character encountered: \"" + character + "\"");
}
}
let parityBit = "1";
const flipflop = args[0] === "Even Parity" ? 0 : 1;
if (count1s % 2 === flipflop) {
parityBit = "0";
}
if (args[1] === "End") {
return input + parityBit;
} else {
return parityBit + input;
}
}
/**
* just removes the parity bit to return the original data
* @param input string of binary, encoded
* @param args array
*/
export function decodeParityBit(input, args) {
if (args[1] === "End") {
return input.slice(0, -1);
} else {
return input.slice(1);
}
}

View File

@ -1,5 +1,6 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @author ko80240 [csk.dev@proton.me]
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
@ -8,6 +9,7 @@ import * as uuid from "uuid";
import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs";
import { toHex } from "../lib/Hex.mjs";
/**
* Analyse UUID operation
@ -22,27 +24,128 @@ class AnalyseUUID extends Operation {
this.name = "Analyse UUID";
this.module = "Crypto";
this.description = "Tries to determine information about a given UUID and suggests which version may have been used to generate it";
this.description = "Operation for extracting metadata and detecting the version of a given UUID.";
this.infoURL = "https://wikipedia.org/wiki/Universally_unique_identifier";
this.inputType = "string";
this.outputType = "string";
this.args = [];
this.args = [
{
name: "Include Metadata",
type: "boolean",
value: true
}
];
}
/**
* @param {string} input
* @param {string} input - Expects a valid UUID string
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
input = input.trim();
let uuidVersion, uuidBytes;
try {
const uuidVersion = uuid.version(input);
return "UUID version: " + uuidVersion;
uuidVersion = uuid.version(input); // Re-using the uuid library to extract version
uuidBytes = uuid.parse(input); // Re-using the uuid library to parse bytes
} catch (error) {
throw new OperationError("Invalid UUID");
}
const [includeMetadata] = args;
const dv = new DataView(uuidBytes.buffer, uuidBytes.byteOffset, uuidBytes.byteLength); // Dataview helps handle the multi-byte ints
const uuidInteger = (dv.getBigUint64(0) << 64n) | dv.getBigUint64(8);
const sections = [`Version:\n${uuidVersion}`];
if (includeMetadata) {
const parser = UUID_PARSERS[uuidVersion];
const decoded = parser?.(uuidBytes, dv);
sections.push(formatDecoded(decoded));
}
sections.push(`UUID Integer:\n${uuidInteger}`);
return sections.filter(Boolean).join("\n\n");
}
}
export default AnalyseUUID;
/**
* Metadata can be extracted for versions 1, 6, and 7.
* Enum-like frozen mapping of UUID version to parser function.
*/
const UUID_PARSERS = Object.freeze({
1: parsev1v6,
6: parsev1v6,
7: parsev7,
});
/**
* Versions 1 and 6. Note 6 is a re-order of 1.
* Version 1 == layout: timeLow(32) | timeMid(16) | timeHi(12)
* Version 6 == layout: timeHi(32) | timeMid(16) | timeLow(12)
*/
function parsev1v6(uuidBytes, dv) {
const isV1 = (uuidBytes[6] >> 4) === 1;
const timeStamp =
isV1 ? (
(BigInt(dv.getUint16(6) & 0x0fff) << 48n) | // mask off version bits
(BigInt(dv.getUint16(4)) << 32n) |
BigInt(dv.getUint32(0))
) : (
(BigInt(dv.getUint32(0)) << 28n) |
(BigInt(dv.getUint16(4)) << 12n) |
(BigInt(dv.getUint16(6) & 0x0fff))
);
// Convert to Unix time
const milliseconds =
Number(
(timeStamp - 122192928000000000n) / 10000n
);
return {
timestamp: milliseconds,
isoTimestamp: new Date(milliseconds).toISOString(),
clock: ((uuidBytes[8] & 0x3f) << 8) | uuidBytes[9],
node: toHex(uuidBytes.slice(10), ":").toUpperCase()
};
}
/** Version 7 */
function parsev7(uuidBytes, dv) {
const milliseconds = Number((BigInt(dv.getUint32(0)) << 16n) | BigInt(dv.getUint16(4)));
return {
timestamp: milliseconds,
isoTimestamp: new Date(milliseconds).toISOString(),
randA: ((uuidBytes[6] & 0x0f) << 8) | uuidBytes[7],
randB: toHex(uuidBytes.slice(8), "").toUpperCase()
};
}
/**
* Formats metadata
*
* @param {Object|undefined} decoded
* @returns {string}
*/
function formatDecoded(decoded) {
if (!decoded) return "No metadata available. Only versions 1, 6, 7 are supported.";
return Object.entries({
"Timestamp": decoded.timestamp,
"Timestamp (ISO)": decoded.isoTimestamp,
"Node": decoded.node,
"Clock": decoded.clock,
"Rand A": decoded.randA,
"Rand B": decoded.randB
})
.filter(([, value]) => value !== undefined)
.map(([label, value]) => `${label}:\n${value}`)
.join("\n\n");
}

View File

@ -0,0 +1,128 @@
/**
* @author j83305 [awz22@protonmail.com]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import { calculateParityBit, decodeParityBit } from "../lib/ParityBit.mjs";
/**
* Parity Bit operation
*/
class ParityBit extends Operation {
/**
* ParityBit constructor
*/
constructor() {
super();
this.name = "Parity Bit";
this.module = "Default";
this.description = "A parity bit, or check bit, is the simplest form of error detection. It is a bit which is added to a string of bits and represents if the number of 1's in the binary string is an even number or odd number.<br><br>If a delimiter is specified, the parity bit calculation will be performed on each 'block' of the input data, where the blocks are created by slicing the input at each occurence of the delimiter character";
this.infoURL = "https://wikipedia.org/wiki/Parity_bit";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Mode",
type: "option",
value: [
"Even Parity",
"Odd Parity"
]
},
{
name: "Postion",
type: "option",
value: [
"Start",
"End"
]
},
{
name: "Encode or Decode",
type: "option",
value: [
"Encode",
"Decode"
]
},
{
name: "Delimiter",
type: "shortString",
value: ""
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
if (input.length === 0) {
return input;
}
/**
* determines weather to use the encode or decode method based off args[2]
* @param input input to be encoded or decoded
* @param args array
*/
const method = (input, args) => args[2] === "Encode" ? calculateParityBit(input, args) : decodeParityBit(input, args);
if (args[3].length > 0) {
const byteStrings = input.split(args[3]);
for (let byteStringsArrayIndex = 0; byteStringsArrayIndex < byteStrings.length; byteStringsArrayIndex++) {
byteStrings[byteStringsArrayIndex] = method(byteStrings[byteStringsArrayIndex], args);
}
return byteStrings.join(args[3]);
}
return method(input, args);
}
/**
* Highlight Parity Bit
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlight(pos, args) {
if (args[3].length === 0) {
if (args[1] === "Prepend") {
pos[0].start += 1;
pos[0].end += 1;
}
return pos;
}
// need to be able to read input to do the highlighting when there is a delimiter
}
/**
* Highlight Parity Bit in reverse
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlightReverse(pos, args) {
if (args[3].length === 0) {
if (args[1] === "Prepend") {
if (pos[0].start > 0) {
pos[0].start -= 1;
}
pos[0].end -= 1;
}
return pos;
}
}
}
export default ParityBit;

View File

@ -35,6 +35,11 @@ class RenderMarkdown extends Operation {
name: "Enable syntax highlighting",
type: "boolean",
value: true
},
{
name: "Open links in new tab.",
type: "boolean",
value: false
}
];
}
@ -45,7 +50,7 @@ class RenderMarkdown extends Operation {
* @returns {html}
*/
run(input, args) {
const [convertLinks, enableHighlighting] = args,
const [convertLinks, enableHighlighting, openLinksBlank] = args,
md = new MarkdownIt({
linkify: convertLinks,
html: false, // Explicitly disable HTML rendering
@ -58,12 +63,38 @@ class RenderMarkdown extends Operation {
return "";
}
}),
rendered = md.render(input);
});
if (openLinksBlank) {
this.makeLinksOpenInNewTab(md);
}
const rendered = md.render(input);
return `<div style="font-family: var(--primary-font-family)">${rendered}</div>`;
}
/**
* Adds target="_blank" to links.
* @param {MarkdownIt} md
*/
makeLinksOpenInNewTab(md) {
// Adapted from: https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer
// Remember old renderer, if overridden, or proxy to default renderer
const defaultRender = md.renderer.rules.link_open || function(tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options);
};
// eslint-disable-next-line camelcase
md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
const token = tokens[idx];
if (token.attrIndex("target") >= 0) {
// Target attribute already set, do not replace.
return;
}
token.attrPush(["target", "_blank"]); // add new attribute
// pass token to default renderer.
return defaultRender(tokens, idx, options, env, self);
};
}
}
export default RenderMarkdown;

View File

@ -43,17 +43,23 @@ class HTMLOperation {
/**
* Renders the operation in HTML as a stub operation with no ingredients.
*
* @param {boolean} removeIcon - show icon for removing operation
* @param {string} elementId - element ID for aria usage
* @returns {string}
*/
toStubHtml(removeIcon) {
toStubHtml(removeIcon = false, elementId = null) {
let html = "<li class='operation'";
if (elementId) {
html += ` id='${elementId}'`;
}
if (this.description) {
const infoLink = this.infoURL ? `<hr>${titleFromWikiLink(this.infoURL)}` : "";
html += ` data-container='body' data-toggle='popover' data-placement='right'
data-content="${this.description}${infoLink}" data-html='true' data-trigger='hover'
data-boundary='viewport'`;
data-boundary='viewport' role='button'`;
}
html += ">" + this.name;

View File

@ -173,7 +173,7 @@
Operations
<span class="op-count"></span>
</div>
<input id="search" type="search" class="form-control" placeholder="Search..." autocomplete="off" tabindex="0" data-help-title="Searching for operations" data-help="<p>Use the search box to find useful operations.</p><p>Both operation names and descriptions are queried using a fuzzy matching algorithm.</p>">
<input id="search" type="search" class="form-control" placeholder="Search..." autocomplete="off" tabindex="0" data-help-title="Searching for operations" data-help="<p>Use the search box to find useful operations.</p><p>Both operation names and descriptions are queried using a fuzzy matching algorithm.</p>" aria-owns="search-results">
<ul id="search-results" class="op-list"></ul>
<div id="categories" class="panel-group no-select"></div>
</div>

View File

@ -28,17 +28,16 @@ class OperationsWaiter {
this.removeIntent = false;
}
/**
* Handler for search events.
* Finds operations which match the given search term and displays them under the search box.
*
* @param {event} e
* @param {KeyboardEvent | ClipboardEvent | Event} e
*/
searchOperations(e) {
let ops, selected;
if (e.type === "search" || e.keyCode === 13) { // Search or Return
if ((e.type === "search" && e.target.value !== "") || e.keyCode === 13) { // Search (non-empty) or Return
e.preventDefault();
ops = document.querySelectorAll("#search-results li");
if (ops.length) {
@ -49,27 +48,43 @@ class OperationsWaiter {
}
}
/**
* Sets up the operation element with the correct attributes when selected
* @param {HTMLElement} element
*/
const _selectOperation = (element) => {
element.classList.add("selected-op");
element.scrollIntoView({block: "nearest"});
$(element).popover("show");
e.target.setAttribute("aria-activedescendant", element.id);
};
/**
* Sets up the operation element with the correct attributes when deselected
* @param {HTMLElement} element
*/
const _deselectOperation = (element) => {
element.classList.remove("selected-op");
$(element).popover("hide");
};
if (e.keyCode === 40) { // Down
e.preventDefault();
ops = document.querySelectorAll("#search-results li");
if (ops.length) {
selected = this.getSelectedOp(ops);
if (selected > -1) {
ops[selected].classList.remove("selected-op");
}
if (selected > -1) _deselectOperation(ops[selected]);
if (selected === ops.length-1) selected = -1;
ops[selected+1].classList.add("selected-op");
_selectOperation(ops[selected+1]);
}
} else if (e.keyCode === 38) { // Up
e.preventDefault();
ops = document.querySelectorAll("#search-results li");
if (ops.length) {
selected = this.getSelectedOp(ops);
if (selected > -1) {
ops[selected].classList.remove("selected-op");
}
if (selected > -1) _deselectOperation(ops[selected]);
if (selected === 0) selected = ops.length;
ops[selected-1].classList.add("selected-op");
_selectOperation(ops[selected-1]);
}
} else {
const searchResultsEl = document.getElementById("search-results");
@ -83,11 +98,13 @@ class OperationsWaiter {
searchResultsEl.removeChild(searchResultsEl.firstChild);
}
document.querySelector("#search").removeAttribute("aria-activedescendant");
$("#categories .show").collapse("hide");
if (str) {
const matchedOps = this.filterOperations(str, true);
const matchedOpsHtml = matchedOps
.map(v => v.toStubHtml())
.map((operation, idx) => operation.toStubHtml(false, `search-result-${idx}`))
.join("");
searchResultsEl.innerHTML = matchedOpsHtml;
@ -103,7 +120,7 @@ class OperationsWaiter {
* @param {string} searchStr
* @param {boolean} highlight - Whether or not to highlight the matching string in the operation
* name and description
* @returns {string[]}
* @returns {HTMLOperation[]}
*/
filterOperations(inStr, highlight) {
const matchedOps = [];

View File

@ -589,8 +589,7 @@ Password: 282760`;
...[1, 3, 4, 5, 6, 7].map(version => it(`Analyze UUID v${version}`, () => {
const uuid = chef.generateUUID("", { "version": `v${version}` }).toString();
const result = chef.analyseUUID(uuid).toString();
const expected = `UUID version: ${version}`;
assert.strictEqual(result, expected);
assert.ok(result.startsWith(`Version:\n${version}\n`), `Expected output to start with "Version:\\n${version}\\n", got: ${result}`);
})),
it("Generate UUID using defaults", () => {
@ -598,7 +597,7 @@ Password: 282760`;
assert.ok(uuid);
const analysis = chef.analyseUUID(uuid).toString();
assert.strictEqual(analysis, "UUID version: 4");
assert.ok(analysis.startsWith("Version:\n4\n"), `Expected output to start with "Version:\\n4\\n", got: ${analysis}`);
}),
it("Gzip, Gunzip", () => {

View File

@ -17,6 +17,7 @@ import { setLongTestFailure, logTestReport } from "../lib/utils.mjs";
import TestRegister from "../lib/TestRegister.mjs";
import "./tests/A1Z26CipherDecode.mjs";
import "./tests/AESKeyWrap.mjs";
import "./tests/AnalyseUUID.mjs";
import "./tests/AlternatingCaps.mjs";
import "./tests/AvroToJSON.mjs";
import "./tests/BaconCipher.mjs";
@ -72,6 +73,7 @@ import "./tests/ExtractAudioMetadata.mjs";
import "./tests/ExtractEmailAddresses.mjs";
import "./tests/ExtractHashes.mjs";
import "./tests/ExtractIPAddresses.mjs";
import "./tests/Fernet.mjs";
import "./tests/Float.mjs";
import "./tests/FileTree.mjs";
import "./tests/FletcherChecksum.mjs";
@ -135,6 +137,7 @@ import "./tests/ParseUDP.mjs";
import "./tests/PEMtoHex.mjs";
import "./tests/PGP.mjs";
import "./tests/PHP.mjs";
import "./tests/ParityBit.mjs";
import "./tests/PHPSerialize.mjs";
import "./tests/PowerSet.mjs";
import "./tests/Protobuf.mjs";
@ -145,6 +148,7 @@ import "./tests/RAKE.mjs";
import "./tests/Regex.mjs";
import "./tests/Register.mjs";
import "./tests/RegularExpression.mjs";
import "./tests/RenderMarkdown.mjs";
import "./tests/RisonEncodeDecode.mjs";
import "./tests/Rotate.mjs";
import "./tests/RSA.mjs";

View File

@ -0,0 +1,66 @@
/**
* Analyse UUID tests
*
* @author ko80240 [csk.dev@proton.me]
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "Analyse UUID: v1 UUID extracts timestamp, clock, and node",
"input": "cefa1760-28ee-11f1-9f95-1fb76af3e239",
"expectedOutput": "Version:\n1\n\nTimestamp:\n1774514156502\n\nTimestamp (ISO):\n2026-03-26T08:35:56.502Z\n\nNode:\n1F:B7:6A:F3:E2:39\n\nClock:\n8085\n\nUUID Integer:\n275119515460318071558429785403790975545",
"recipeConfig": [
{
"op": "Analyse UUID",
"args": [true]
}
]
},
{
"name": "Analyse UUID: v7 UUID extracts timestamp, randA, and randB",
"input": "019d294a-af64-7728-9524-26da08f50708",
"expectedOutput": "Version:\n7\n\nTimestamp:\n1774514253668\n\nTimestamp (ISO):\n2026-03-26T08:37:33.668Z\n\nRand A:\n1832\n\nRand B:\n952426DA08F50708\n\nUUID Integer:\n2145256098533991595556290452700595976",
"recipeConfig": [
{
"op": "Analyse UUID",
"args": [true]
}
]
},
{
"name": "Analyse UUID: v4 UUID should show no metadata - not possible",
"input": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"expectedOutput": "Version:\n4\n\nNo metadata available. Only versions 1, 6, 7 are supported.\n\nUUID Integer:\n324969006592305634633390616021200786553",
"recipeConfig": [
{
"op": "Analyse UUID",
"args": [true]
}
]
},
{
"name": "Analyse UUID: if the 'Include Metadata' option is false it should return not metadata",
"input": "cefa1760-28ee-11f1-9f95-1fb76af3e239",
"expectedOutput": "Version:\n1\n\nUUID Integer:\n275119515460318071558429785403790975545",
"recipeConfig": [
{
"op": "Analyse UUID",
"args": [false]
}
]
},
{
"name": "Analyse UUID: invalid UUID should return error message",
"input": "not-a-uuid",
"expectedOutput": "Invalid UUID",
"recipeConfig": [
{
"op": "Analyse UUID",
"args": [true]
}
]
}
]);

View File

@ -5,7 +5,7 @@
* @copyright Karsten Silkenbäumer 2019
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
@ -47,7 +47,7 @@ TestRegister.addTests([
{
name: "Fernet Encrypt: no input",
input: "",
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
expectedMatch: /^gAAA[\w-]+={0,2}$/,
recipeConfig: [
{
op: "Fernet Encrypt",
@ -69,12 +69,27 @@ TestRegister.addTests([
{
name: "Fernet Encrypt: valid arguments",
input: "This is a secret message.\n",
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
expectedMatch: /^gAAA[\w-]+={0,2}$/,
recipeConfig: [
{
op: "Fernet Encrypt",
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
}
],
},
{
name: "Fernet Encrypt/Decrypt: round trip",
input: "This is a secret message.\n",
expectedOutput: "This is a secret message.\n",
recipeConfig: [
{
op: "Fernet Encrypt",
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
},
{
op: "Fernet Decrypt",
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
},
],
}
]);

View File

@ -0,0 +1,147 @@
/**
* Parity Bit tests
*
* @author j83305 [awz22@protonmail.com]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Parity bit encode in even parity, 1 block of binary of arbitrary length, prepend, even number of 1s",
input: "01010101 10101010",
expectedOutput: "001010101 10101010",
recipeConfig: [
{
"op": "Parity Bit",
"args": [
"Even Parity",
"Start",
"Encode",
""
]
}
]
},
{
name: "Parity bit encode in even parity, 1 block of binary of arbitrary length, prepend, odd number of 1s",
input: "01010101 10101011",
expectedOutput: "101010101 10101011",
recipeConfig: [
{
"op": "Parity Bit",
"args": [
"Even Parity",
"Start",
"Encode",
""
]
}
]
},
{
name: "Parity bit encode in even parity, 1 block of binary of arbitrary length, append, odd number of 1s",
input: "01010101 10101011",
expectedOutput: "01010101 101010111",
recipeConfig: [
{
"op": "Parity Bit",
"args": [
"Even Parity",
"End",
"Encode",
""
]
}
]
},
{
name: "Parity bit encode in odd parity, 1 block of binary of arbitrary length, prepend, even number of 1s",
input: "01010101 10101010",
expectedOutput: "101010101 10101010",
recipeConfig: [
{
"op": "Parity Bit",
"args": [
"Odd Parity",
"Start",
"Encode",
""
]
}
]
},
{
name: "Parity bit encode in odd parity, 1 block of binary of arbitrary length, prepend, odd number of 1s",
input: "01010101 10101011",
expectedOutput: "001010101 10101011",
recipeConfig: [
{
"op": "Parity Bit",
"args": [
"Odd Parity",
"Start",
"Encode",
""
]
}
]
},
{
name: "Parity bit encode in odd parity, 1 block of binary of arbitrary length, append, odd number of 1s",
input: "01010101 10101011",
expectedOutput: "01010101 101010110",
recipeConfig: [
{
"op": "Parity Bit",
"args": [
"Odd Parity",
"End",
"Encode",
""
]
}
]
},
{
name: "Parity bit encode in even parity, binary for 'hello world!', prepend to each byte",
input: "hello world!",
expectedOutput: "101101000 001100101 001101100 001101100 001101111 100100000 001110111 001101111 001110010 001101100 101100100 000100001",
recipeConfig: [
{
"op": "To Binary",
"args": ["Space"]
},
{
"op": "Parity Bit",
"args": [
"Even Parity",
"Start",
"Encode",
" "
]
}
]
},
{
name: "Parity bit encode in odd parity, binary for 'hello world!', append to each byte",
input: "hello world!",
expectedOutput: "011010000 011001011 011011001 011011001 011011111 001000000 011101111 011011111 011100101 011011001 011001000 001000011",
recipeConfig: [
{
"op": "To Binary",
"args": ["Space"]
},
{
"op": "Parity Bit",
"args": [
"Odd Parity",
"End",
"Encode",
" "
]
}
]
},
]);

View File

@ -0,0 +1,110 @@
/**
* RenderMarkdown tests.
*
* @copyright Crown Copyright 2026
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Render Markdown: Nothing",
input: "",
expectedOutput: '<div style="font-family: var(--primary-font-family)"></div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": []
}
]
},
{
name: "Render Markdown: Basic Text",
input: "Hello World!",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><p>Hello World!</p>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": []
}
]
},
{
name: "Render Markdown: Simple Markdown",
input: "# Hello World!",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><h1>Hello World!</h1>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": []
}
]
},
{
name: "Render Markdown: URL (not expanded)",
input: "https://gchq.github.io/CyberChef/",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><p>https://gchq.github.io/CyberChef/</p>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": [false, false, false]
}
]
},
{
name: "Render Markdown: URL (expanded)",
input: "https://gchq.github.io/CyberChef/",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><p><a href="https://gchq.github.io/CyberChef/">https://gchq.github.io/CyberChef/</a></p>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": [true, false, false]
}
]
},
{
name: "Render Markdown: Link (not expanded)",
input: "[CyberChef](https://gchq.github.io/CyberChef/)",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><p><a href="https://gchq.github.io/CyberChef/">CyberChef</a></p>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": [false, false, false]
}
]
},
{
name: "Render Markdown: Link (expanded)",
input: "[CyberChef](https://gchq.github.io/CyberChef/)",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><p><a href="https://gchq.github.io/CyberChef/">CyberChef</a></p>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": [true, false, false]
}
]
},
{
name: "Render Markdown: Link (open in new window)",
input: "[CyberChef](https://gchq.github.io/CyberChef/)",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><p><a href="https://gchq.github.io/CyberChef/" target="_blank">CyberChef</a></p>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": [true, false, true]
}
]
},
{
name: "Render Markdown: URL (open in new window)",
input: "https://gchq.github.io/CyberChef/",
expectedOutput: '<div style="font-family: var(--primary-font-family)"><p><a href="https://gchq.github.io/CyberChef/" target="_blank">https://gchq.github.io/CyberChef/</a></p>\n</div>',
recipeConfig: [
{
"op": "Render Markdown",
"args": [true, false, true]
}
]
},
]);