Skip to content
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

Enhancement: Trufflehog #1343

5 changes: 4 additions & 1 deletion bbot/modules/docker_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ async def handle_event(self, event):
if repo_path:
self.verbose(f"Downloaded docker repository {repo_url} to {repo_path}")
codebase_event = self.make_event(
{"path": str(repo_path)}, "FILESYSTEM", tags=["docker", "tarball"], source=event
{"path": str(repo_path), "description": f"Docker image repository: {repo_url}"},
"FILESYSTEM",
tags=["docker", "tarball"],
source=event,
)
codebase_event.scope_distance = event.scope_distance
await self.emit_event(codebase_event)
Expand Down
18 changes: 11 additions & 7 deletions bbot/modules/trufflehog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class trufflehog(BaseModule):
meta = {"description": "TruffleHog is a tool for finding credentials"}

options = {
"version": "3.69.0",
"version": "3.75.1",
"only_verified": True,
"concurrency": 8,
}
Expand Down Expand Up @@ -37,18 +37,15 @@ async def setup(self):
self.concurrency = int(self.config.get("concurrency", 8))
return True

async def filter_event(self, event):
if event.type == "FILESYSTEM":
if "git" not in event.tags and "docker" not in event.tags:
return False, "event is not a git repository or a docker image"
return True

async def handle_event(self, event):
path = event.data["path"]
description = event.data.get("description", "")
if "git" in event.tags:
module = "git"
elif "docker" in event.tags:
module = "docker"
else:
module = "filesystem"
async for decoder_name, detector_name, raw_result, verified, source_metadata in self.execute_trufflehog(
module, path
):
Expand All @@ -58,12 +55,16 @@ async def handle_event(self, event):
"description": f"Verified Secret Found. Detector Type: [{detector_name}] Decoder Type: [{decoder_name}] Secret: [{raw_result}] Details: [{source_metadata}]",
"host": str(event.source.host),
}
if description:
data["description"] += f" Description: [{description}]"
await self.emit_event(data, "VULNERABILITY", event)
else:
data = {
"description": f"Potential Secret Found. Detector Type: [{detector_name}] Decoder Type: [{decoder_name}] Secret: [{raw_result}] Details: [{source_metadata}]",
"host": str(event.source.host),
}
if description:
data["description"] += f" Description: [{description}]"
await self.emit_event(data, "FINDING", event)

async def execute_trufflehog(self, module, path):
Expand All @@ -80,6 +81,9 @@ async def execute_trufflehog(self, module, path):
elif module == "docker":
command.append("docker")
command.append("--image=file://" + path)
elif module == "filesystem":
command.append("filesystem")
command.append(path)

stats_file = self.helpers.tempfile_tail(callback=self.log_trufflehog_status)
try:
Expand Down
Loading
Loading