Closed Wavelandian closed 5 years ago
@Wavelandian thanks for reporting.
I'll take a look, think I have seen this before on the group level should be easy to fix, will see if I can release a fix by Monday.
Many thanks for taking a look into this issue. Today I'm starting my holidays and will be on leave for the next two weeks, therefore unable to test new updates, if any.
On my return I'll spend more time to deep look into the occurrences and the differences with the correct entry updates, to see if I can identify a pattern.
2018-08-03 16:04 GMT+02:00 John Klann notifications@github.com:
@Wavelandian https://github.com/Wavelandian thanks for reporting.
I'll take a look, think I have seen this before on the group level should be easy to fix, will see if I can release a fix by Monday.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PSKeePass/PoShKeePass/issues/148#issuecomment-410258984, or mute the thread https://github.com/notifications/unsubscribe-auth/ARq-vOevd5sQwZ3Ok42XpUnt_FawtJdnks5uNFhXgaJpZM4VtuiD .
In my case I can see a clear pattern: this exception occurs whenever I update an entry that has been updated before.
I was getting the same error this morning, but I added -Confirm:$false and no longer get the error message.
Hi @jkdba , any update on this?
In my case the problem is related with the history collection.
If I comment this line: https://github.com/PSKeePass/PoShKeePass/blob/master/internal/Set-KPEntry.ps1#L128 it saves without the error message.
Interesting that despite the error it saves the history anyway. (if I select ignore).
@wi-fr - with me is consistent. It happens every time
@kshire - for me the -Confirm:$false
doesn't work, still give the error.
I'm seeing the same assertion. As the scripts are run non-interactively, this prompt isn't seen by the user and the KeePass database which is stored on a network share was left partially written and completely corrupted. So we had to pull the database back from a recent backup. Could the KeePass database saving method be altered to write to a temporary file first, then replace it, in case these kind of assertions occur midway through serialization?
PSES module version: 1.10.0 PSVersion: 5.1.15063.1387 PSEdition: Desktop PSBuildVersion: 10.0.15063.1387 CLRVersion: 4.0.30319.42000 Operating system: Windows 64-bit 10.0.15063
Think I found a fix for this.
I found that if you insert a $OldEntry.History.Clear() right before the $KeePassEntry.History.Add($OldEntry) referenced by @ClaudioESSilva the exception is no longer thrown on an update.
Just opened another issue with the same problem
Is this still being investigated ?
Think I found a fix for this.
I found that if you insert a $OldEntry.History.Clear() right before the $KeePassEntry.History.Add($OldEntry) referenced by @ClaudioESSilva the exception is no longer thrown on an update.
Hi
New to all of this so please bare with me,
If i download the files and make this change, how then do i load the module into powershell to be used, instead of the original?
Seems the project owner hasn't been here is quite some time....the way I did the update: installed PoshKeePass, then found where the module files (%programfiles%\windowspowershell\modules\poshkeepass\2.1.1.8), make a copy just in case then open the PoshKeePass.psm1 file add the line - somewhere around line 2896, after that had no issues with updating entries.
Thanks, kdmhorn, your fix solved my problem
Performing the fix above caused the following exception:
Exception calling "Open" with "3" argument(s): "The file header is corrupted. Data is missing at the end of the file, i.e. the file is incomplete."
I imagine that this is because I have installed the module from the PowerShell Gallery. Can anyone update the module in the absence of the maintainer, or are we out of luck?
@DamionD - The above fix wouldn't have caused that - running the command before the fix does, as when the error message appears, if you click abort it leaves your .kdbx file in a incomplete state
The fix stops this from happening
Hi @kdmhorn @SJHarrison1992 can anyone confirm if the history is maintained in the updated entry with the suggested fix?
I believe it does, but let me check Monday morning when I have access to my test database. What the process is doing is copying the record current state to a new object, it clears the history from that copied object then adds it to the history of the original record before committing the changes made. I'm not great with code (C++ or C#) but had found the fix by tracing what KeePASS source code does with an update.
Just tested and commited fix, released and pushed to psgallery.
This seems to still be occurring, even after updating to 2.1.2.0. This seems to occur when an entry has a history inside it.
I could also be doing something wrong though. Any suggestions?
@xtremedew lets clarify the issue we are seeing. From my testing this is what I found:
After testing with fix this behavior was resolved for me, Can you provide a step by step of how your issue occurs so I can reproduce it.
@jkdba - I am pretty sure I resolved this on my end. I think I was running old code somewhere. I deleted everything and started again from scratch - No issues now. Sorry for causing any panic or confusion. Thanks for the help! Keep up the good work.
@xtremedew no worries, glad to know you found it! Just tested again as sanity and still didn't have the issue. Let me know if anything comes up.
Can confirm history is maintained with the suggested fix
Great to see you are maintaining this great library
@SJHarrison1992 great! Yes not always as frequently as I would like.
In some cases (most of cases, unable to identify a pattern), when trying to update an entry, by using this command:
Update-KeePassEntry -DatabaseProfileName $KPDBProfileName -MasterKey $KeePassDBPassword -KeePassEntry $entry -Title $title -KeePassEntryGroupPath $groupFullPath -force
I get the below exception:
Details of the machine I'm using: