mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 23:36:16 -04:00
ESM: Added new List<File> Dish type. Added present() method for displaying operation output in a nice way. Testing required.
This commit is contained in:
parent
ae55fde591
commit
b7ed1becba
8 changed files with 165 additions and 69 deletions
|
@ -25,7 +25,8 @@ class Unzip extends Operation {
|
|||
this.module = "Compression";
|
||||
this.description = "Decompresses data using the PKZIP algorithm and displays it per file, with support for passwords.";
|
||||
this.inputType = "byteArray";
|
||||
this.outputType = "html";
|
||||
this.outputType = "List<File>";
|
||||
this.presentType = "html";
|
||||
this.args = [
|
||||
{
|
||||
name: "Password",
|
||||
|
@ -43,7 +44,7 @@ class Unzip extends Operation {
|
|||
/**
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {html}
|
||||
* @returns {File[]}
|
||||
*/
|
||||
run(input, args) {
|
||||
const options = {
|
||||
|
@ -51,28 +52,22 @@ class Unzip extends Operation {
|
|||
verify: args[1]
|
||||
},
|
||||
unzip = new Zlib.Unzip(input, options),
|
||||
filenames = unzip.getFilenames(),
|
||||
files = [];
|
||||
filenames = unzip.getFilenames();
|
||||
|
||||
filenames.forEach(function(fileName) {
|
||||
return filenames.map(fileName => {
|
||||
const bytes = unzip.decompress(fileName);
|
||||
const contents = Utils.byteArrayToUtf8(bytes);
|
||||
|
||||
const file = {
|
||||
fileName: fileName,
|
||||
size: contents.length,
|
||||
};
|
||||
|
||||
const isDir = contents.length === 0 && fileName.endsWith("/");
|
||||
if (!isDir) {
|
||||
file.bytes = bytes;
|
||||
file.contents = contents;
|
||||
}
|
||||
|
||||
files.push(file);
|
||||
return new File([bytes], fileName);
|
||||
});
|
||||
}
|
||||
|
||||
return Utils.displayFilesAsHTML(files);
|
||||
/**
|
||||
* Displays the files in HTML for web apps.
|
||||
*
|
||||
* @param {File[]} files
|
||||
* @returns {html}
|
||||
*/
|
||||
async present(files) {
|
||||
return await Utils.displayFilesAsHTML(files);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue