Tidied up 'Play Media' operation

This commit is contained in:
n1474335 2018-12-19 17:58:38 +00:00
parent 8c6c3a1c01
commit 01c4cfdc8d
3 changed files with 16 additions and 9 deletions

View file

@ -2,6 +2,9 @@
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master). All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
### [8.16.0] - 2018-12-19
- 'Play Media' operation added [@anthony-arnold] | [#446]
### [8.15.0] - 2018-12-18 ### [8.15.0] - 2018-12-18
- 'Text Encoding Brute Force' operation added [@Cynser] | [#439] - 'Text Encoding Brute Force' operation added [@Cynser] | [#439]
@ -76,6 +79,7 @@ All major and minor version changes will be documented in this file. Details of
[8.16.0]: https://github.com/gchq/CyberChef/releases/tag/v8.16.0
[8.15.0]: https://github.com/gchq/CyberChef/releases/tag/v8.15.0 [8.15.0]: https://github.com/gchq/CyberChef/releases/tag/v8.15.0
[8.14.0]: https://github.com/gchq/CyberChef/releases/tag/v8.14.0 [8.14.0]: https://github.com/gchq/CyberChef/releases/tag/v8.14.0
[8.13.0]: https://github.com/gchq/CyberChef/releases/tag/v8.13.0 [8.13.0]: https://github.com/gchq/CyberChef/releases/tag/v8.13.0
@ -112,6 +116,7 @@ All major and minor version changes will be documented in this file. Details of
[@jarmovanlenthe]: https://github.com/jarmovanlenthe [@jarmovanlenthe]: https://github.com/jarmovanlenthe
[@tcode2k16]: https://github.com/tcode2k16 [@tcode2k16]: https://github.com/tcode2k16
[@Cynser]: https://github.com/Cynser [@Cynser]: https://github.com/Cynser
[@anthony-arnold]: https://github.com/anthony-arnold
[#95]: https://github.com/gchq/CyberChef/pull/299 [#95]: https://github.com/gchq/CyberChef/pull/299
[#173]: https://github.com/gchq/CyberChef/pull/173 [#173]: https://github.com/gchq/CyberChef/pull/173
@ -138,3 +143,4 @@ All major and minor version changes will be documented in this file. Details of
[#439]: https://github.com/gchq/CyberChef/pull/439 [#439]: https://github.com/gchq/CyberChef/pull/439
[#441]: https://github.com/gchq/CyberChef/pull/441 [#441]: https://github.com/gchq/CyberChef/pull/441
[#443]: https://github.com/gchq/CyberChef/pull/443 [#443]: https://github.com/gchq/CyberChef/pull/443
[#446]: https://github.com/gchq/CyberChef/pull/446

View file

@ -342,8 +342,12 @@
] ]
}, },
{ {
"name": "Multimedia", "name": "Forensics",
"ops": [ "ops": [
"Detect File Type",
"Scan for Embedded Files",
"Remove EXIF",
"Extract EXIF",
"Render Image", "Render Image",
"Play Media" "Play Media"
] ]
@ -354,16 +358,12 @@
"Entropy", "Entropy",
"Frequency distribution", "Frequency distribution",
"Chi Square", "Chi Square",
"Detect File Type",
"Scan for Embedded Files",
"Disassemble x86", "Disassemble x86",
"Pseudo-Random Number Generator", "Pseudo-Random Number Generator",
"Generate UUID", "Generate UUID",
"Generate TOTP", "Generate TOTP",
"Generate HOTP", "Generate HOTP",
"Haversine distance", "Haversine distance",
"Remove EXIF",
"Extract EXIF",
"Numberwang", "Numberwang",
"XKCD Random Number" "XKCD Random Number"
] ]

View file

@ -23,8 +23,8 @@ class PlayMedia extends Operation {
super(); super();
this.name = "Play Media"; this.name = "Play Media";
this.module = "Media"; this.module = "Default";
this.description = "Plays the input as sound or video depending on the type."; this.description = "Plays the input as audio or video depending on the type.<br><br>Tags: sound, movie, mp3, mp4, mov, webm, wav, ogg";
this.infoURL = ""; this.infoURL = "";
this.inputType = "string"; this.inputType = "string";
this.outputType = "byteArray"; this.outputType = "byteArray";
@ -44,7 +44,7 @@ class PlayMedia extends Operation {
* @returns {byteArray} The multimedia data as bytes. * @returns {byteArray} The multimedia data as bytes.
*/ */
run(input, args) { run(input, args) {
const inputFormat = args[0]; const [inputFormat] = args;
if (!input.length) return []; if (!input.length) return [];
@ -68,7 +68,7 @@ class PlayMedia extends Operation {
// Determine file type // Determine file type
const type = Magic.magicFileType(input); const type = Magic.magicFileType(input);
if (!(type && /^audio|video/.test(type.mime))) { if (!(type && /^audio|video/.test(type.mime))) {
throw new OperationError("Invalid file type"); throw new OperationError("Invalid or unrecognised file type");
} }
return input; return input;
@ -77,6 +77,7 @@ class PlayMedia extends Operation {
/** /**
* Displays an audio or video element that may be able to play the media * Displays an audio or video element that may be able to play the media
* file. * file.
*
* @param data {byteArray} Data containing an audio or video file. * @param data {byteArray} Data containing an audio or video file.
* @returns {string} Markup to display a media player. * @returns {string} Markup to display a media player.
*/ */