- 
                Notifications
    You must be signed in to change notification settings 
- Fork 71
Add extensions ecosystem support for Guarddog #589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d43ead2    to
    4bce5bd      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I had 2-3 questions and a handful of nits but no major changes requested.
Let's make sure @sobregosodd gets a chance to look at it, as well.
        
          
                guarddog/analyzer/analyzer.py
              
                Outdated
          
        
      | output = { | ||
| "issues": issues, | ||
| "errors": errors, | ||
| "results": results, | ||
| "path": path} | ||
| # Including extension info - pending discussion | ||
| # if info is not None: | ||
| # output["package_info"] = info | ||
|  | ||
| return output | ||
|  | ||
| def analyze_metadata( | ||
| self, | ||
| path: str, | ||
| info, | ||
| rules=None, | ||
| name: Optional[str] = None, | ||
| version: Optional[str] = None) -> dict: | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-  this entire block changed nothing, let's keep the new analyze_metadataformated one
        
          
                guarddog/analyzer/analyzer.py
              
                Outdated
          
        
      |  | ||
| # Define verbose rules that should only show "file-level" triggers | ||
| verbose_rules = { | ||
| "DETECT_FILE_obfuscator_dot_io", | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- this should not be hardcoded, let's find another way
| 'rm -rf', | ||
| 'del /s', | ||
| 'format', | ||
| 'shutdown', | ||
| 'curl', | ||
| 'wget', | ||
| 'powershell'] | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a good idea to hardcode these here. let's talk alternatives
|  | ||
| # Default to EXTENSION for general YARA rules (can be adjusted as when | ||
| # other ecosystems are supported) | ||
| rule_ecosystem = ECOSYSTEM.EXTENSION | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- this is not right, all ecosystems are currently supported. you might need to parse the metadata here
…fix formatting :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few small things here and there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a couple optional suggestions.
Let's make sure to also get approval from @sobregosodd before merging.
| # Determine ecosystem based on filename prefix | ||
| rule_ecosystem: Optional[ECOSYSTEM] | ||
| if file_name.startswith("extension_"): | ||
| rule_ecosystem = ECOSYSTEM.EXTENSION | ||
| else: | ||
| # If no specific ecosystem prefix, apply to any ecosystem | ||
| rule_ecosystem = None | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rule_ecosystem = None
if file_name.startswith("extension_"):
    rule_ecosystem = ECOSYSTEM.EXTENSIONThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may also want to move the "extension_" piece to a constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could even do rule_ecosystem = ECOSYSTEM.EXTENSION if file_name.startswith("extension_") else None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll wait for Sebastian's review and apply this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmh... actually, we don't use the name's prefix to do this, we use the metadata of the rule.
similar to description_regex up there.
in some ideal future world, we should remove the prefixes of the rules (there are problems if we try to do this now)
Adding Extension ecosystem support to GD.
The changes include: