mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 08:16:17 -04:00
Add Output Filter option to Magic operation
This commit is contained in:
parent
79b9b63982
commit
283d7f2159
2 changed files with 13 additions and 5 deletions
|
@ -267,7 +267,7 @@ class Magic {
|
|||
* @param {boolean} [useful=false] - Whether the current recipe should be scored highly
|
||||
* @returns {Object[]} - A sorted list of the recipes most likely to result in correct decoding
|
||||
*/
|
||||
async speculativeExecution(depth=0, extLang=false, intensive=false, recipeConfig=[], useful=false) {
|
||||
async speculativeExecution(depth=0, extLang=false, intensive=false, recipeConfig=[], useful=false, filter=null) {
|
||||
if (depth < 0) return [];
|
||||
|
||||
// Find any operations that can be run on this data
|
||||
|
@ -305,7 +305,7 @@ class Magic {
|
|||
|
||||
const magic = new Magic(output, this.opPatterns),
|
||||
speculativeResults = await magic.speculativeExecution(
|
||||
depth-1, extLang, intensive, [...recipeConfig, opConfig], op.useful);
|
||||
depth-1, extLang, intensive, [...recipeConfig, opConfig], op.useful, filter);
|
||||
|
||||
results = results.concat(speculativeResults);
|
||||
}));
|
||||
|
@ -331,7 +331,10 @@ class Magic {
|
|||
r.fileType || // A file was found
|
||||
r.isUTF8 || // UTF-8 was found
|
||||
r.matchingOps.length // A matching op was found
|
||||
)
|
||||
) &&
|
||||
(
|
||||
filter == null || // Either no filter was passed, or
|
||||
new RegExp(filter).test(r.data)) // the filter matches the result data
|
||||
);
|
||||
|
||||
// Return a sorted list of possible recipes along with their properties
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue