Skip to content

Commit b09567f

Browse files
authored
[CredScan] Remove general string suppressions (Azure#28151)
1 parent a7c8aa5 commit b09567f

File tree

9 files changed

+29
-45
lines changed

9 files changed

+29
-45
lines changed

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"eng/common/docgeneration/Generate-DocIndex.ps1",
9393
"eng/**/*.py",
9494
".gitignore",
95+
"tools/azure-sdk-tools/devtools_testutils/fake_credentials.py",
9596
"tools/azure-sdk-tools/packaging_tools/**",
9697
"tools/azure-sdk-tools/setup.py"
9798
],

doc/dev/mgmt/generating-integration-test.md

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,35 +95,12 @@ You can rearrange sequence or disable particular tests.
9595

9696
## Running Test
9797

98-
First of all set the variable, to enable live tests:
99-
100-
export AZURE_TEST_RUN_LIVE=true
101-
102-
Live test requires credentials, in order to do that create **mgmt_settings_real.py** file:
103-
104-
cd /_/azure-sdk-for-python
105-
cp tools/azure-sdk-tools/devtools_testutils/mgmt_settings_fake.py tools/azure-sdk-tools/devtools_testutils/mgmt_settings_real.py
106-
vi tools/azure-sdk-tools/devtools_testutils/mgmt_settings_real.py
107-
108-
and make sure your subscription ID is correct:
109-
110-
SUBSCRIPTION_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
111-
112-
and **get_credentials** looks as follows:
113-
114-
def get_credentials(**kwargs):
115-
from azure.common.credentials import ServicePrincipalCredentials
116-
return ServicePrincipalCredentials(
117-
client_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
118-
secret = 'XxxxXxxxXXXxxxXXXXxxxxXXxxxXxxx',
119-
tenant = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx'
120-
)
121-
122-
now you can run live integration test:
123-
124-
pytest -s sdk/attestation/azure-mgmt-attestation
125-
126-
>NOTE: To create service principal, follow instructions here: https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
98+
To run tests, refer to the documentation at
99+
[/doc/dev/mgmt/tests.md](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/mgmt/tests.md). Most test
100+
suites in the Azure SDK have been migrated to use the Azure SDK test proxy, but some libraries that have inactive tests
101+
may still be using an older, deprecated system. The
102+
[test proxy migration guide](https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md)
103+
describes the differences between the systems and their requirements.
127104

128105
## Fixing Test
129106

eng/CredScanSuppression.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
"suppressions": [
44
{
55
"placeholder": [
6-
"XxxxXxxxXXXxxxXXXXxxxxXXxxxXxxx",
7-
"HusH_Sec4et",
8-
"myPassw0rd",
9-
"myPassw0rd3",
10-
"SWsSsd__233$Sdsds#%Sd!",
11-
"kt#_gahr!@aGERDXA",
126
"Aa1!zyx_",
137
"Aa!1()-xyz",
148
":code:`<pfx-file-password>`",

sdk/appservice/azure-mgmt-web/tests/disable_test_cli_mgmt_certificate.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import azure.mgmt.web
1616
from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer
17+
from devtools_testutils.fake_credentials import FAKE_LOGIN_PASSWORD
1718

1819
AZURE_LOCATION = 'eastus'
1920

@@ -40,7 +41,7 @@ def test_certificate(self, resource_group):
4041
"host_names": [
4142
"ServerCert"
4243
],
43-
"password": "SWsSsd__233$Sdsds#%Sd!"
44+
"password": FAKE_LOGIN_PASSWORD # this may not work -- check when tests are active
4445
}
4546
result = self.mgmt_client.certificates.create_or_update(resource_group_name=RESOURCE_GROUP, name=NAME, certificate_envelope=BODY)
4647

@@ -68,7 +69,7 @@ def test_certificate(self, resource_group):
6869
# /Certificates/patch/Patch Certificate[patch]
6970
#--------------------------------------------------------------------------
7071
BODY = {
71-
"password": "SWsSsd__233$Sdsds#%Sd!"
72+
"password": FAKE_LOGIN_PASSWORD # this may not work -- check when tests are active
7273
}
7374
result = self.mgmt_client.certificates.update(resource_group_name=RESOURCE_GROUP, name=NAME, certificate_envelope=BODY)
7475

sdk/appservice/azure-mgmt-web/tests/disable_test_cli_mgmt_web.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import azure.mgmt.web
4040
from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer
41+
from devtools_testutils.fake_credentials import FAKE_LOGIN_PASSWORD
4142

4243
AZURE_LOCATION = 'eastus'
4344

@@ -120,7 +121,7 @@ def test_web(self, resource_group):
120121
"host_names": [
121122
"ServerCert"
122123
],
123-
"password": "SWsSsd__233$Sdsds#%Sd!"
124+
"password": FAKE_LOGIN_PASSWORD # this may not work -- check when tests are active
124125
}
125126
result = self.mgmt_client.certificates.create_or_update(resource_group_name=RESOURCE_GROUP, name=NAME, certificate_envelope=BODY)
126127

@@ -764,7 +765,7 @@ def test_web(self, resource_group):
764765
# /Certificates/patch/Patch Certificate[patch]
765766
#--------------------------------------------------------------------------
766767
BODY = {
767-
"password": "SWsSsd__233$Sdsds#%Sd!"
768+
"password": FAKE_LOGIN_PASSWORD # this may not work -- check when tests are active
768769
}
769770
result = self.mgmt_client.certificates.update(resource_group_name=RESOURCE_GROUP, name=NAME, certificate_envelope=BODY)
770771

sdk/batch/azure-batch/tests/batch_preparers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from azure_devtools.scenario_tests.exceptions import AzureTestError
1717

1818
from devtools_testutils import AzureMgmtPreparer, ResourceGroupPreparer, FakeResource
19+
from devtools_testutils.fake_credentials import BATCH_TEST_PASSWORD
1920
from devtools_testutils.resource_testcase import RESOURCE_GROUP_PARAM
2021

2122
AZURE_ARM_ENDPOINT = 'https://management.azure.com'
@@ -182,7 +183,7 @@ def create_resource(self, name, **kwargs):
182183
base_url=AZURE_ARM_ENDPOINT)
183184
group = self._get_resource_group(**kwargs)
184185
batch_account = self._get_batch_account(**kwargs)
185-
user = models.UserAccount(name='task-user', password='kt#_gahr!@aGERDXA', elevation_level=models.ElevationLevel.admin)
186+
user = models.UserAccount(name='task-user', password=BATCH_TEST_PASSWORD, elevation_level=models.ElevationLevel.admin)
186187
vm_size = 'standard_d2_v2'
187188

188189
if self.config == 'paas':

sdk/batch/azure-batch/tests/test_batch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
CachedResourceGroupPreparer,
2929
CachedStorageAccountPreparer
3030
)
31+
from devtools_testutils.fake_credentials import BATCH_TEST_PASSWORD
3132

3233

3334
AZURE_LOCATION = 'eastus'
@@ -165,8 +166,8 @@ def test_batch_create_pools(self, **kwargs):
165166

166167
# Test Create Iaas Pool
167168
users = [
168-
models.UserAccount(name='test-user-1', password='kt#_gahr!@aGERDXA'),
169-
models.UserAccount(name='test-user-2', password='kt#_gahr!@aGERDXA', elevation_level=models.ElevationLevel.admin)
169+
models.UserAccount(name='test-user-1', password=BATCH_TEST_PASSWORD),
170+
models.UserAccount(name='test-user-2', password=BATCH_TEST_PASSWORD, elevation_level=models.ElevationLevel.admin)
170171
]
171172
test_iaas_pool = models.PoolAddParameter(
172173
id=self.get_resource_name('batch_iaas_'),
@@ -670,7 +671,7 @@ def test_batch_compute_node_user(self, batch_pool, **kwargs):
670671
# Test Add User
671672
user_name = 'BatchPythonSDKUser'
672673
nodes = list(client.compute_node.list(batch_pool.name))
673-
user = models.ComputeNodeUser(name=user_name, password='kt#_gahr!@aGERDXA', is_admin=False)
674+
user = models.ComputeNodeUser(name=user_name, password=BATCH_TEST_PASSWORD, is_admin=False)
674675
response = client.compute_node.add_user(batch_pool.name, nodes[0].id, user)
675676
self.assertIsNone(response)
676677

sdk/sql/azure-mgmt-sql/tests/disable_test_mgmt_sql.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
AzureMgmtTestCase, ResourceGroupPreparer,
1414
AzureMgmtPreparer, FakeResource
1515
)
16+
from devtools_testutils.fake_credentials import FAKE_LOGIN_PASSWORD
1617

1718

1819
def get_server_params(location):
1920
return {
2021
'location': 'westus2', #location, # "self.region" is 'west-us' by default
2122
'version': '12.0',
2223
'administrator_login': 'mysecretname',
23-
'administrator_login_password': 'HusH_Sec4et'
24+
'administrator_login_password': FAKE_LOGIN_PASSWORD # this password may not work -- check when tests are active
2425
}
2526

2627

tools/azure-sdk-tools/devtools_testutils/fake_credentials.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
from azure.core.credentials import AccessToken
22

3-
STORAGE_ACCOUNT_FAKE_KEY = "NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg=="
3+
4+
# General-use fake credentials
5+
FAKE_LOGIN_PASSWORD = "F4ke_L0gin_P4ss"
6+
7+
# Service-specific fake credentials
8+
BATCH_TEST_PASSWORD = "kt#_gahr!@aGERDXA"
49
MGMT_HDINSIGHT_FAKE_KEY = "qFmud5LfxcCxWUvWcGMhKDp0v0KuBRLsO/AIddX734W7lzdInsVMsB5ILVoOrF+0fCfk/IYYy5SJ9Q+2v4aihQ=="
10+
STORAGE_ACCOUNT_FAKE_KEY = "NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg=="
511

612

713
class FakeTokenCredential(object):
814
"""Protocol for classes able to provide OAuth tokens.
15+
916
:param str scopes: Lets you specify the type of access needed.
1017
"""
1118

0 commit comments

Comments
 (0)