Skip to content

fix: throws error if dir not found #3419

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

Merged

Conversation

sahil9001
Copy link
Contributor

Description:

This PR relates to #3005 . If the directory is not found, the process returns an error message and exits.

Screenshot 2024-10-16 at 1 42 58 AM

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@sahil9001 sahil9001 requested review from a team as code owners October 15, 2024 20:13
Comment on lines +331 to +334
// Check if the directory exists
if _, err := os.Stat(gitDir); os.IsNotExist(err) {
return fmt.Errorf("directory does not exist: %s", gitDir)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this change is the only one that's needed. With just it applied, this is the output I get:

trufflehog (remotes/origin/HEAD *) % ./trufflehog git file:///oops
🐷🔑🐷  TruffleHog. Unearth your secrets. 🐷🔑🐷

2024-10-16T16:14:08-04:00	info-0	trufflehog	running source	{"source_manager_worker_id": "hN9fy", "with_units": true}
2024-10-16T16:14:08-04:00	error	trufflehog	error running scan	{"error": "engine failed to finish execution: fatal: directory does not exist: /oops"}
trufflehog (remotes/origin/HEAD *) % echo $?
1

Are you seeing something different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rosecodym Thanks for the review, I have removed the code. Can you please check again?

@sahil9001 sahil9001 requested review from a team as code owners June 23, 2025 18:30
@sahil9001
Copy link
Contributor Author

@kashifkhan0771 Can you please review this minor PR? Thanks!

@kashifkhan0771 kashifkhan0771 linked an issue Jun 24, 2025 that may be closed by this pull request
@kashifkhan0771 kashifkhan0771 requested a review from rosecodym June 24, 2025 14:34
@kashifkhan0771 kashifkhan0771 merged commit bda0787 into trufflesecurity:main Jun 24, 2025
13 checks passed
@rosecodym rosecodym mentioned this pull request Jun 24, 2025
2 tasks
@shahzadhaider1 shahzadhaider1 mentioned this pull request Jun 25, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Git source should fail if directory doesn't exists
3 participants