-
Notifications
You must be signed in to change notification settings - Fork 0
Contributing
Haze4269 edited this page Dec 28, 2025
·
1 revision
We welcome contributions to the detection engine! Whether you're adding a new security rule or optimizing the IL analysis, here's how to get started.
All detection logic lives in Models/Rules. To add a new rule:
-
Create the Rule Class: Add a new file in
Models/Rules/MyNewRule.cs. -
Implement
IScanRule:using Mono.Cecil; using Mono.Cecil.Cil; namespace MLVScan.Models.Rules { public class MyNewRule : IScanRule { public string Description => "Detects usage of DangerousAPI"; public Severity Severity => Severity.High; public bool IsSuspicious(MethodDefinition method) { if (!method.HasBody) return false; foreach (var instruction in method.Body.Instructions) { // Example: Detect checking for a specific string if (instruction.OpCode == OpCodes.Ldstr && instruction.Operand.ToString().Contains("dangerous_string")) { return true; } } return false; } } }
-
Register the Rule: Add your new rule to
RuleFactory.cs:public static List<IScanRule> CreateDefaultRules() { return new List<IScanRule> { // ... existing rules ... new MyNewRule(), }; }
- Test It: Run the scanner against an assembly that should trigger the rule.
-
Clone the Repo:
git clone https://github.com/ifBars/MLVScan.Core.git
-
Build:
dotnet build
- Use standard C# coding conventions.
- Ensure rules are performant (avoid heavy computations in
IsSuspiciousif possible). - Add comments explaining why a pattern is considered malicious.