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

A further generalized idea of modifying UserSettings.txt sketch-wide #283

Open
xcvista opened this issue Aug 13, 2018 · 5 comments
Open
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@xcvista
Copy link

xcvista commented Aug 13, 2018

This is a generalized solution to #15 and #29. It adds one preprocessor macro to the sketch file, while achieving the same effects without introducing special files:

#pragma arduino

Whatever text comes after this preprocessor macro, to the end of the line, is treated as part of the UserSettings.txt. For example putting the followign lines in the sketch:

#pragma arduino compiler.c.extra_flags=-DNDEBUG
#pragma arduino compiler.cpp.extra_flags={compiler.c.extra_flags} -DTESTLIBRARY_BUFSIZE=100

is equivalent to adding the following lines to UserSettings.txt for the specific sketch:

compiler.c.extra_flags=-DNDEBUG
compiler.cpp.extra_flags={compiler.c.extra_flags} -DTESTLIBRARY_BUFSIZE=100
@phd
Copy link

phd commented Aug 25, 2018

  1. Will this pragma also affect build process for libraries if added to the sketch code?
    If not, then it will not be quite useful as an extension to platform.txt.

  2. This has the same security problems as Adding support for sketch-specific build properties #29. A malicious sketch can modify commands' paths without user's consent.

I have shared pull request #282 which adds full platform.sketch.txt file support while providing an IDE configuration option for enabling it first.
Comments are welcome.

@xcvista
Copy link
Author

xcvista commented Aug 25, 2018

@phd

  1. Yes it will. This #pragma is handled no later than the library-introducing #include directives, and will affect the entire build process.
  2. The paths of all executables being called by arduino-build can be limited with whitelisting: any subdirectory within the Arduino-related folders, and any subdirectory within the current sketch. It is up to the user not to download untrustworthy platforms.

@phd
Copy link

phd commented Aug 25, 2018

@xcvista

  1. Then it seems like a nice replacement for my pull request.
    I could probably modify it soon to support this.

  2. User may download sample sketches and they should not be allowed (by default) to mess with the system.
    I think a configuration option in the Arduino IDE for this pragma would be a solution. Maybe even something like a "no/ask/yes" setting.

@xcvista
Copy link
Author

xcvista commented Aug 25, 2018

@phd

Based on this path whitelist, the user should be able to choose among blocking, prompting and allowing execution of programs outside the list. The user should also be allowed to maintain his own additional list of whitelisted paths (Arduino-related directories are always allowed.)

@xcvista
Copy link
Author

xcvista commented Aug 25, 2018

@phd The _Pragma() syntax need not to be supported right now, just #pragma arduino.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

3 participants