-
-
Notifications
You must be signed in to change notification settings - Fork 63
Add opt-in configuration for MA0153 to detect logging of types containing DataClassification members #936
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
Conversation
Co-authored-by: meziantou <[email protected]>
Co-authored-by: meziantou <[email protected]>
|
@copilot Can you add an option to enable reporting object containing properties decorated with DataClassificationAttribute. Follow the format used in other rule: |
…tion detection Co-authored-by: meziantou <[email protected]>
Done in commit 32c4185. Added configuration option |
|
@copilot Can you change the default value to false? |
…tes to false Co-authored-by: meziantou <[email protected]>
| var operation = (IInvocationOperation)context.Operation; | ||
| if (operation.TargetMethod.ContainingType.IsEqualTo(LoggerExtensionsSymbol) && FindLogParameters(operation.TargetMethod, out var argumentsParameter)) | ||
| { | ||
| var options = context.Options.AnalyzerConfigOptionsProvider.GetOptions(operation.Syntax.SyntaxTree); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot You can simplify it by using the extension method GetConfigurationValue, which also supports a boolean default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit cb5885f. Simplified by using the GetConfigurationValue extension method.
…reading Co-authored-by: meziantou <[email protected]>
|
@copilot Can you replace GetMembers with GetAllMembers (extension method in the project) |
…tribute Co-authored-by: meziantou <[email protected]>
Add opt-in configuration for MA0153 to detect logging of types with DataClassification members
Summary of Changes
Analyzer Enhancement:
TypeContainsMembersWithDataClassificationhelper method to check if a type contains properties or fields withDataClassificationAttributeValidateDataClassificationto check parameter types and general operation types for classified membersMA0153.report_types_with_data_classification_attributesto enable/disable type-level detection (default: false)GetConfigurationValueextension methodGetAllMembersto check inherited members for DataClassificationAttributeTest Coverage:
Documentation:
Configuration Option
The new analyzer behavior can be configured via
.editorconfig:When set to
false(default), the analyzer will only detect direct member access (original behavior). When set totrue, it will also detect logging of objects containing classified members, including inherited members.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.