Corrected recipient key handling

pull/1/head
Tom Peltonen 2021-08-18 23:36:07 +10:00
parent cb2dc3cbf8
commit 3906144a1c
4 changed files with 28 additions and 4 deletions

Binary file not shown.

View File

@ -33,7 +33,7 @@ $global:default_metaFile = "##peter##.json"
$global:default_errorListFile = Join-Path -Path ".\" -ChildPath "##peter_error_list##.txt" $global:default_errorListFile = Join-Path -Path ".\" -ChildPath "##peter_error_list##.txt"
$global:LogPathName = "" $global:LogPathName = ""
$global:MetadataPathName = Join-Path -Path ".\" -ChildPath ".peter-metadata" $global:MetadataPathName = Join-Path -Path ".\" -ChildPath ".peter-metadata"
$global:Version = "0.31" $global:Version = "0.32"
function Open-Log { function Open-Log {
@ -775,13 +775,13 @@ Param(
{ {
$SecretFile = $ArchiveFile + ".key" $SecretFile = $ArchiveFile + ".key"
} }
$secret = New-RandomPassword -Length 80
Protect-CmsMessage -To $recipientKey -OutFile $SecretFile -Content $secret
if (!(Test-Path -Path $SecretFile)) { if (!(Test-Path -Path $SecretFile)) {
Write-Log "Secret file '$SecretFile' not found" Write-Log "Secret file '$SecretFile' not found"
Close-Log Close-Log
Throw "Secret file '$SecretFile' not found" Throw "Secret file '$SecretFile' not found"
} }
$secret = New-RandomPassword -Length 80
Protect-CmsMessage -To $recipientKey -OutFile $SecretFile -Content $secret
} else { } else {
if (!(Test-PasswordQuality -TestPassword $SecretKey)) { if (!(Test-PasswordQuality -TestPassword $SecretKey)) {
Write-Log "Secret Key does not meet complexity rules" Write-Log "Secret Key does not meet complexity rules"

View File

@ -105,6 +105,26 @@ via local file NuGet package file if Internet access is limited.
See the [Advanced Usage](Docs/Advanced.md) for more advanced options. See the [Advanced Usage](Docs/Advanced.md) for more advanced options.
## Limitations
### Secure string
The current version does not use secure strings for password protection
within the code. You data is stil protected with encryption.
## Path length
There is a limitation with the PowerShell functions used within PeterDocs
of file paths having to be 260 characters in length or less.
If you have long file paths, the processing will fail. A possible
work around is to use mapped net work drive even on your local sourced
file. The command in PowerShell would be something like:
```powershell
New-PSDrive "X" -PSProvider FileSysytem -Root "$Source"
```
## Further Reading ## Further Reading
[Design](Docs/Design.md) [Design](Docs/Design.md)

View File

@ -5,6 +5,10 @@ param (
[String] $Destination [String] $Destination
) )
# Note that there is a path limitation for files of 260 characters
# beyond which PeterDocs will fail
# You could also use drive mapping to overcome this
# New-PSDrive "X" -PSProvider FileSysytem -Root "$Source"
$step ="Starting" $step ="Starting"
Try { Try {
@ -13,7 +17,7 @@ Try {
$step ="Running robocopy" $step ="Running robocopy"
Write-Host "Running robocopy for source '$Source' and destination '$Destination'" Write-Host "Running robocopy for source '$Source' and destination '$Destination'"
# Change the command line switches to suit # Change the command line switches to suit
robocopy `"C:\Users\tom\Small Share\misc_05`" `"$Destination`" /e /copy:DAT /dcopy:DAT /log+:./robocopy.log robocopy `"$Source`" "$Destination" /e /copy:DAT /dcopy:DAT /log+:./robocopy.log /r:1000 /w:10
if ($LastExitCode -lt 8) { if ($LastExitCode -lt 8) {
Write-Host "Robocopy succeeded" Write-Host "Robocopy succeeded"
} else { } else {