Merge remote-tracking branch 'upstream/master'

This commit is contained in:
j433866 2019-08-22 11:20:40 +01:00
commit 8d628cf0ed
11 changed files with 83 additions and 46 deletions

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "9.0.5",
"version": "9.0.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "9.0.5",
"version": "9.0.8",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",

View file

@ -205,7 +205,7 @@ class Protobuf {
(this.data[this.offset] & this.VALUE) << shift :
(this.data[this.offset] & this.VALUE) * Math.pow(2, shift);
shift += 7;
} while ((this.data[this.offset++] & this.MSD) === this.MSB);
} while ((this.data[this.offset++] & this.MSB) === this.MSB);
return fieldNumber;
}

View file

@ -91,7 +91,7 @@ The following algorithms will be used based on the size of the key:
const decipher = forge.cipher.createDecipher("AES-" + mode, key);
decipher.start({
iv: iv,
iv: iv.length === 0 ? "" : iv,
tag: gcmTag
});
decipher.update(forge.util.createBuffer(input));

View file

@ -113,7 +113,7 @@ CMYK: ${cmyk}
}).on('colorpickerChange', function(e) {
var color = e.color.string('rgba');
document.getElementById('input-text').value = color;
window.app.autoBake();
window.app.manager.input.debounceInputChange(new Event("keyup"));
});
</script>`;
}

View file

@ -382,7 +382,7 @@
</div>
</div>
<div class="modal" id="save-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="save-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -442,7 +442,7 @@
</div>
</div>
<div class="modal" id="load-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="load-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -469,7 +469,7 @@
</div>
</div>
<div class="modal" id="options-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="options-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -582,7 +582,7 @@
</div>
</div>
<div class="modal" id="favourites-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="favourites-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -608,7 +608,7 @@
</div>
</div>
<div class="modal" id="support-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="support-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -744,7 +744,7 @@
</div>
</div>
<div class="modal" id="confirm-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="confirm-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -763,7 +763,7 @@
</div>
</div>
<div class="modal" id="input-tab-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="input-tab-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -822,7 +822,7 @@
</div>
</div>
<div class="modal" id="output-tab-modal" tabindex="-1" role="dialog">
<div class="modal fade" id="output-tab-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">

View file

@ -48,6 +48,7 @@ class TestRegister {
* Runs all the tests in the register.
*/
runTests () {
console.log("Running tests...");
return Promise.all(
this.tests.map(function(test, i) {
const chef = new Chef();
@ -103,6 +104,8 @@ class TestRegister {
* Run all api related tests and wrap results in report format
*/
runApiTests() {
console.log("Running tests...");
return Promise.all(this.apiTests.map(async function(test, i) {
const result = {
test: test,

View file

@ -15,28 +15,48 @@
* @param {string} status
* @returns {string}
*/
const statusToIcon = function statusToIcon(status) {
const icons = {
function statusToIcon(status) {
return {
erroring: "🔥",
failing: "❌",
passing: "✔️️",
};
return icons[status] || "?";
};
}[status] || "?";
}
/**
* Displays a given test result in the console.
* Counts test statuses.
*
* @param {Object} testStatusCounts
* @param {Object} testStatus
* @param {Object} testResult
*/
function handleTestResult(testStatus, testResult) {
testStatus.allTestsPassing = testStatus.allTestsPassing && testResult.status === "passing";
const newCount = (testStatus.counts[testResult.status] || 0) + 1;
testStatus.counts[testResult.status] = newCount;
testStatus.counts[testResult.status] = (testStatus.counts[testResult.status] || 0) + 1;
testStatus.counts.total += 1;
}
/**
* Log each test result, count tests and failures.
*
* @param {Object} testStatus - object describing test run data
* @param {Object[]} results - results from TestRegister
*/
export function logTestReport(testStatus, results) {
console.log("Tests completed.");
results.forEach(r => handleTestResult(testStatus, r));
console.log();
for (const testStatusCount in testStatus.counts) {
const count = testStatus.counts[testStatusCount];
if (count > 0) {
console.log(testStatusCount.toUpperCase() + "\t" + count);
}
}
console.log();
// Print error messages for tests that didn't pass
results.filter(res => res.status !== "passing").forEach(testResult => {
console.log([
statusToIcon(testResult.status),
testResult.test.name
@ -50,24 +70,8 @@ function handleTestResult(testStatus, testResult) {
.replace(/\n/g, "\n\t")
);
}
}
/**
* Log each test result, count tests and failures. Log test suite run duration.
*
* @param {Object} testStatus - object describing test run data
* @param {Object[]} results - results from TestRegister
*/
export function logTestReport(testStatus, results) {
results.forEach(r => handleTestResult(testStatus, r));
console.log("\n");
for (const testStatusCount in testStatus.counts) {
const count = testStatus.counts[testStatusCount];
if (count > 0) {
console.log(testStatusCount.toUpperCase(), count);
}
}
});
console.log();
process.exit(testStatus.allTestsPassing ? 0 : 1);
}
@ -81,4 +85,3 @@ export function setLongTestFailure() {
process.exit(1);
}, 60 * 1000);
}

View file

@ -906,7 +906,7 @@ smothering ampersand abreast
}),
it("to unix timestamp", () => {
assert.strictEqual(chef.toUNIXTimestamp("04-01-2001").toString(), "986083200 (Sun 1 April 2001 00:00:00 UTC)");
assert.strictEqual(chef.toUNIXTimestamp("2001-04-01").toString(), "986083200 (Sun 1 April 2001 00:00:00 UTC)");
}),
it("Translate DateTime format", () => {

View file

@ -54,6 +54,21 @@ The following algorithms will be used based on the size of the key:
}
],
},
{
name: "AES Encrypt: AES-128-CTR, no IV, ASCII",
input: "The quick brown fox jumps over the lazy dog.",
expectedOutput: "a98c9e8e3b7c894384d740e4f0f4ed0be2bbb1e0e13a255812c3c6b0a629e4ad759c075b2469c6f4fb2c0cf9",
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"CTR", "Raw", "Hex"
]
}
],
},
{
name: "AES Encrypt: AES-128-CBC with IV, ASCII",
input: "The quick brown fox jumps over the lazy dog.",
@ -645,6 +660,22 @@ The following algorithms will be used based on the size of the key:
}
],
},
{
name: "AES Decrypt: AES-128-CTR, no IV, ASCII",
input: "a98c9e8e3b7c894384d740e4f0f4ed0be2bbb1e0e13a255812c3c6b0a629e4ad759c075b2469c6f4fb2c0cf9",
expectedOutput: "The quick brown fox jumps over the lazy dog.",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"CTR", "Hex", "Raw",
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Decrypt: AES-128-CBC with IV, ASCII",
input: "4fa077d50cc71a57393e7b542c4e3aea0fb75383b97083f2f568ffc13c0e7a47502ec6d9f25744a061a3a5e55fe95e8d",

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
@ -15,7 +15,7 @@ TestRegister.addTests([
expectedOutput: "192[.]168[.]1[.]1",
recipeConfig: [
{
op: "Defang IP",
op: "Defang IP Addresses",
args: [],
},
],
@ -25,7 +25,7 @@ TestRegister.addTests([
expectedOutput: "2001[:]0db8[:]85a3[:]0000[:]0000[:]8a2e[:]0370[:]7343",
recipeConfig: [
{
op: "Defang IP",
op: "Defang IP Addresses",
args: [],
},
],
@ -35,7 +35,7 @@ TestRegister.addTests([
expectedOutput: "2001[:]db8[:]3c4d[:]15[:][:]1a2f[:]1a2b",
recipeConfig: [
{
op: "Defang IP",
op: "Defang IP Addresses",
args: [],
},
],