MCPcopy Index your code
hub / github.com/NextronSystems/valhallaAPI / get_rules_text

Method get_rules_text

valhallaAPI/valhalla.py:234–270  ·  view source on GitHub ↗

Retrieve the rules as JSON object, but converts them to text before returning them :param product: set a certain product that all rules must support :param max_version: set a maximum YARA version that your product supports :param modules: set a list of modules that y

(self, product="", max_version="", modules=[], with_crypto=True, tags=[], score=0, search="")

Source from the content-addressed store, hash-verified

232 return rules_response
233
234 def get_rules_text(self, product="", max_version="", modules=[], with_crypto=True, tags=[], score=0, search=""):
235 """
236 Retrieve the rules as JSON object, but converts them to text before returning them
237 :param product: set a certain product that all rules must support
238 :param max_version: set a maximum YARA version that your product supports
239 :param modules: set a list of modules that your product supports
240 :param with_crypto: set False if a product's YARA has not been built with OpenSSL (--without-crypto)
241 :param tags: set a list of tags that you want to retrieve
242 :param score: minimum score for rules to include in the output
243 :return:
244 """
245 rules_response = self.get_rules_json(product=product,
246 max_version=max_version,
247 modules=modules,
248 with_crypto=with_crypto,
249 tags=tags,
250 score=score,
251 search=search)
252
253 # Error
254 if 'status' in rules_response:
255 if rules_response['status'] == "error":
256 raise ApiError(rules_response['message'])
257
258 response_elements = list()
259
260 # Generate header
261 response_elements.append(generate_header(rules_response))
262
263 # Save the number of retrieved rules
264 self.last_retrieved_rules_count = len(rules_response['rules'])
265
266 # Rules
267 for rule in rules_response['rules']:
268 response_elements.append(rule['content'])
269
270 return "\n\n".join(response_elements)

Callers 3

mainFunction · 0.95
test_demo_rules_textFunction · 0.95
test_invalid_keyFunction · 0.95

Calls 3

get_rules_jsonMethod · 0.95
ApiErrorClass · 0.85
generate_headerFunction · 0.85

Tested by 2

test_demo_rules_textFunction · 0.76
test_invalid_keyFunction · 0.76