Retrieve more info with Get-AuthenticodeSignature#17568
Retrieve more info with Get-AuthenticodeSignature#17568jborean93 wants to merge 1 commit intoPowerShell:masterfrom jborean93:authenticode-extra
Conversation
Adds the Signatures property to the Signature output object of Get-AuthenticodeSignature and Set-AuthenticodeSignature. This new object is an array of signature detail objects that contains the signing and digest algorithm as well as the timestamp information of the signature. It does this for all the entries in the authenticode block and not just the first entry
|
Reopen PR to re-trigger the CI runs. |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
I'd prefer to have dotnet/runtime#34042 :-) |
|
An issue from nearly 3 years ago with no progress + a somewhat vague request. Is that asking for cross platform support, more implementations in dotnet or something else? If this isn't wanted in PowerShell it would be great if I could put it in https://www.nuget.org/packages/Microsoft.Security.Extensions but it doesn't appear to be open source or available for contributors. Ultimately I'm hoping to add more information for
|
|
@jborean93 A lot of code exists in PowerShell only because these features are missing from the .Net Runtime and Libraries. We have already removed a lot of code as .Net went from version 1 to 7. This is the preferred path. There is not much point in repackaging the code - only the risk of regression. It is more valuable to spend this effort to extend .Net. |
|
The bulk of the code is very PowerShell specific. It's adding extra info the the return object of If the changes here aren't wanted in PowerShell that's fair enough, I won't add any more efforts in moving it to a ready state. |
|
|
||
| /// <summary> | ||
| /// Gets the list of signatures and their details using the Crypt APIs. | ||
| /// is used to get all the signatures in a file/content rather than |
There was a problem hiding this comment.
| /// is used to get all the signatures in a file/content rather than | |
| /// It is used to get all the signatures in a file/content rather than |
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the list of signatures and their details using the Crypt APIs. |
There was a problem hiding this comment.
| /// Gets the list of signatures and their details using the Crypt APIs. | |
| /// Gets the list of signatures and their details using the Crypto APIs. |
| /// is used to get all the signatures in a file/content rather than | ||
| /// just the overall trust information. | ||
| /// </summary> | ||
| private static SignatureDetail[] GetSignaturesFromCrypto(string fileName, |
There was a problem hiding this comment.
| private static SignatureDetail[] GetSignaturesFromCrypto(string fileName, | |
| private static SignatureDetail[] GetSignaturesFromCrypto( | |
| string fileName, |
| public unsafe byte* pbData; | ||
| } | ||
|
|
||
| [DllImport("Crypt32.dll", EntryPoint = "CryptQueryObject", SetLastError = true)] |
There was a problem hiding this comment.
MS documentation says CryptQueryObject is deprecated. Should we be using the current API? If not please add a comment as to why we are using this API and that it is deprecated by MS.
| int dataLength = 0; | ||
| unsafe | ||
| { | ||
| NativeCryptMsgGetParam(msg, paramType, idx, null, ref dataLength); |
There was a problem hiding this comment.
Can this fail? It seems like we should throw here on fail.
| byte[] sigData; | ||
| if (fileContent == null) | ||
| { | ||
| // FIXME: Handle a missing file |
There was a problem hiding this comment.
Not sure what this comment means. I assume API will throw if file is non-existent. Please remove the comment if it no longer applies, or fix the issue.
| } | ||
|
|
||
| SignedCms cmsInfo = new(); | ||
| cmsInfo.Decode(sigData); |
There was a problem hiding this comment.
I think we should capture any errors here if the decode fails for any reason, and just return null or empty array for the new Signatures property. We may want to write a warning that the extra signature information could not be obtained.
| if (attr.Oid.Value == counterSignOid) | ||
| { | ||
| SignedCms counterSigner = new(); | ||
| counterSigner.Decode(attr.Values[0].RawData); |
There was a problem hiding this comment.
We should handle any decoding errors.
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
PR Summary
Adds the Signatures property to the Signature output object of
Get-AuthenticodeSignature and Set-AuthenticodeSignature. This new object
is an array of signature detail objects that contains the signing and
digest algorithm as well as the timestamp information of the signature.
It does this for all the entries in the authenticode block and not just
the first entry
PR Context
I was trying to get this information to test out the changes in #17560 and found the
Get-AuthenticodeSignaturewas lacking some of the data needed. This hopefully expands the functionality of the cmdlet and expose more data that might be useful for others.Still need to finalise the tests and fix up a few things before I can mark this as ready.
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.(which runs in a different PS Host).