reject env variables containing newlines when debugging (#2518)

This commit is contained in:
Bob Brown 2022-04-22 14:43:18 -07:00 коммит произвёл GitHub
Родитель a986b8edc7
Коммит da57409f0e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -14,6 +14,7 @@ Bug Fixes:
- Fix schema validation for presets version 4. [#2490](https://github.com/microsoft/vscode-cmake-tools/issues/2490)
- Remove problematic environment variables from the debugger environment. [#2442](https://github.com/microsoft/vscode-cmake-tools/issues/2442)
- Fix preferredGenerator "Watcom WMake" not working. [#2500](https://github.com/microsoft/vscode-cmake-tools/issues/2500)
- Exclude environment variables from debugging if the values have newlines. [#2515](https://github.com/microsoft/vscode-cmake-tools/issues/2515)
## 1.10.5
Bug Fixes:

Просмотреть файл

@ -376,7 +376,7 @@ export function makeDebuggerEnvironmentVars(env?: Environment): DebuggerEnvironm
if (!env) {
return [];
}
const filter: RegExp = /\$\{.+?\}/; // Disallow env variables that have variable expansion values
const filter: RegExp = /\$\{.+?\}|\n/; // Disallow env variables that have variable expansion values or newlines
const converted_env: DebuggerEnvironmentVariable[] = [];
for (const [key, value] of Object.entries(env)) {
if (value !== undefined && !value.match(filter)) {

Просмотреть файл

@ -8,9 +8,10 @@ suite('debugger tests', () => {
env['other'] = '${hey';
env['BASH_FUNC_which%%'] = '() { ( alias;\n eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot \"$@\"\n}';
env['BASH_FUNC_module()'] = '() { eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh';
env['BASH_FUNC_ml%%'] = '() { module ml \"$@\"\n}';
const debugEnv = fromDebuggerEnvironmentVars(makeDebuggerEnvironmentVars(env));
expect(debugEnv).to.contain.keys('foo', 'other');
expect(debugEnv).to.not.contain.keys('BASH_FUNC_which%%', 'BASH_FUNC_module()');
expect(debugEnv).to.not.contain.keys('BASH_FUNC_which%%', 'BASH_FUNC_module()', 'BASH_FUNC_ml%%');
});
});