arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

#1447 - back-end usage scenario

Open 4ntoine opened this issue 2 years ago • 5 comments

Add .proto file (messages and a service), generate go files. (Draft to demonstrate the proposal).

Please check if the PR fulfills these requirements

  • [ ] The PR has no duplicates (please search among the Pull Requests before creating one)
  • [ ] The PR follows our contributing guidelines
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)
  • [ ] UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce? The MR Draft demonstrates the back-end scenario when client and server are on different hosts thus making direct files access problematic. So the client can't read neither the sketches content, nor the compiled binaries.
  • What is the current behavior? The feature is not implemented
  • What is the new behavior? There is "file system" service allowing to request file content.
  • Other information: This is an alternative to returning file content every here and there.

See how to contribute

4ntoine avatar Nov 03 '21 18:11 4ntoine

Interesting proposal but I have some concerns.

Protocol buffers are not meant to be used with large data sets as per documentation, sending the whole content of a file via gRPC is not a great idea I think.

But the major concern is about security, if the arduino-cli is running on a backend and any client can ask the content of any file that has permission to read you open up a BIG hole I think. Am not really confortable with this.

In the end I think this must not be a concern of the CLI, files exchange should be handled by another service.

silvanocerza avatar Nov 04 '21 14:11 silvanocerza

@silvanocerza Yeah, your concerns are more than reasonable. I've been also thinking about that. It seems if we limit the paths to user and build dirs only (to be able to load the sketches and compiled binaries) it should be ok. Also we might register the service to the server only if daemon is started with a new --with-file-system flag (switched off by default), so users who intentionally want to run it for back-end use case will be able to do it (and the rest will be not affected at all).

If we're talking about sketches and compiled binaries - they don't exceed kilobytes (megabytes max), so size seems to be not a huge issue. Also we can compress (see Type = raw/zip/etc) to reduce the size if still having some concerns on it.

I also agree that external (dedicated) service should do it better, but imo it's very small additional feature to provide a full set of needed functional so it seems to be not a big deal. I doubt that average user will be able to install smth like https://github.com/hubot-grpc/filesystem-grpc and want to deal with dockers, daemons, etc.

But instead it will allow users to use their laptops/desktops or even Raspi's with arduino-cli to compile for Arduino from any mobile client (smartphones, tablet, smart devices, etc).

4ntoine avatar Nov 04 '21 18:11 4ntoine

@4ntoine

But instead it will allow users to use their laptops/desktops or even Raspi's with arduino-cli to compile for Arduino from any mobile client (smartphones, tablet, smart devices, etc).

This is a use case I was interested in, but I have opted for running CLI on a Pi, editing files over SSH and then running the appropriate command over SSH with the board attached to the Pi's USB port. Have you thought about "mapping" the remote FS using SAMBA? You could in theory configure the CLI to have the paths required be subfolders of that mounted path. Not sure it would work on iPad, though

directories:
  data: /Users/ubi/Library/Arduino15
  downloads: /Users/ubi/Library/Arduino15/staging
  user: /data/Dropbox/AppsDocuments/Arduino

ubidefeo avatar Nov 04 '21 19:11 ubidefeo

@ubidefeo

yes, i tried different scenarios including samba (and it worked).

I'm thinking about "average user" and Arduino is awesome due to it's simplicity. So imo if it costs only 42 lines of code as in this MR lot's of people will say "thank you guys for doing our life easier"

4ntoine avatar Nov 04 '21 19:11 4ntoine

@silvanocerza will it work for you to address security concerns? i can update the MR

4ntoine avatar Nov 09 '21 03:11 4ntoine