|
5 | 5 | misperrors = {"error": "Error"} |
6 | 6 | mispattributes = {"input": ["yara"], "output": ["text"]} |
7 | 7 | moduleinfo = { |
8 | | - "version": "0.1", |
9 | | - "author": "Dennis Rand", |
| 8 | + "version": "0.2", |
| 9 | + "author": "Dennis Rand and Theo Geffe", |
10 | 10 | "description": "An expansion hover module to perform a syntax check on if yara rules are valid or not.", |
11 | 11 | "module-type": ["hover"], |
12 | 12 | "name": "YARA Syntax Validator", |
|
15 | 15 | "features": ( |
16 | 16 | "This modules simply takes a YARA rule as input, and checks its syntax. It returns then a confirmation if the" |
17 | 17 | " syntax is valid, otherwise the syntax error is displayed." |
| 18 | + " This modules can compile YARA rule even if there is externals variables or miss modules" |
18 | 19 | ), |
19 | 20 | "references": ["http://virustotal.github.io/yara/"], |
20 | 21 | "input": "YARA rule attribute.", |
|
38 | 39 | # will raise "undefined identifier" errors unless the appropriate imports |
39 | 40 | # are present. |
40 | 41 |
|
| 42 | + |
41 | 43 | def insert_import_module(rule_text, module_name): |
42 | 44 | lines = rule_text.strip().splitlines() |
43 | 45 | if not any(line.strip().startswith(f'import "{module_name}"') for line in lines): |
@@ -65,6 +67,7 @@ def insert_import_module(rule_text, module_name): |
65 | 67 | # - No false negatives caused by missing imports or missing externals |
66 | 68 | # ------------------------------------------------------------------------- |
67 | 69 |
|
| 70 | + |
68 | 71 | def handler(q=False): |
69 | 72 | if q is False: |
70 | 73 | return False |
@@ -104,11 +107,9 @@ def handler(q=False): |
104 | 107 | summary = "Syntax error: Max validation attempts exceeded" |
105 | 108 | return {"results": [{"types": mispattributes["output"], "values": summary}]} |
106 | 109 |
|
107 | | - |
108 | 110 | def introspection(): |
109 | 111 | return mispattributes |
110 | 112 |
|
111 | | - |
112 | 113 | def version(): |
113 | 114 | moduleinfo["config"] = moduleconfig |
114 | 115 | return moduleinfo |
0 commit comments