Upgrading legacy non-dynamic rules to the new syntax #1674
Labels
breaking-change
introduces a breaking change that should be released in a major version
dynamic
related to dynamic analysis flavor
With the rollout of the new dynamic feature extraction and consequently the changes made to the rules' syntax (replacing
scope
withscopes
), we'll need a way to port the old rules into the new format; since many of them might be reusable anyways. In this issue, I'll be proposing a way to automatically port rules to the new format and make any necessary changes, all with a single script.The way I propose we do this rule upgrade is via a script that would parse test each rule for validity in the dynamic scope, and if it is, it would give it a dynamic interpretation; else, it would restrict it to the static analysis context. The way this script would work for a single rule is that it would essentially construct the corresponding statement for each rule, and try to activate all the shared features that are contained in that statement; then, if the rule evaluates to True, then it can be ported, otherwise it would be labeled as static.
This script should also modify the rules' inner blocks to contain a dynamic parallel in the case that the said inner block can match in a dynamic context. Here's an example to illustrate what I mean:
Original rule:
Would become:
In the previous example, the
basic block
node would be replaced by anor
one which contains the originalbasic block
node as well as a mirror node that contains only static features and that has the original scope's "parallel scope"The parallel dynamic scopes I suggest for each static scope are:
instruction -> call: since I believe it's commonly used for detecting api calls.
basic block -> thread: since I believe it's commonly used for applying boolean logic to detected api calls.
function -> process: same reason as above, and since having a hierarchy would make things easier.
Another option for picking the parallel dynamic scopes is to do it relative to what types of features are within each one.
looking forward to hear your thoughts on this.
The text was updated successfully, but these errors were encountered: