vcsjones / AuthenticodeExaminer

MIT License
43 stars 16 forks source link

API improvements. #4

Closed vcsjones closed 5 years ago

vcsjones commented 5 years ago

@onovotny

Take a look at the new program sample. What do you think of this as a start?

This addresses:

var extractor = new FileInspector(path);

//Returns an enum of the validation result
var validationResult = extractor.Validate(); 

// Gets all of the signatures "flattened", no recursion necessary. 
var signatures = extractor.GetSignatures();

foreach(var signature in signatures)
{
    //Property to get the publisher info, or null
    //Signtool always puts in a publisherinfo, the fields are just empty strings.
    var publisherInfo = signature.PublisherInformation;

    //Property to get the timestamp signature
    var timestamps = signature.TimestampSignatures;

     // Gets the DateTimeOffset of the timestamp
    var timestampedAt = timestamp.TimestampDateTime;
}

Fixes #2

clairernovotny commented 5 years ago

That's better, but what do you think of something closer to https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/blob/view-authenticode-sigs/PackageViewModel/Types/AuthenticodeSignature.cs

It has a signature object that directly exposes the publisher info, timestamp info, etc?

Null is valid if there isn't one.

vcsjones commented 5 years ago

The thought was that since all of signature types are the same interface, and in the case of RF3161 timestamps they're actually the same class as a normal signature, It doesn't make sense for timestamps to have publisher info on them. That was the thinking at least.

I can encapsulate the known signatures to be more "concrete" as to what they are and expose things on the types rather than extensions.

A small issue with my current design I intend to correct is that a signature can have multiple time stamps (which I've seen in the wild.. rarely) so Timestamps should be a collection.

clairernovotny commented 5 years ago

Yeah, was thinking about keeping it as simple for people that might not know what kinds of things are in a sig. That an object would represent all of that.

vcsjones commented 5 years ago

@onovotny updated

clairernovotny commented 5 years ago

Looks better, but still not clear to me why Publisher and Timestamp should be methods? Seems like they could be calculated quickly either on-demand on first access or in the ctor? That also makes it possible to bind in WPF.

vcsjones commented 5 years ago

That also makes it possible to bind in WPF.

Ah. Wasn't aware you were going to use these as models.

clairernovotny commented 5 years ago

No reason to write a wrapper model if it's not necessary :)

vcsjones commented 5 years ago

okie doke, properties it is.

clairernovotny commented 5 years ago

:shipit:

vcsjones commented 5 years ago

@onovotny give https://www.nuget.org/packages/AuthenticodeExaminer/0.2.0 a shot when you got a moment.