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

Fix issue with debug output masking if it contains special symbols #3464

Merged

Conversation

alexander-smolyakov
Copy link
Contributor

@alexander-smolyakov alexander-smolyakov commented Jul 19, 2021

Issue description:
Currently, the secret masker doesn't mask debug output of the task.setvariable command if it contains specials symbols in the variable value (e.g. %).

Example:

Before percent decode
secretName = text_percents_azp25
secretValue = {"first":{"second":{"third":{"password":"%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25%AZP25"}}}}
--------------------
After percent decode
secretName = text_percents_azp25
secretValue = {"first":{"second":{"third":{"password":"%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25"}}}}
##[debug]set text_percents_azp25=********
##[debug]Processed: ##vso[task.setvariable variable=text_percents_azp25;issecret=true;]{"first":{"second":{"third":{"password":"%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25%AZP25AZP25"}}}}
--------------------------------------

Fix description:
It seems the issue is related to the fact that we adding only unescaped command strings to the masker dictionary. To fix this problem we should add to the secret masker dictionary both escaped and unescaped strings.

Changes

  • Extracted logic for escaping and unescaping special symbols to CommandStringConvertor class
  • Added escape data of ##vso commands to the secret masker to resolve the problem with debug output masking
  • Removed Agent.Sdk.Knob from the Command class as it is not used in the code.

Documentation changes required: No

Added unit tests: No

Attached related issue:

Aleksandr Smolyakov added 2 commits July 18, 2021 20:47
* Extract logic for escaping and unescaping  special symbols to `CommandStringConvertor` class
* Add escape data of `##vso` commands to the secret masker to resolve the problem with debug output masking
* Remove `Agent.Sdk.Knob` from `Command` class as it is not used in the code.
Copy link
Contributor

@mjroghelia mjroghelia left a comment

Choose a reason for hiding this comment

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

Looks ok to me. Please hold off on merging until @damccorm has reviewed.

Copy link

@damccorm damccorm left a comment

Choose a reason for hiding this comment

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

Looks good to me - thanks for doing this!

@alexander-smolyakov alexander-smolyakov requested a review from a team July 20, 2021 07:38
@EzzhevNikita
Copy link
Contributor

Tested these changes manually seems like everything work as expected

@EzzhevNikita EzzhevNikita requested a review from a team July 21, 2021 07:16
Copy link
Contributor

@DaniilShmelev DaniilShmelev left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mjroghelia mjroghelia merged commit 390dc24 into master Jul 21, 2021
@mjroghelia mjroghelia deleted the users/alexander-smolyakov/issue1326_fix_logs_masking branch July 21, 2021 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants