rapid7 / godap

The Data Analysis Pipeline
MIT License
17 stars 10 forks source link

add a csv output type backed by lines factory function #5

Closed ssikdar-r7 closed 5 years ago

ssikdar-r7 commented 5 years ago

With ruby dap if I take a json input and try to do a csv output:

$ echo '{"foo":"bar", "baz":"qux", "a":"b"}'  | dap json + csv
bar,qux,b

If I try with godap:

$ echo '{"foo":"bar", "baz":"qux", "a":"b"}'  | /Users/ssikdar/go/bin/godap json + csv
Error: Invalid output plugin: csv

Comparing the available outputs:

$ dap --outputs
Outputs:
  * lines
  * json
  * csv
$ /Users/ssikdar/go/bin/godap  --outputs
Outputs:
 * lines
 * json

However at a quick look, looks like lines in fact is basically doing the function of csv w/ delims etc. ( Not sure if this completely true, I just took a quick look)

My change was to register another RegisterOutput w/ factory function with csv (but maybe it should be in a csv.go ?)

With my change:

$ go build -o dappy
$ ./dappy --outputs
Outputs:
 * json
 * lines
 * csv
$ echo '{"foo":"bar", "baz":"qux", "a":"b"}'  | ./dappy json + csv
bar,qux,b
dabdine-r7 commented 5 years ago

I didn't originally implement csv, because lines and csv in dap seem very similar to begin with: https://github.com/rapid7/dap/blob/master/lib/dap/output.rb

Can you verify the functionality? There are minor differences between both output handlers...

ssikdar-r7 commented 5 years ago

you're right! looked at the code, tried recreated some code snippets in ibr, and compared both tools functionality looks to be the same.

closing pull request!