-
Notifications
You must be signed in to change notification settings - Fork 99
Fix catalog access #1831
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
Fix catalog access #1831
Conversation
return null; | ||
} | ||
|
||
request.Content = new StringContent(content); |
Check warning
Code scanning / CodeQL
Information exposure through transmitted data Medium
sensitive information
This data transmitted to the user depends on
sensitive information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 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
content
parameter. - Update the
Utils.GetContainerRegistryAccessTokenFromSecretManagement
method to return an encrypted or tokenized version of the password. - Ensure that the receiving server can handle the encrypted/tokenized data appropriately.
-
Copy modified line R555
@@ -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") }; |
-
Copy modified lines R736-R737 -
Copy modified lines R742-R743
@@ -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; | ||
} |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
PR Summary
This pull request introduces enhancements and bug fixes to the
ContainerRegistryServerAPICalls
class, 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)
)GetContainerRegistryAccessToken
method to accept aneedCatalogAccess
parameter, 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)
)IsContainerRegistryUnauthenticated
method 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:
IsContainerRegistryUnauthenticated
to 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:
GetHttpResponseJObjectUsingContentHeaders
do 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)
)IsMARRepository
method to useStartsWith
instead ofContains
for 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
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.