-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Markdown output format #4650
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
base: main
Are you sure you want to change the base?
Markdown output format #4650
Conversation
Added line number and hasLine fields to markdownRow. Updated Print method to handle line number and sanitization.
|
Hey @dasmfm - thanks for taking the time to contribute to the project! Unfortunately, we have some concerns about the specificity of this PR. Markdown output is cool, but this implementation is tailored for filesystem output, and will generate deficient output if other sources are scanned instead. It also seems like markdown could be generated from generated JSON (by a separate postprocessor), which would allow for more generality and eliminate the need to change TruffleHog itself. This seems to us like a preferable solution. I don't know what your use case is - did you consider something like that? Would it work for you? |
| if isTrue(inputs["markdown"].Value) { | ||
| command = append(command, "--markdown") | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TUI allows conflicting output format flags simultaneously
Low Severity
The TUI configuration allows users to enable both --markdown and --json output formats simultaneously without any validation or warning. When both are enabled, the Cmd() function appends both flags to the command, but main.go's switch statement checks *jsonOut before *markdownOut, causing JSON to silently take precedence. Users enabling both options may unexpectedly receive JSON output instead of the Markdown they also selected.
Additional Locations (1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's common pattern for all printers. If neccesary, should be fixed in separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| if !hasFile { | ||
| file = "n/a" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant fallback already handled by helper function
Low Severity
The check if !hasFile { file = "n/a" } is redundant. The extractFileLine function in helpers.go already initializes file to "n/a" as its default value (line 9), and only updates it when a file is actually found. When hasFile is false, file is already "n/a", making this conditional assignment unnecessary.
Description:
Basic support for Markdown output.
For now there are hardcoded fields, but in the future it could be easily extended.
Checklist:
make test-community)?make lintthis requires golangci-lint)?