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

[App Service] BREAKING CHANGE: Redact tokens output on deployment source update-token #27614

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2052,12 +2052,17 @@ def config_source_control(cmd, resource_group_name, name, repo_url, repository_t
def update_git_token(cmd, git_token=None):
'''
Update source control token cached in Azure app service. If no token is provided,
the command will clean up existing token.
the command will clean up existing token. Note that tokens are now redacted in the result.
kamperiadis marked this conversation as resolved.
Show resolved Hide resolved
'''
client = web_client_factory(cmd.cli_ctx)
from azure.mgmt.web.models import SourceControl
sc = SourceControl(name='not-really-needed', source_control_name='GitHub', token=git_token or '')
return client.update_source_control('GitHub', sc)
response = client.update_source_control('GitHub', sc)
logger.warning('Tokens have been redacted.')
kamperiadis marked this conversation as resolved.
Show resolved Hide resolved
response.refresh_token = None
response.token = None
response.token_secret = None
return response


def show_source_control(cmd, resource_group_name, name, slot=None):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
interactions:
- request:
body: '{"properties": {"token": "password1234"}}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- functionapp deployment source update-token
Connection:
- keep-alive
Content-Length:
- '41'
Content-Type:
- application/json
ParameterSetName:
- --git-token
User-Agent:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-web/7.0.0 Python/3.8.0 (Windows-10-10.0.22621-SP0)
method: PUT
uri: https://management.azure.com/providers/Microsoft.Web/sourcecontrols/GitHub?api-version=2022-03-01
response:
body:
string: '{"id":null,"name":"GitHub","type":"Microsoft.Web/sourcecontrols","properties":{"name":"GitHub","token":"password1234","tokenSecret":null,"refreshToken":null,"environment":null}}'
headers:
cache-control:
- no-cache
content-length:
- '177'
content-type:
- application/json
date:
- Thu, 02 Nov 2023 17:26:42 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-IIS/10.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-aspnet-version:
- 4.0.30319
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-tenant-writes:
- '1199'
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,13 @@ def test_functionapp_linux_consumption_zip_deploy_missing_appsetting(self, resou
self.cmd('functionapp deployment source config-zip -g {} -n {} --src "{}" --build-remote'.format(resource_group, functionapp_name, zip_file))


class FunctionappDeploymentSourceScenarioTest(ScenarioTest):
def test_functionapp_deployment_source_update_token(self):
self.cmd('functionapp deployment source update-token --git-token password1234').assert_with_checks([
JMESPathCheck('token', None)
])


# LiveScenarioTest due to issue https://github.com/Azure/azure-cli/issues/10705
class FunctionappDeploymentLogsScenarioTest(LiveScenarioTest):
@ResourceGroupPreparer(location=WINDOWS_ASP_LOCATION_FUNCTIONAPP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_set_source_control_token(self, client_factory_mock):
result = update_git_token(cmd_mock, 'veryNiceToken')

# assert things gets wired up
self.assertEqual(result.token, 'veryNiceToken')
self.assertEqual(result.token, None)

@mock.patch('azure.cli.command_modules.appservice.custom.web_client_factory', autospec=True)
def test_set_domain_name(self, client_factory_mock):
Expand Down