mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Wrote some tests, fixed imports for node
This commit is contained in:
parent
768fef502d
commit
3ad5f889a0
8 changed files with 127 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* @author tlwr [toby@toby.codes] - Original
|
* @author tlwr [toby@toby.codes]
|
||||||
* @author Matt C [me@mitt.dev] - Conversion to new format
|
* @author Matt C [me@mitt.dev]
|
||||||
* @copyright Crown Copyright 2019
|
* @copyright Crown Copyright 2019
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
41
src/core/operations/HTMLToText.mjs
Normal file
41
src/core/operations/HTMLToText.mjs
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/**
|
||||||
|
* @author tlwr [toby@toby.codes]
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
|
* @copyright Crown Copyright 2019
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTML To Text operation
|
||||||
|
*/
|
||||||
|
class HTMLToText extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTMLToText constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "HTML To Text";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Converts a HTML ouput from an operation to a readable string instead of being rendered in the DOM.";
|
||||||
|
this.infoURL = "";
|
||||||
|
this.inputType = "html";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {html} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HTMLToText;
|
|
@ -1,11 +1,12 @@
|
||||||
/**
|
/**
|
||||||
* @author tlwr [toby@toby.codes]
|
* @author tlwr [toby@toby.codes]
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
* @copyright Crown Copyright 2019
|
* @copyright Crown Copyright 2019
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as d3 from "d3";
|
import * as d3temp from "d3";
|
||||||
import * as nodom from "nodom";
|
import * as nodomtemp from "nodom";
|
||||||
import { getScatterValues, RECORD_DELIMITER_OPTIONS, COLOURS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
import { getScatterValues, RECORD_DELIMITER_OPTIONS, COLOURS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +14,9 @@ import Operation from "../Operation";
|
||||||
import OperationError from "../errors/OperationError";
|
import OperationError from "../errors/OperationError";
|
||||||
import Utils from "../Utils";
|
import Utils from "../Utils";
|
||||||
|
|
||||||
|
const d3 = d3temp.default ? d3temp.default : d3temp;
|
||||||
|
const nodom = nodomtemp.default ? nodomtemp.default: nodomtemp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Heatmap chart operation
|
* Heatmap chart operation
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
/**
|
/**
|
||||||
* @author tlwr [toby@toby.codes]
|
* @author tlwr [toby@toby.codes]
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
* @copyright Crown Copyright 2019
|
* @copyright Crown Copyright 2019
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as d3 from "d3";
|
import * as d3temp from "d3";
|
||||||
import * as d3hexbin from "d3-hexbin";
|
import * as d3hexbintemp from "d3-hexbin";
|
||||||
import * as nodom from "nodom";
|
import * as nodomtemp from "nodom";
|
||||||
import { getScatterValues, RECORD_DELIMITER_OPTIONS, COLOURS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
import { getScatterValues, RECORD_DELIMITER_OPTIONS, COLOURS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
||||||
|
|
||||||
import Operation from "../Operation";
|
import Operation from "../Operation";
|
||||||
import Utils from "../Utils";
|
import Utils from "../Utils";
|
||||||
|
|
||||||
|
const d3 = d3temp.default ? d3temp.default : d3temp;
|
||||||
|
const d3hexbin = d3hexbintemp.default ? d3hexbintemp.default : d3hexbintemp;
|
||||||
|
const nodom = nodomtemp.default ? nodomtemp.default: nodomtemp;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hex Density chart operation
|
* Hex Density chart operation
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
/**
|
/**
|
||||||
* @author tlwr [toby@toby.codes]
|
* @author tlwr [toby@toby.codes]
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
* @copyright Crown Copyright 2019
|
* @copyright Crown Copyright 2019
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as d3 from "d3";
|
import * as d3temp from "d3";
|
||||||
import * as nodom from "nodom";
|
import * as nodomtemp from "nodom";
|
||||||
|
|
||||||
import { getScatterValues, getScatterValuesWithColour, RECORD_DELIMITER_OPTIONS, COLOURS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
import { getScatterValues, getScatterValuesWithColour, RECORD_DELIMITER_OPTIONS, COLOURS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
||||||
|
|
||||||
import Operation from "../Operation";
|
import Operation from "../Operation";
|
||||||
import Utils from "../Utils";
|
import Utils from "../Utils";
|
||||||
|
|
||||||
|
const d3 = d3temp.default ? d3temp.default : d3temp;
|
||||||
|
const nodom = nodomtemp.default ? nodomtemp.default: nodomtemp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scatter chart operation
|
* Scatter chart operation
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
/**
|
/**
|
||||||
* @author tlwr [toby@toby.codes]
|
* @author tlwr [toby@toby.codes]
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
* @copyright Crown Copyright 2019
|
* @copyright Crown Copyright 2019
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as d3 from "d3";
|
import * as d3temp from "d3";
|
||||||
import * as nodom from "nodom";
|
import * as nodomtemp from "nodom";
|
||||||
import { getSeriesValues, RECORD_DELIMITER_OPTIONS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
import { getSeriesValues, RECORD_DELIMITER_OPTIONS, FIELD_DELIMITER_OPTIONS } from "../lib/Charts";
|
||||||
|
|
||||||
import Operation from "../Operation";
|
import Operation from "../Operation";
|
||||||
import Utils from "../Utils";
|
import Utils from "../Utils";
|
||||||
|
|
||||||
|
const d3 = d3temp.default ? d3temp.default : d3temp;
|
||||||
|
const nodom = nodomtemp.default ? nodomtemp.default: nodomtemp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Series chart operation
|
* Series chart operation
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,6 +33,7 @@ import "./tests/BitwiseOp";
|
||||||
import "./tests/ByteRepr";
|
import "./tests/ByteRepr";
|
||||||
import "./tests/CartesianProduct";
|
import "./tests/CartesianProduct";
|
||||||
import "./tests/CharEnc";
|
import "./tests/CharEnc";
|
||||||
|
import "./tests/Charts";
|
||||||
import "./tests/Checksum";
|
import "./tests/Checksum";
|
||||||
import "./tests/Ciphers";
|
import "./tests/Ciphers";
|
||||||
import "./tests/Code";
|
import "./tests/Code";
|
||||||
|
|
55
tests/operations/tests/Charts.mjs
Normal file
55
tests/operations/tests/Charts.mjs
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* Chart tests.
|
||||||
|
*
|
||||||
|
* @author Matt C [me@mitt.dev]
|
||||||
|
* @copyright Crown Copyright 2019
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../TestRegister";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Scatter chart",
|
||||||
|
input: "100 100\n200 200\n300 300\n400 400\n500 500",
|
||||||
|
expectedMatch: /^<svg width/,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Scatter chart",
|
||||||
|
"args": ["Line feed", "Space", false, "time", "stress", "black", 5, false]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Hex density chart",
|
||||||
|
input: "100 100\n200 200\n300 300\n400 400\n500 500",
|
||||||
|
expectedMatch: /^<svg width/,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Hex Density chart",
|
||||||
|
"args": ["Line feed", "Space", 25, 15, true, "", "", true, "white", "black", true]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Series chart",
|
||||||
|
input: "100 100 100\n200 200 200\n300 300 300\n400 400 400\n500 500 500",
|
||||||
|
expectedMatch: /^<svg width/,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Series chart",
|
||||||
|
"args": ["Line feed", "Space", "", 1, "mediumseagreen, dodgerblue, tomato"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Heatmap chart",
|
||||||
|
input: "100 100\n200 200\n300 300\n400 400\n500 500",
|
||||||
|
expectedMatch: /^<svg width/,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Heatmap chart",
|
||||||
|
"args": ["Line feed", "Space", 25, 25, true, "", "", false, "white", "black"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
Loading…
Add table
Add a link
Reference in a new issue