Skip to content
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 @@ -12,7 +12,7 @@ class TestCredentialHelper(unittest.TestCase):
def _get_test_secret_masker(self):
from microsoft_security_utilities_secret_masker import SecretMasker, load_regex_pattern_from_json
email_address_json = {
"Pattern": r"(?<refine>[\w.%#+-]+)(%40|@)([a-z0-9.-]*.[a-z]{2,})",
"Pattern": r"(?P<refine>[\w.%#+-]+)(%40|@)([a-z0-9.-]*.[a-z]{2,})",
Copy link
Member

Choose a reason for hiding this comment

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

#31367 contains the detailed error.

2025-04-27T09:22:37.8357554Z                             if char not in "=!":
2025-04-27T09:22:37.8357740Z >                               raise source.error("unknown extension ?<" + char,
2025-04-27T09:22:37.8357916Z                                                    len(char) + 2)
2025-04-27T09:22:37.8358098Z E                               re.error: unknown extension ?<r at position 1
2025-04-27T09:22:37.8358190Z 
2025-04-27T09:22:37.8358388Z /opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/re/_parser.py:769: error

I am curious if ?<r is an invalid regex, how is it not detected by the old microsoft-security-utilities-secret-masker library?

Is it because (?<refine>[\w.%#+-]+)(%40|@)([a-z0-9.-]*.[a-z]{2,}) is actually never used?

Copy link
Member Author

Choose a reason for hiding this comment

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

old microsoft-security-utilities-secret-masker has a func replacing all ?P<refine> with ?<refine> because it was wrong in rule json file that 1ES shared. The new version removed this func as 1ES has fixed the rule patterns

Copy link
Member Author

@evelyn-ys evelyn-ys May 6, 2025

Choose a reason for hiding this comment

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

old microsoft-security-utilities-secret-masker has a func replacing all ?<refine> with ?P<refine> because it was wrong in rule json file that 1ES shared. The new version removed this func as 1ES has fixed the rule patterns

"Id": "001",
"Name": "EmailAddress",
"Signatures": [
Expand All @@ -22,7 +22,7 @@ def _get_test_secret_masker(self):
"DetectionMetadata": "HighConfidence"
}
guid_json = {
"Pattern": r"(?<refine>[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12})",
"Pattern": r"(?P<refine>[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12})",
"Id": "002",
"Name": "GUID",
"DetectionMetadata": "LowConfidence"
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'humanfriendly~=10.0',
'jmespath',
'knack~=0.11.0',
'microsoft-security-utilities-secret-masker~=1.0.0b2',
'microsoft-security-utilities-secret-masker~=1.0.0b4',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it is not in requirements.txt?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's azure-cli-core's dependency, not azure-cli

Copy link
Contributor

Choose a reason for hiding this comment

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

I see.
This change has no effect since ~= will select the 1.0.0b4 by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, this PR fixes tests after sdk upgrade as well

Copy link
Member

Choose a reason for hiding this comment

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

It's azure-cli-core's dependency, not azure-cli

This is not accurate. requirements.txt contains requirements of both Azure CLI and Core. requirements.txt is used to have stable dependencies in MSI, ZIP, DEB, RPM packages.

If microsoft-security-utilities-secret-masker is required by Azure CLI Core, it should be included in requirements.txt too. msal is an example:

'msal[broker]==1.32.3',

Copy link
Contributor

@bebound bebound May 6, 2025

Choose a reason for hiding this comment

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

I upvote adding more azure-cli-core dependencies in requirements.txt.

I have to manually add microsoft-security-utilities-secret-masker and py-deviceid to requirements.txt in: https://github.com/Azure/azure-cli-pr/pull/143#discussion_r2030667413

'msal-extensions==1.2.0',
'msal[broker]==1.31.2b1',
'msrestazure~=0.6.4',
Expand Down