mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
swap ENVIRONMENT_IS_* functions for Utils named exports
This commit is contained in:
parent
c70f14419a
commit
1c24c05647
41 changed files with 117 additions and 141 deletions
|
@ -7,6 +7,7 @@
|
|||
import Operation from "../Operation";
|
||||
import OperationError from "../errors/OperationError";
|
||||
import Yara from "libyara-wasm";
|
||||
import { isWorkerEnvironment } from "../Utils";
|
||||
|
||||
/**
|
||||
* YARA Rules operation
|
||||
|
@ -61,21 +62,21 @@ class YARARules extends Operation {
|
|||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
if (isWorkerEnvironment())
|
||||
self.sendStatusMessage("Instantiating YARA...");
|
||||
const [rules, showStrings, showLengths, showMeta, showCounts] = args;
|
||||
return new Promise((resolve, reject) => {
|
||||
Yara().then(yara => {
|
||||
if (ENVIRONMENT_IS_WORKER()) self.sendStatusMessage("Converting data for YARA.");
|
||||
if (isWorkerEnvironment()) self.sendStatusMessage("Converting data for YARA.");
|
||||
let matchString = "";
|
||||
|
||||
const inpArr = new Uint8Array(input); // Turns out embind knows that JS uint8array <==> C++ std::string
|
||||
|
||||
if (ENVIRONMENT_IS_WORKER()) self.sendStatusMessage("Running YARA matching.");
|
||||
if (isWorkerEnvironment()) self.sendStatusMessage("Running YARA matching.");
|
||||
|
||||
const resp = yara.run(inpArr, rules);
|
||||
|
||||
if (ENVIRONMENT_IS_WORKER()) self.sendStatusMessage("Processing data.");
|
||||
if (isWorkerEnvironment()) self.sendStatusMessage("Processing data.");
|
||||
|
||||
if (resp.compileErrors.size() > 0) {
|
||||
for (let i = 0; i < resp.compileErrors.size(); i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue