Skip to content

Skip readonly variables in process handler #4174

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

localconst
Copy link
Contributor

Skip read-only variables in process handler to fit design concept:
https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/readonly-variables.md

@localconst localconst requested review from a team as code owners February 28, 2023 16:22
@localconst localconst self-assigned this Feb 28, 2023

if (_readonlyEnvVariables.Contains(key, StringComparer.OrdinalIgnoreCase))
{
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider: log an error (or at least a warning) when attempting to set a 'read-only variable'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure we want to throw error or warning here, because customer or task owner didn't really control what variables will be. Here we get all the environment variables and process them from case to case

string value = line.Substring(index + 1);

if (_readonlyEnvVariables.Contains(key, StringComparer.OrdinalIgnoreCase))
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider: use feature flag for this change + collect metrics to determine impact and effectiveness

@@ -126,6 +129,8 @@ public async Task RunAsync()
{
// Format the command so the environment variables can be captured.
cmdExeArgs = $"/c \"{command} {arguments} && echo {OutputDelimiter} && set \"";

_readonlyEnvVariables = Constants.Variables.ReadOnlyVariables.ConvertAll(var => VarUtil.ConvertToEnvVariableFormat(var));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One point missed here - we shoud also collect runtime env variables.
we may get full list of readonly variables from the AZP_READONLY_ENV_VARIABLES implemented here: #4175

@localconst localconst marked this pull request as draft March 30, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants