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

Add -f option for Json output to allow field filtering #1373

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

soonghee2
Copy link
Contributor

@soonghee2 soonghee2 commented Feb 4, 2025

Updated PR Message (for JSON field filtering)

Description

This PR enhances the existing -json output functionality by adding support for a -f (or --field) option.
Users can now specify which fields they want in the JSON output instead of always receiving all available fields.

Additionally, unlike the previous -csv PR(#1372), the option name has been updated from CSVFields to Fields for consistency across output formats.

Related Issue

Closes #1371

Related PR

#1372

Changes Introduced

  • Added -f option to allow field filtering when using -json.
  • Updated JSON output logic to include only specified fields.

Example Usage

Outputs only the ip and port fields instead of the full dataset.

naabu$ ./naabu -host example.com -p 80,443 -j -f "ip,port"

                  __
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/

		projectdiscovery.io

[INF] Current naabu version 2.3.4 (latest)
[INF] Host discovery disabled: less than two ports were specified
[INF] Running CONNECT scan with non root privileges
{"ip":"96.7.128.175","port":80}
{"ip":"96.7.128.175","port":443}
[INF] Found 2 ports on host example.com (96.7.128.175)

Looking forward to feedback

pkg/runner/options.go Outdated Show resolved Hide resolved
pkg/runner/runner.go Outdated Show resolved Hide resolved
pkg/runner/output.go Outdated Show resolved Hide resolved
This commit aligns the column names in all CSV files with the project's data dictionary. This ensures consistency and avoids potential issues with data interpretation.
@soonghee2
Copy link
Contributor Author

@ehsandeep I implemented your feedback. Could you please check this? Thank you!

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.

Support field filtering in CSV output (-f option for -csv)
2 participants