Skip to content

When timestamp is untrusted, display the primary signature details and modified output for various verbosity levels in nuget verify command#3992

Merged
kartheekp-ms merged 18 commits intodevfrom
dev-kartheekp-ms-dotnetverify-verbosity
Apr 20, 2021
Merged

When timestamp is untrusted, display the primary signature details and modified output for various verbosity levels in nuget verify command#3992
kartheekp-ms merged 18 commits intodevfrom
dev-kartheekp-ms-dotnetverify-verbosity

Conversation

@kartheekp-ms
Copy link
Copy Markdown
Contributor

@kartheekp-ms kartheekp-ms commented Apr 12, 2021

Bug

Fixes: NuGet/Home#10316
Fixes: NuGet/Home#10535

Regression? Last working version:

Description

Modified output displayed for various verbosity levels of dotnet nuget verify and nuget.exe verify command as per spec. Improved log messages & error codes in docs to improve the customer experience based upon the learnings from the recent Debian incident.

When timestamp is untrusted, display the primary signature details to fix NuGet/Home#10535

Once this PR is merged, dotnet nuget verify and nuget.exe verify command displays output in the following order.

  • primary signature details
  • timestamp signature details
  • warnings or errors

PR Checklist

@kartheekp-ms kartheekp-ms marked this pull request as ready for review April 12, 2021 04:42
@kartheekp-ms kartheekp-ms requested a review from a team as a code owner April 12, 2021 04:42

#if IS_SIGNING_SUPPORTED
using (var zip = new ZipArchive(ZipReadStream, ZipArchiveMode.Read, leaveOpen: true))
if (!_isSigned.HasValue)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When debugging dotnet nuget verify command, I noticed that IsSignedAsync method is invoked multiple times in the same code path. Hence added a nullable bool _isSigned to avoid executing the logic multiple times (a minor perf. improvement).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider positive checks where possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am leaning towards keeping the current implementation as is. If you prefer a positive check, I can change the code as shown below. Please let me know your feedback.

            if (_isSigned.HasValue)
                return Task.FromResult(_isSigned.Value);

            _isSigned = false;

            using (var zip = new ZipArchive(ZipReadStream, ZipArchiveMode.Read, leaveOpen: true))
            {
                var signatureEntry = zip.GetEntry(SigningSpecifications.SignaturePath);

                if (signatureEntry != null &&
                   string.Equals(signatureEntry.Name, SigningSpecifications.SignaturePath, StringComparison.Ordinal))
                {
                    _isSigned = true;
                }
            }

            return Task.FromResult(_isSigned.Value);

@kartheekp-ms kartheekp-ms force-pushed the dev-kartheekp-ms-dotnetverify-verbosity branch 2 times, most recently from 3e228c6 to 594e688 Compare April 14, 2021 01:08
Copy link
Copy Markdown
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏


#if IS_SIGNING_SUPPORTED
using (var zip = new ZipArchive(ZipReadStream, ZipArchiveMode.Read, leaveOpen: true))
if (!_isSigned.HasValue)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider positive checks where possible.

Copy link
Copy Markdown
Contributor

@heng-liu heng-liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @kartheekp-ms !
Just have one question in the below comment.

@kartheekp-ms kartheekp-ms force-pushed the dev-kartheekp-ms-dotnetverify-verbosity branch from 594e688 to e49ae89 Compare April 16, 2021 16:58
Copy link
Copy Markdown
Contributor

@erdembayar erdembayar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just 2 comments.

Copy link
Copy Markdown
Contributor

@erdembayar erdembayar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job.

@kartheekp-ms kartheekp-ms merged commit eb8bebe into dev Apr 20, 2021
@kartheekp-ms kartheekp-ms deleted the dev-kartheekp-ms-dotnetverify-verbosity branch April 20, 2021 02:24
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.

Signing: primary signature details not displayed when certificate expired and timestamp untrusted dotnet nuget verify is too quiet

4 participants