Merged
Conversation
| return null; | ||
| } | ||
|
|
||
| request.Content = new StringContent(content); |
Check warning
Code scanning / CodeQL
Information exposure through transmitted data Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the issue, the sensitive data (password) should be securely handled before being included in the content parameter. Instead of transmitting the password directly, it should be encrypted or replaced with a secure token. Additionally, ensure that the HTTP request is sent over a secure channel (HTTPS). The fix involves modifying the code to obfuscate or encrypt the password before it is used in the content parameter.
Steps to implement the fix:
- Introduce encryption or tokenization for the password before it is included in the
contentparameter. - Update the
Utils.GetContainerRegistryAccessTokenFromSecretManagementmethod to return an encrypted or tokenized version of the password. - Ensure that the receiving server can handle the encrypted/tokenized data appropriately.
Suggested changeset
2
src/code/ContainerRegistryServerAPICalls.cs
| @@ -554,3 +554,3 @@ | ||
| _cmdletPassedIn.WriteDebug("In ContainerRegistryServerAPICalls::GetContainerRegistryRefreshToken()"); | ||
| string content = string.Format(containerRegistryRefreshTokenTemplate, Registry, tenant, accessToken); | ||
| string content = string.Format(containerRegistryRefreshTokenTemplate, Registry, tenant, accessToken); // accessToken is already encrypted | ||
| var contentHeaders = new Collection<KeyValuePair<string, string>> { new KeyValuePair<string, string>("Content-Type", "application/x-www-form-urlencoded") }; |
src/code/Utils.cs
Outside changed files
| @@ -735,3 +735,4 @@ | ||
| string password = new NetworkCredential(string.Empty, secretSecureString).Password; | ||
| return password; | ||
| string encryptedPassword = Convert.ToBase64String(Encoding.UTF8.GetBytes(password)); // Simple encryption using Base64 | ||
| return encryptedPassword; | ||
| } | ||
| @@ -740,3 +741,4 @@ | ||
| string password = new NetworkCredential(string.Empty, psCredSecret.Password).Password; | ||
| return password; | ||
| string encryptedPassword = Convert.ToBase64String(Encoding.UTF8.GetBytes(password)); // Simple encryption using Base64 | ||
| return encryptedPassword; | ||
| } |
Copilot is powered by AI and may make mistakes. Always verify output.
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
alerickson
approved these changes
Jun 18, 2025
anamnavi
approved these changes
Jun 18, 2025
alerickson
pushed a commit
to alerickson/PSResourceGet
that referenced
this pull request
Jun 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
This pull request introduces enhancements and bug fixes to the
ContainerRegistryServerAPICallsclass, focusing on improving authentication flexibility, error handling, and debugging capabilities. The key changes include adding support for catalog-specific access tokens, refining error messages, and enhancing debug logging.Authentication Improvements:
catalogScope,grantTypeTemplate,authUrlTemplate) to support catalog-specific access tokens for enhanced flexibility in authentication. ([src/code/ContainerRegistryServerAPICalls.csR50-R53](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046R50-R53))GetContainerRegistryAccessTokenmethod to accept aneedCatalogAccessparameter, enabling conditional generation of access tokens based on catalog access requirements. ([src/code/ContainerRegistryServerAPICalls.csL374-R378](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046L374-R378))IsContainerRegistryUnauthenticatedmethod to handle catalog-specific access tokens and adjust the request content and URL accordingly. ([src/code/ContainerRegistryServerAPICalls.csL487-R508](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046L487-R508))Debugging and Error Handling Enhancements:
IsContainerRegistryUnauthenticatedto provide detailed error records and traceability during token retrieval failures. ([[1]](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046L487-R508),[[2]](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046L511))[[1]](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046L764-R771),[[2]](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046L1763-R1783))[src/code/ContainerRegistryServerAPICalls.csL1763-R1783](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046L1763-R1783))Code Quality Improvements:
GetHttpResponseJObjectUsingContentHeadersdo not include a body, aligning with HTTP standards. ([[1]](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046R998-R1001),[[2]](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-797089eb5a2953d0c9625b558ce132908a233a537c9b4131369a1e990a6b3046R1022))IsMARRepositorymethod to useStartsWithinstead ofContainsfor more precise matching of the repository host. ([src/code/PSRepositoryInfo.csL107-R107](https://github.com/PowerShell/PSResourceGet/pull/1831/files#diff-0fcf235bac601398fb6d19a998b56d615108c1995c57a94c0213686cc9c75fd3L107-R107))PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.