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

Propagate file info in log context #3405

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

rgmz
Copy link
Contributor

@rgmz rgmz commented Oct 14, 2024

Description:

I noticed that file-related errors no longer (?) include information about the file in the log context. This makes troubleshooting errors incredibly difficult. Also, in some cases the information is included but is duplicated.

Before

2024-10-14T13:00:47-04:00	error	trufflehog	error unarchiving chunk.	{"source_manager_worker_id": "qCLmT", "unit": "/tmp/desktop", "unit_kind": "dir", "mime": "application/x-rar-compressed", "timeout": 60, "error": "error extracting archive with format: .rar: rardecode: incorrect password"}
2024-10-14T12:33:22-04:00	error	trufflehog	error handling binary file	{"source_manager_worker_id": "zo8YL", "unit": "https://github.com/operasoftware/desktop.git", "unit_kind": "repo", "repo": "https://github.com/operasoftware/desktop.git", "filename": "lgpl/sources/chromium/src/chrome/installer/mac/third_party/xz/xz/tests/files/unsupported-check.xz", "commit": "87acf535ec96827fa48c134de50b6225ad0fc432", "file": "lgpl/sources/chromium/src/chrome/installer/mac/third_party/xz/xz/tests/files/unsupported-check.xz", "error": "error creating custom reader: error identifying archive: matching zip: xz: integrity check type not supported"}

After

2024-10-14T13:00:47-04:00	error	trufflehog	error unarchiving chunk.	{"source_manager_worker_id": "qCLmT", "unit": "/tmp/desktop", "unit_kind": "dir", "commit": "9e22ccb", "path": "lgpl/sources/chromium/src/chrome/test/data/safe_browsing/rar/passwd1234_two_files.rar", "mime": "application/x-rar-compressed", "timeout": 60, "error": "error extracting archive with format: .rar: rardecode: incorrect password"}
2024-10-14T12:53:25-04:00	error	trufflehog	error handling binary file	{"source_manager_worker_id": "bnjof", "unit": "/tmp/desktop", "unit_kind": "dir", "repo": "https://github.com/operasoftware/desktop.git", "commit": "95264d4038ea7e1ddb9a8942e09b2329f8e68093", "path": "lgpl/sources/chromium/src/third_party/zstd/src/tests/gzip/hufts-segv.gz", "error": "error creating custom reader: error identifying archive: matching zip: flate: corrupt input before offset 5"}

Checklist:

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

@rgmz rgmz requested a review from a team as a code owner October 14, 2024 17:17
return handlers.HandleFile(ctx, readCloser, &chunkSkel, reporter)
Verify: s.verify,
}
fileCtx := context.WithValues(ctx, "path", meta.GetFile())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect this method is only called via the Enterprise flow. Source-specific changes would presumably need to be made for each source.

@rgmz rgmz force-pushed the chore/log-ctx-info branch from 1685475 to fef37cd Compare October 14, 2024 17:19
Copy link
Collaborator

@ahrav ahrav left a comment

Choose a reason for hiding this comment

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

That looks a lot better. Thanks!

@ahrav ahrav merged commit 34e443a into trufflesecurity:main Oct 15, 2024
13 checks passed
@rgmz rgmz deleted the chore/log-ctx-info branch October 15, 2024 00:14
abmussani added a commit to abmussani/trufflehog that referenced this pull request Oct 15, 2024
* main:
  feat: propagate file info in log context (trufflesecurity#3405)
  fix(deps): update module github.com/xanzy/go-gitlab to v0.112.0 (trufflesecurity#3410)
  fix(deps): update module github.com/getsentry/sentry-go to v0.29.1 (trufflesecurity#3408)
  fix(deps): update module github.com/gabriel-vasile/mimetype to v1.4.6 (trufflesecurity#3407)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants