Doveps / mono

Code for Doveps projects
http://doveps.com
MIT License
0 stars 0 forks source link

04-02-2018: Reading from stdin #136

Closed JosiahRegencia closed 6 years ago

JosiahRegencia commented 6 years ago

Limited file uploads to only 1 file.

https://github.com/Doveps/mono/blob/2c757d1b4c6b561d1514f8daec17aee40388fd60/savant/app/get_scanned.py#L26-L30

Added loggers based on the code above. The result is still the same. Through unit testing, it doesn't seem to read the contents of the file. screenshot from 2018-04-02 21-26-55

One more thing: In my curl commands, I use the flag -F. Reading from the site below, I learned the -F flag means that it reads from the stdin instead of the file itself. The unittest, somehow seems to be reading directly from the file. Hence, it doesn't read the contents, I guess (which is likely to be true). http://manpages.ubuntu.com/manpages/xenial/man1/curl.1.html

Either I find a way to have the API read the file directly and not from stdin

OR

Have the unit tests read from stdin instead of directly to the file.

Which one should I do?

JosiahRegencia commented 6 years ago

Forgot to mention. It's able to read the file. As opposed to multiple files, it's not able to detect any of them

greenmoss commented 6 years ago

Good debugging. I think you are getting closer.

Reading from STDIN is good for a single file. If you want to do multiple, I don't think you can do STDIN. If I remember correctly, we decided to do multiple per API call, so I guess we can't use -F.

JosiahRegencia commented 6 years ago

Seems like we could from STDIN for multiple files. It's what I did in the previous

greenmoss commented 6 years ago

I thought we had to specify multiple files using multiple arguments. STDIN is a single stream, so how would the parser know where one file ends and the next one begins?

JosiahRegencia commented 6 years ago

Flavor creation:

curl -F "files[]=@tests/Scanner_Files/33.33.33.50/find_debs_stdout.log" -F "files[]=@tests/Scanner_Files/33.33.33.50/find_groups_stdout.log" -F "files[]=@tests/Scanner_Files/33.33.33.50/find_shadow_stdout.log" -F "files[]=@tests/Scanner_Files/33.33.33.50/find_users_stdout.log" http://127.0.0.1:5000/doveps/api/flavor/create/

Comparison: curl -F "files[]=@tests/Scanner_Files/33.33.33.51/find_debs_stdout.log" -F "files[]=@tests/Scanner_Files/33.33.33.51/find_groups_stdout.log" -F "files[]=@tests/Scanner_Files/33.33.33.51/find_shadow_stdout.log" -F "files[]=@tests/Scanner_Files/33.33.33.51/find_users_stdout.log" http://127.0.0.1:5000/doveps/api/flavor/compare/

Is that what this does?

zerstoeren commented 6 years ago

So you are trying to loop through the inputs?

On Mon, Apr 2, 2018, 9:47 PM Josiah Eleazar T. Regencia < notifications@github.com> wrote:

Flavor creation:

curl -F "files[]=/33.33.33.50/find_debs_stdout.log" -F "files[]=/ 33.33.33.50/find_groups_stdout.log" -F "files[]=/ 33.33.33.50/find_shadow_stdout.log" -F "files[]=/ 33.33.33.50/find_users_stdout.log" http://127.0.0.1:5000/doveps/api/flavor/create/

Comparison: curl -F "files[]=/33.33.33.51/find_debs_stdout.log" -F "files[]=/ 33.33.33.51/find_groups_stdout.log" -F "files[]=/ 33.33.33.51/find_shadow_stdout.log" -F "files[]=/ 33.33.33.51/find_users_stdout.log" http://127.0.0.1:5000/doveps/api/flavor/compare/

Is that what this does?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Doveps/mono/issues/136#issuecomment-378101774, or mute the thread https://github.com/notifications/unsubscribe-auth/AGbogmVRRYjNKVYliJ1v9ACBo4ArmUy5ks5tktS7gaJpZM4TDjYW .

greenmoss commented 6 years ago

I ran curl --help and it shows

-F, --form CONTENT Specify HTTP multipart POST data (H)

so... maybe -F is correct after all

JosiahRegencia commented 6 years ago

Yup. In loops. Because in the original it saves all the uploaded files in a list