Description
Describe the bug
Arduino Web Editor has a "Secret tab" feature that makes it easy to share sketches without accidentally exposing sensitive data (e.g., passwords or tokens).
The values of these secrets can be defined on Arduino Cloud via a form in the "Secret" tab in Arduino Web Editor.
On Arduino Cloud, secrets are stored in a secure database and the secret macro values populated from there.
The secrets database capability is not available when using the Arduino IDE, so a more conventional approach is taken by defining the secrets macros in a header file named arduino_secrets.h
. In order to allow the use of the macros from this file, it's necessary to add an #include directive at the top of the primary sketch file for arduino_secrets.h
(#438) when it is pulled. Before pushing, the #include
directive should be removed.
Arduino Language syntax allows for an arbitrary number of spaces within an #include
directive at two locations:
- Between the
#
and theinclude
identifier. - Between the
include
identifier and the header file path.
The regular expression used by the Arduino IDE to find and remove this code:
https://github.com/arduino/arduino-ide/blob/2.0.0-beta.9/arduino-ide-extension/src/browser/create/create-api.ts#L247-L248
const includeString = `#include "${Create.arduino_secrets_file}"`;
const includeRegexp = new RegExp(includeString + '\\s*', 'g');
🐛 Does not currently accommodate any variation in the number of spaces.
🐛 In addition, it will match to incidental occurrences of this string which are not valid syntax.
To Reproduce
- Open a sketch from your Remote Sketchbook in the Arduino IDE
- Add the following line to the sketch file:
# include "arduino_secrets.h"
- Push the sketch to Arduino Cloud
- Pull the sketch from Arduino Cloud
🐛 You will now have this:
#include "arduino_secrets.h"
# include "arduino_secrets.h"
🐛 You will also have this line in the sketch when opened in Arduino Cloud:
# include "arduino_secrets.h"
- Open a sketch from your Remote Sketchbook in the Arduino IDE
- Add the following line to the sketch file:
#include "arduino_secrets.h"
- Push the sketch to Arduino Cloud
- Pull the sketch from Arduino Cloud
🐛 You will now have this:
#include "arduino_secrets.h"
#include "arduino_secrets.h"
- Open a sketch from your Remote Sketchbook in the Arduino IDE
- Add the following line to the sketch file:
// the purpose of #include "arduino_secrets.h" is to provide the secrets
- Push the sketch to Arduino Cloud
- Pull the sketch from Arduino Cloud
🐛 You will now have this:
// the purpose of is to provide the secrets
Expected behavior
Any valid form of #include
directive for arduino_secrets.h
to be recognized.
Occurrences of #include "arduino_secrets.h"
in comments to be left alone.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop
- OS: Windows
- Version: Version: 2.0.0-beta.9
Date: 2021-07-08T14:42:27.433Z
CLI Version: 0.18.3 alpha [d710b642]