Skip to content

Commit

Permalink
sfp_tool_trufflehog: Enforce a timeout to prevent being blocked.
Browse files Browse the repository at this point in the history
  • Loading branch information
smicallef committed Feb 7, 2023
1 parent 38a417e commit d8b02b1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/sfp_tool_trufflehog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
import json
import os
from subprocess import PIPE, Popen
from subprocess import PIPE, Popen, TimeoutExpired

from spiderfoot import SpiderFootPlugin, SpiderFootEvent

Expand Down Expand Up @@ -135,8 +135,13 @@ def handleEvent(self, event):
args.append(url)
try:
p = Popen(args, stdout=PIPE, stderr=PIPE)
out, _ = p.communicate(input=None)
out, _ = p.communicate(input=None, timeout=600)
stdout = out.decode(sys.stdin.encoding)
except TimeoutExpired:
p.kill()
stdout, stderr = p.communicate()
self.debug(f"Timed out waiting for trufflehog to finish on {url}")
return
except Exception as e:
self.error(f"Unable to run trufflehog: {e}")
return
Expand Down

0 comments on commit d8b02b1

Please sign in to comment.