浏览代码

Fixed problems flagged by n's review

Matt 6 年之前
父节点
当前提交
dd9ba4d250
共有 4 个文件被更改,包括 19 次插入22 次删除
  1. 2 0
      src/core/Ingredient.mjs
  2. 1 0
      src/core/Operation.mjs
  3. 14 10
      src/core/operations/YARARules.mjs
  4. 2 12
      src/web/HTMLIngredient.mjs

+ 2 - 0
src/core/Ingredient.mjs

@@ -23,6 +23,7 @@ class Ingredient {
         this._value = null;
         this._value = null;
         this.disabled = false;
         this.disabled = false;
         this.hint = "";
         this.hint = "";
+        this.rows = 0;
         this.toggleValues = [];
         this.toggleValues = [];
         this.target = null;
         this.target = null;
         this.defaultIndex = 0;
         this.defaultIndex = 0;
@@ -45,6 +46,7 @@ class Ingredient {
         this.defaultValue = ingredientConfig.value;
         this.defaultValue = ingredientConfig.value;
         this.disabled = !!ingredientConfig.disabled;
         this.disabled = !!ingredientConfig.disabled;
         this.hint = ingredientConfig.hint || false;
         this.hint = ingredientConfig.hint || false;
+        this.rows = ingredientConfig.rows || false;
         this.toggleValues = ingredientConfig.toggleValues;
         this.toggleValues = ingredientConfig.toggleValues;
         this.target = typeof ingredientConfig.target !== "undefined" ? ingredientConfig.target : null;
         this.target = typeof ingredientConfig.target !== "undefined" ? ingredientConfig.target : null;
         this.defaultIndex = typeof ingredientConfig.defaultIndex !== "undefined" ? ingredientConfig.defaultIndex : 0;
         this.defaultIndex = typeof ingredientConfig.defaultIndex !== "undefined" ? ingredientConfig.defaultIndex : 0;

+ 1 - 0
src/core/Operation.mjs

@@ -179,6 +179,7 @@ class Operation {
 
 
             if (ing.toggleValues) conf.toggleValues = ing.toggleValues;
             if (ing.toggleValues) conf.toggleValues = ing.toggleValues;
             if (ing.hint) conf.hint = ing.hint;
             if (ing.hint) conf.hint = ing.hint;
+            if (ing.rows) conf.rows = ing.rows;
             if (ing.disabled) conf.disabled = ing.disabled;
             if (ing.disabled) conf.disabled = ing.disabled;
             if (ing.target) conf.target = ing.target;
             if (ing.target) conf.target = ing.target;
             if (ing.defaultIndex) conf.defaultIndex = ing.defaultIndex;
             if (ing.defaultIndex) conf.defaultIndex = ing.defaultIndex;

+ 14 - 10
src/core/operations/YaraRules.mjs → src/core/operations/YARARules.mjs

@@ -9,41 +9,45 @@ import OperationError from "../errors/OperationError";
 import Yara from "libyara-wasm";
 import Yara from "libyara-wasm";
 
 
 /**
 /**
- * Yara Rules operation
+ * YARA Rules operation
  */
  */
-class YaraRules extends Operation {
+class YARARules extends Operation {
 
 
     /**
     /**
-     * YaraRules constructor
+     * YARARules constructor
      */
      */
     constructor() {
     constructor() {
         super();
         super();
 
 
-        this.name = "Yara Rules";
+        this.name = "YARA Rules";
         this.module = "Yara";
         this.module = "Yara";
-        this.description = "Yara support";
-        this.infoURL = "https://en.wikipedia.org/wiki/YARA";
+        this.description = "YARA is a tool developed at VirusTotal, primarily aimed at helping malware researchers to identify and classify malware samples. It matches based on rules specified by the user containing textual or binary patterns and a boolean expression. For help on writing rules, see the <a href='https://yara.readthedocs.io/en/latest/writingrules.html'>YARA documentation.</a>";
+        this.infoURL = "https://wikipedia.org/wiki/YARA";
         this.inputType = "ArrayBuffer";
         this.inputType = "ArrayBuffer";
         this.outputType = "string";
         this.outputType = "string";
         this.args = [
         this.args = [
             {
             {
                 name: "Rules",
                 name: "Rules",
-                type: "code",
-                value: ""
+                type: "text",
+                value: "",
+                rows: 5
             },
             },
             {
             {
                 name: "Show strings",
                 name: "Show strings",
                 type: "boolean",
                 type: "boolean",
+                hint: "Show each match's data",
                 value: false
                 value: false
             },
             },
             {
             {
                 name: "Show string lengths",
                 name: "Show string lengths",
                 type: "boolean",
                 type: "boolean",
+                hint: "Show the length of each match's data",
                 value: false
                 value: false
             },
             },
             {
             {
                 name: "Show metadata",
                 name: "Show metadata",
                 type: "boolean",
                 type: "boolean",
+                hint: "Show the metadata of each rule",
                 value: false
                 value: false
             }
             }
         ];
         ];
@@ -59,7 +63,7 @@ class YaraRules extends Operation {
         return new Promise((resolve, reject) => {
         return new Promise((resolve, reject) => {
             Yara().then(yara => {
             Yara().then(yara => {
                 let matchString = "";
                 let matchString = "";
-                const inpArr = new Uint8Array(input); // I know this is garbage but it's like 1.5 times faster
+                const inpArr = new Uint8Array(input);
                 const inpVec = new yara.vectorChar();
                 const inpVec = new yara.vectorChar();
                 for (let i = 0; i < inpArr.length; i++) {
                 for (let i = 0; i < inpArr.length; i++) {
                     inpVec.push_back(inpArr[i]);
                     inpVec.push_back(inpArr[i]);
@@ -107,4 +111,4 @@ class YaraRules extends Operation {
 
 
 }
 }
 
 
-export default YaraRules;
+export default YARARules;

+ 2 - 12
src/web/HTMLIngredient.mjs

@@ -25,6 +25,7 @@ class HTMLIngredient {
         this.value = config.value;
         this.value = config.value;
         this.disabled = config.disabled || false;
         this.disabled = config.disabled || false;
         this.hint = config.hint || false;
         this.hint = config.hint || false;
+        this.rows = config.rows || false;
         this.target = config.target;
         this.target = config.target;
         this.defaultIndex = config.defaultIndex || 0;
         this.defaultIndex = config.defaultIndex || 0;
         this.toggleValues = config.toggleValues;
         this.toggleValues = config.toggleValues;
@@ -42,18 +43,6 @@ class HTMLIngredient {
             i, m;
             i, m;
 
 
         switch (this.type) {
         switch (this.type) {
-            case "code":
-                html+= `<div class="form-group">
-                <label for="${this.id}" class="bmd-label-floating">${this.name}</label>
-                <textarea class="form-control arg"
-                    id="${this.id}"
-                    arg-name="${this.name}"
-                    value="${this.value}"
-                    rows=5
-                    ${this.disabled ? "disabled" : ""}></textarea>
-                ${this.hint ? "<span class='bmd-help'>" + this.hint + "</span>" : ""}
-                </div>`;
-                break;
             case "string":
             case "string":
             case "binaryString":
             case "binaryString":
             case "byteArray":
             case "byteArray":
@@ -241,6 +230,7 @@ class HTMLIngredient {
                         class="form-control arg"
                         class="form-control arg"
                         id="${this.id}"
                         id="${this.id}"
                         arg-name="${this.name}"
                         arg-name="${this.name}"
+                        rows="${this.rows ? this.rows : 3}"
                         ${this.disabled ? "disabled" : ""}>${this.value}</textarea>
                         ${this.disabled ? "disabled" : ""}>${this.value}</textarea>
                     ${this.hint ? "<span class='bmd-help'>" + this.hint + "</span>" : ""}
                     ${this.hint ? "<span class='bmd-help'>" + this.hint + "</span>" : ""}
                 </div>`;
                 </div>`;