Menu

#1505 Export/Import parts of a database shifts entries to root group

KeePass_2.x
closed
nobody
None
5
2016-04-21
2016-04-11
Mike Valk
No

Export/Import parts of a database shifts entries to root. Using 2.32

Test import:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<KeePassFile>
  <Root>
    <Group>
      <Name>Group1</Name>
        <Entry>
          <String>
            <Key>Title</Key>
            <Value>testentry</Value>
          </String>
        </Entry>
    </Group>
  </Root>
</KeePassFile>

I think it is because the whole export includes a top group with the name of the DB:

Example:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<KeePassFile>
  <Root>
    <Group>
      <Name>DB Name</Name>
      <Group>
        <Name>Group1</Name>
          <Entry>
            <String>
              <Key>Title</Key>
              <Value>testentry</Value>
             </String>
          </Entry>
        </Group>
    </Group>
  </Root>
</KeePassFile>

Importting the above in existing DB honors the groups and its andtries but will create a group with the DB name. But wil not nest the groups.

I found this while generating custom XML's to facilitate custom string field in imports, which I use in Custom URL's: Hostname; Port; Langauge; Client; etc..

Work around when generating XML's is to create a bogus group "Remove after import" and nest groups there.

The "Generic CSV Import" converts all non default fields to <ignore>. And is a hassle to manually overide to custom fields. Perhaps the generect CSV could issue a column with ignored fields whitch can be toggled.</ignore>

Kr, Mike

Discussion

  • Paul

    Paul - 2016-04-11

    Using your test XML I get a group named "Group1" with no entries and a root entry called "testentry". Not what I would have expected.

    cheers, Paul

     
  • wellread1

    wellread1 - 2016-04-11

    I believe what you are describing is the intended KeePass import behavior. The top level group in an XML file is always treated as the top level database group during import. See the developer's comments in Bug #1394.

    In your first xml example you have defined "Group1" as the top level group. When you import the xml data "Group1" collides with the actual top level group of the database. KeePass dumps the entries contained in the xml defined top level group "Group1" into the database top level group and creates a "Group1" so that the Group name is not lost.

    In your second xml example, you have defined "DB Name" as the top level group. "DB Name" collides with the actual database top level group and is preserved as an empty 2nd level group. However, now when KeePass encounters the 2nd level group "Group1" in the xml import file, it knows to create a new 2nd level group in the database called "Group1" and it can import the entries contained into their respective groups.

    You can avoid creating an empty dummy group (e.g. "Remove after import" ) by adding the UUID element to the top level group in your xml file and assign it the value of the UUID of the top level group of the database you are importing it into. Select "Keep exisiting" in the Import Behavior. On import the top level group will be merged because its UUID matches the database top level group UUID, and new UUIDs will be assigned to the other groups listed in the xml because the these groups don't have assigned UUIDs.

    If the UUID of the top level group of the database you are importing into is "97cKxTar1kqBG8V2+vViIA==" the following xml should import with the desired hierarchy leaving no dummy group entries.

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <KeePassFile>
      <Root>
        <Group>
          <UUID>97cKxTar1kqBG8V2+vViIA==</UUID>
          <Name>NewDatabase</Name>
          <Group>
            <Name>Group1</Name>
              <Entry>
                <String>
                  <Key>Title</Key>
                  <Value>testentry</Value>
                 </String>
              </Entry>
            </Group>
        </Group>
      </Root>
    </KeePassFile>
    

    IMPORTANT: The easiest way I know of to find the UUID of the top level group of the database that you are importing into is to export the group as an xml file.

     

    Last edit: wellread1 2016-04-11
  • Dominik Reichl

    Dominik Reichl - 2016-04-21
    • status: open --> closed
     
  • Dominik Reichl

    Dominik Reichl - 2016-04-21

    It's the intended behavior, like Wellread1 described.

    Best regards,
    Dominik

     

Log in to post a comment.

Auth0 Logo