Skip to content

Sync-HashesFromHibp - Misleading FQDN in progress info, missing Proxy param in docs, no feedback on HTTP exceptions #139

Open
@barelyprofessional

Description

@barelyprofessional

Been implementing weekly password hash syncs and have encountered a few issues.

Sync-HashesFromHibp : One or more errors occurred.
At line:1 char:1
+ Sync-HashesFromHibp -Proxy http://antiquatedcorporateproxy:3128 -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Sync-HashesFromHibp], AggregateException
    + FullyQualifiedErrorId : System.AggregateException,Lithnet.ActiveDirectory.PasswordProtection.PowerShell.SyncHashesFromHibp

My suggestion to improve error reporting would be to add code to log the task's exception when its state is faulted.
https://github.com/lithnet/ad-password-protection/blob/master/src/PasswordProtectionPS/SyncHashesFromHibp.cs

I have seen in other issues you've asked people to dump the stacktrace by ToString'ing $Error[0] (here). If this could be documented as a troubleshooting step it'd make things easier.

At the very least if you could add something like this after the while loop, it would make life a lot easier. Admittedly I haven't worked with PowerShell from C# so this is just a guess on my part for how to implement this.

            if (task.IsFaulted)
            {
                WriteVerbose("HIBP downloader task faulted, dumping out inner exceptions");
                if (task.Exception == null)
                {
                    WriteVerbose("HIBP downloader task's Exception was null");
                }
                else
                {
                    foreach (var ex in task.Exception.InnerExceptions)
                    {
                        WriteError(new ErrorRecord(ex, "HibpDownloadTaskFaulted", ErrorCategory.InvalidOperation, null));
                    }
                }
            }

Ideally it there's a way to use something like NLog or log4net and have its logging bubble up to PowerShell from the HibpDownloader class, that'd be the best, but obviously a lot more effort to implement that.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions