You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying your go-yara library and testing whether it suits my use-case. Here is the ideas I'm trying to do:
The binary constantly checking data from network packets to see whether they violate the existing rules.
If I see a packets has bypassed the existing rules, I'll try to add a new rules to the rules folder.
So, before trying any goroutine to automate the process of detecting new YARA files being added, I tried to live-load a new rule during runtime inside the code like this:
// the default examples - loads and compiles rules when the program startsfor_, rule:=rangerules {
f, err:=os.Open(rule.filename)
iferr!=nil {
log.Fatalf("Could not open rule file %s: %s", rule.filename, err)
}
err=c.AddFile(f, rule.namespace)
f.Close()
iferr!=nil {
log.Fatalf("Could not parse rule file %s: %s", rule.filename, err)
}
}
r, err:=c.GetRules()
iferr!=nil {
log.Fatalf("Failed to compile rules: %s", err)
}
// my implementation - live load after the initial compilation has finishedf1, err:=os.Open("./samp1e.yara")
err=c.AddFile(f1, "")
f1.Close()
r, err=c.GetRules()
iferr!=nil {
log.Fatalf("Failed to compile rules: %s", err)
}
My implementation is causing the program to panic. Here is the panic message:
By removing one c.GetRules(), the program works fine again.
Can you point out where I did things wrong? I assume that compiler.GetRules() should only be called once; but how can I achieve my goal? Thanks in advance.
The text was updated successfully, but these errors were encountered:
The yr_compiler object which is wrapped by Compiler can't be re-used after producing a compiled rule set. This is not strictly a bug in go-yara (although we could guard against this).
If you want to update your ruleset at run-time, you'll have to create a fresh Compiler and pass all rule files to it.
Hi, I'm trying your go-yara library and testing whether it suits my use-case. Here is the ideas I'm trying to do:
So, before trying any goroutine to automate the process of detecting new YARA files being added, I tried to live-load a new rule during runtime inside the code like this:
My implementation is causing the program to panic. Here is the panic message:
By removing one
c.GetRules()
, the program works fine again.Can you point out where I did things wrong? I assume that compiler.GetRules() should only be called once; but how can I achieve my goal? Thanks in advance.
The text was updated successfully, but these errors were encountered: