Improved JSON parsing and error handling for tool modules #1952
      
        
          +135
        
        
          −73
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Improved JSON parsing and error handling for tool modules
Summary
This PR improves the robustness and reliability of three tool integration modules (
sfp_tool_nuclei,sfp_tool_wafw00f, andsfp_tool_whatweb) by fixing JSON parsing issues and enhancing error handling.Changes
1. sfp_tool_nuclei.py
Problem: The module was failing to parse Nuclei's JSONL (JSON Lines) output format correctly, causing crashes when processing vulnerability scan results.
Improvements:
{)classification.cve-idfield and template ID patternsmatched-atURLs usingurlparsejson.JSONDecodeErrorandKeyErrorWEBSERVER_TECHNOLOGYevents for informational findings2. sfp_tool_wafw00f.py
Problem: Temporary files were not being cleaned up properly in case of errors.
Improvements:
finallyblock to ensure temporary output files are always removed3. sfp_tool_whatweb.py
Problem: The module was crashing with
JSONDecodeErrorbecause WhatWeb outputs JSONL format (one JSON object per line), not a single JSON array.Improvements:
decode('utf-8', errors='ignore')HTTPServerandX-Powered-Byplugin data structuresTesting
All three modules have been tested with their respective tools:
Backwards Compatibility
All changes are backwards compatible and do not affect the module configurations or options.
Related Issues: Fixes JSON parsing errors in tool integration modules
Type of change: