-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add a new NDJSON / JSONL input source #4721
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
Open
bradlarsen
wants to merge
11
commits into
main
Choose a base branch
from
json-enumerator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,129
−331
Open
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9a6aac6
Add new JSONL enumerator input source
bradlarsen c9d08c1
Rename fields in new JSONL source
bradlarsen 054cfde
Add unit tests for new JSONL source
bradlarsen 64831c0
Merge branch 'main' into json-enumerator
bradlarsen d4337f5
Fix Cursor nits
bradlarsen 430b85b
Fix nits from @rosecodym
bradlarsen 1629d51
Merge branch 'main' into json-enumerator
bradlarsen 0d833d6
use std errors package instead of a third-party one
bradlarsen 84280ec
whitespace
bradlarsen e2f028e
Break up long lines; gofmt is no help
bradlarsen f2bd590
Merge branch 'main' into json-enumerator
bradlarsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package engine | ||
|
|
||
| import ( | ||
| "runtime" | ||
|
|
||
| "google.golang.org/protobuf/proto" | ||
| "google.golang.org/protobuf/types/known/anypb" | ||
|
|
||
| "github.com/trufflesecurity/trufflehog/v3/pkg/context" | ||
| "github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb" | ||
| "github.com/trufflesecurity/trufflehog/v3/pkg/sources" | ||
| "github.com/trufflesecurity/trufflehog/v3/pkg/sources/json_enumerator" | ||
| ) | ||
|
|
||
| // ScanJSONEnumeratorInput scans input that is in JSON Enumerator format | ||
| func (e *Engine) ScanJSONEnumeratorInput(ctx context.Context, c sources.JSONEnumeratorConfig) (sources.JobProgressRef, error) { | ||
| connection := &sourcespb.JSONEnumerator{ | ||
| Paths: c.Paths, | ||
| } | ||
| var conn anypb.Any | ||
| err := anypb.MarshalFrom(&conn, connection, proto.MarshalOptions{}) | ||
| if err != nil { | ||
| ctx.Logger().Error(err, "failed to marshal JSON enumerator connection") | ||
| return sources.JobProgressRef{}, err | ||
| } | ||
|
|
||
| sourceName := "trufflehog - JSON enumerator" | ||
| sourceID, jobID, err := e.sourceManager.GetIDs(ctx, sourceName, json_enumerator.SourceType) | ||
| if err != nil { | ||
| ctx.Logger().Error(err, "failed to get IDs from source manager") | ||
| return sources.JobProgressRef{}, err | ||
| } | ||
|
|
||
| source := &json_enumerator.Source{} | ||
| if err := source.Init(ctx, sourceName, jobID, sourceID, true, &conn, runtime.NumCPU()); err != nil { | ||
| return sources.JobProgressRef{}, err | ||
| } | ||
| return e.sourceManager.EnumerateAndScan(ctx, sourceName, source) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.