Skip to content

Task/rdmp 291 anon security profiles#460

Draft
JFriel wants to merge 3 commits intodevelopfrom
task/RDMP-291-anon-security-profiles
Draft

Task/rdmp 291 anon security profiles#460
JFriel wants to merge 3 commits intodevelopfrom
task/RDMP-291-anon-security-profiles

Conversation

@JFriel
Copy link
Copy Markdown
Contributor

@JFriel JFriel commented May 9, 2025

No description provided.

SecurityProfileOptions.RetainUIDs;
if (CustomSecurityProfile != null)
{
profile = SecurityProfile.LoadProfile(new StringReader(CustomSecurityProfile), flags);

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning

Disposable 'StringReader' is created but not disposed.

Copilot Autofix

AI 12 months ago

To fix the issue, the StringReader instance should be properly disposed of. The best approach is to wrap its creation and usage in a using block. This ensures that the Dispose method is called automatically, even if an exception occurs. The using block should encompass the call to SecurityProfile.LoadProfile to ensure the StringReader is disposed of immediately after its use.


Suggested changeset 1
Rdmp.Dicom/Extraction/FoDicomBased/FoDicomAnonymiser.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Rdmp.Dicom/Extraction/FoDicomBased/FoDicomAnonymiser.cs b/Rdmp.Dicom/Extraction/FoDicomBased/FoDicomAnonymiser.cs
--- a/Rdmp.Dicom/Extraction/FoDicomBased/FoDicomAnonymiser.cs
+++ b/Rdmp.Dicom/Extraction/FoDicomBased/FoDicomAnonymiser.cs
@@ -300,3 +300,6 @@
             {
-                profile = SecurityProfile.LoadProfile(new StringReader(CustomSecurityProfile), flags);
+                using (var stringReader = new StringReader(CustomSecurityProfile))
+                {
+                    profile = SecurityProfile.LoadProfile(stringReader, flags);
+                }
             }
EOF
@@ -300,3 +300,6 @@
{
profile = SecurityProfile.LoadProfile(new StringReader(CustomSecurityProfile), flags);
using (var stringReader = new StringReader(CustomSecurityProfile))
{
profile = SecurityProfile.LoadProfile(stringReader, flags);
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants