-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
fix: removed unsafe shell
when executing process
#2067
Conversation
d6a4900
to
d69174a
Compare
@@ -55,7 +21,7 @@ export function spawnCommand( | |||
stdIn?: string | |||
): Promise<string> { | |||
return new Promise<string>((resolve, reject) => { | |||
const cp = spawn(command, args, { windowsHide: true, shell: true }); | |||
const cp = spawn(command, args, { windowsHide: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto Format operation fails
The invocation of clang-format when using the "Auto Format" feature fails with the error: "Invalid value for -style
"
To reproduce
- Create a sketch that would be modified by an "Auto Format" operation:
void setup (){ //foo } void loop() {}
- Select Tools > Auto Format from the Arduino IDE menus.
🐛 The sketch is not formatted. - Check the logs.
🐛 The logs show the clang-format
command errored:
2023-05-15T06:56:48.633Z root ERROR Request format failed with error: Error executing E:\incoming\review\2067\1-e203c61\resources\app\node_modules\arduino-ide-extension\build\clang-format.exe -style="{\"AccessModifierOffset\":-2,\"AlignAfterOpenBracket\":\"Align\",\"AlignArrayOfStructures\":\"None\",\"AlignConsecutiveAssignments\":\"None\",\"AlignConsecutiveBitFields\":\"None\",\"AlignConsecutiveDeclarations\":\"None\",\"AlignConsecutiveMacros\":\"None\",\"AlignEscapedNewlines\":\"DontAlign\",\"AlignOperands\":\"Align\",\"AlignTrailingComments\":true,\"AllowAllArgumentsOnNextLine\":true,\"AllowAllConstructorInitializersOnNextLine\":true,\"AllowAllParametersOfDeclarationOnNextLine\":true,\"AllowShortBlocksOnASingleLine\":\"Always\",\"AllowShortCaseLabelsOnASingleLine\":true,\"AllowShortEnumsOnASingleLine\":true,\"AllowShortFunctionsOnASingleLine\":\"Empty\",\"AllowShortIfStatementsOnASingleLine\":\"AllIfsAndElse\",\"AllowShortLambdasOnASingleLine\":\"Empty\",\"AllowShortLoopsOnASingleLine\":true,\"AlwaysBreakAfterDefinitionReturnType\":\"None\",\"AlwaysBreakAfterReturnType\":\"None\",\"AlwaysBreakBeforeMultilineStrings\":false,\"AlwaysBreakTemplateDeclarations\":\"No\",\"AttributeMacros\":[\"__capability\"],\"BasedOnStyle\":\"LLVM\",\"BinPackArguments\":true,\"BinPackParameters\":true,\"BitFieldColonSpacing\":\"Both\",\"BraceWrapping\":{\"AfterCaseLabel\":false,\"AfterClass\":false,\"AfterControlStatement\":\"Never\",\"AfterEnum\":false,\"AfterFunction\":false,\"AfterNamespace\":false,\"AfterObjCDeclaration\":false,\"AfterStruct\":false,\"AfterUnion\":false,\"AfterExternBlock\":false,\"BeforeCatch\":false,\"BeforeElse\":false,\"BeforeLambdaBody\":false,\"BeforeWhile\":false,\"IndentBraces\":false,\"SplitEmptyFunction\":true,\"SplitEmptyRecord\":true,\"SplitEmptyNamespace\":true},\"BreakAfterJavaFieldAnnotations\":false,\"BreakBeforeBinaryOperators\":\"NonAssignment\",\"BreakBeforeBraces\":\"Attach\",\"BreakBeforeConceptDeclarations\":false,\"BreakBeforeInheritanceComma\":false,\"BreakBeforeTernaryOperators\":true,\"BreakConstructorInitializers\":\"BeforeColon\",\"BreakConstructorInitializersBeforeComma\":false,\"BreakInheritanceList\":\"BeforeColon\",\"BreakStringLiterals\":false,\"ColumnLimit\":0,\"CommentPragmas\":\"\",\"CompactNamespaces\":false,\"ConstructorInitializerAllOnOneLineOrOnePerLine\":false,\"ConstructorInitializerIndentWidth\":2,\"ContinuationIndentWidth\":2,\"Cpp11BracedListStyle\":false,\"DeriveLineEnding\":true,\"DerivePointerAlignment\":true,\"DisableFormat\":false,\"EmptyLineAfterAccessModifier\":\"Leave\",\"EmptyLineBeforeAccessModifier\":\"Leave\",\"ExperimentalAutoDetectBinPacking\":false,\"FixNamespaceComments\":false,\"ForEachMacros\":[\"foreach\",\"Q_FOREACH\",\"BOOST_FOREACH\"],\"IfMacros\":[\"KJ_IF_MAYBE\"],\"IncludeBlocks\":\"Preserve\",\"IncludeCategories\":[{\"Regex\":\"^^\\\"(llvm|llvm-c|clang|clang-c)/\",\"Priority\":2,\"SortPriority\":0,\"CaseSensitive\":false},{\"Regex\":\"^(<|\\\"(gtest^|gmock^|isl^|json)/)\",\"Priority\":3,\"SortPriority\":0,\"CaseSensitive\":false},{\"Regex\":\".*\",\"Priority\":1,\"SortPriority\":0,\"CaseSensitive\":false}],\"IncludeIsMainRegex\":\"\",\"IncludeIsMainSourceRegex\":\"\",\"IndentAccessModifiers\":false,\"IndentCaseBlocks\":true,\"IndentCaseLabels\":true,\"IndentExternBlock\":\"Indent\",\"IndentGotoLabels\":false,\"IndentPPDirectives\":\"None\",\"IndentRequires\":true,\"IndentWidth\":2,\"IndentWrappedFunctionNames\":false,\"InsertTrailingCommas\":\"None\",\"JavaScriptQuotes\":\"Leave\",\"JavaScriptWrapImports\":true,\"KeepEmptyLinesAtTheStartOfBlocks\":true,\"LambdaBodyIndentation\":\"Signature\",\"Language\":\"Cpp\",\"MacroBlockBegin\":\"\",\"MacroBlockEnd\":\"\",\"MaxEmptyLinesToKeep\":100000,\"NamespaceIndentation\":\"None\",\"ObjCBinPackProtocolList\":\"Auto\",\"ObjCBlockIndentWidth\":2,\"ObjCBreakBeforeNestedBlockParam\":true,\"ObjCSpaceAfterProperty\":false,\"ObjCSpaceBeforeProtocolList\":true,\"PPIndentWidth\":-1,\"PackConstructorInitializers\":\"BinPack\",\"PenaltyBreakAssignment\":1,\"PenaltyBreakBeforeFirstCallParameter\":1,\"PenaltyBreakComment\":1,\"PenaltyBreakFirstLessLess\":1,\"PenaltyBreakOpenParenthesis\":1,\"PenaltyBreakString\":1,\"PenaltyBreakTemplateDeclaration\":1,\"PenaltyExcessCharacter\":1,\"PenaltyIndentedWhitespace\":1,\"PenaltyReturnTypeOnItsOwnLine\":1,\"PointerAlignment\":\"Right\",\"QualifierAlignment\":\"Leave\",\"ReferenceAlignment\":\"Pointer\",\"ReflowComments\":false,\"RemoveBracesLLVM\":false,\"SeparateDefinitionBlocks\":\"Leave\",\"ShortNamespaceLines\":0,\"SortIncludes\":\"Never\",\"SortJavaStaticImport\":\"Before\",\"SortUsingDeclarations\":false,\"SpaceAfterCStyleCast\":false,\"SpaceAfterLogicalNot\":false,\"SpaceAfterTemplateKeyword\":false,\"SpaceAroundPointerQualifiers\":\"Default\",\"SpaceBeforeAssignmentOperators\":true,\"SpaceBeforeCaseColon\":false,\"SpaceBeforeCpp11BracedList\":false,\"SpaceBeforeCtorInitializerColon\":true,\"SpaceBeforeInheritanceColon\":true,\"SpaceBeforeParens\":\"ControlStatements\",\"SpaceBeforeParensOptions\":{\"AfterControlStatements\":true,\"AfterForeachMacros\":true,\"AfterFunctionDefinitionName\":false,\"AfterFunctionDeclarationName\":false,\"AfterIfMacros\":true,\"AfterOverloadedOperator\":false,\"BeforeNonEmptyParentheses\":false},\"SpaceBeforeRangeBasedForLoopColon\":true,\"SpaceBeforeSquareBrackets\":false,\"SpaceInEmptyBlock\":false,\"SpaceInEmptyParentheses\":false,\"SpacesBeforeTrailingComments\":2,\"SpacesInAngles\":\"Leave\",\"SpacesInCStyleCastParentheses\":false,\"SpacesInConditionalStatement\":false,\"SpacesInContainerLiterals\":false,\"SpacesInLineCommentPrefix\":{\"Minimum\":0,\"Maximum\":-1},\"SpacesInParentheses\":false,\"SpacesInSquareBrackets\":false,\"Standard\":\"Auto\",\"StatementAttributeLikeMacros\":[\"Q_EMIT\"],\"StatementMacros\":[\"Q_UNUSED\",\"QT_REQUIRE_VERSION\"],\"TabWidth\":2,\"UseCRLF\":false,\"UseTab\":\"Never\",\"WhitespaceSensitiveMacros\":[\"STRINGIZE\",\"PP_STRINGIZE\",\"BOOST_PP_STRINGIZE\",\"NS_SWIFT_NAME\",\"CF_SWIFT_NAME\"]}": Invalid value for -style
Expected behavior
No error from the generated clang-format
command
Arduino IDE version
e203c61 (tester build for d69174a)
Operating system
Windows 11
Additional context
The fault does not occur when using the latest build from the main
branch (117b2a4).
The fault occurs even with the IDE installed under a path that does not contain spaces.
db14dd8
to
e1b3953
Compare
Thank you, Per. The latest version of this PR should contain the fix. Just so you know, I removed the unique styles handling on Windows. (See #1285.) I covered the |
d3dc5b8
to
96b40c0
Compare
Please review. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code reviewed, no issues identified.
I've run the related tests locally on my intel mac and they pass.
I've also tested the IDE2 locally on the same machine and confirm the verify steps above are working, including an upload, and firmware update of the MKR WiFi 1010.
Ref: PNX-3671 Co-authored-by: per1234 <accounts@perglass.com> Co-authored-by: Akos Kitta <a.kitta@arduino.cc> Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Akos! I'm very glad that you were able to remove that hacky clang-format
-style
flag argument quoting code for the Windows command interpreter as part of this work.
Motivation
To eliminate the unsafe
shell: true
options when spawning processes. No IDE2 functionality changes are expected.Change description
chai-string
and the corresponding type declarations,getExecPath
function and removed another dependency:which
, andOther information
Steps to verify:
Ref: PNX-3671
Reviewer checklist