16

I have a local svn repository in my PC, I have been using it for a hobby project and it wasn't meant to be accessible to anyone, so I commited files with passwords in them.

Now, I'm thinking of making the repository available for other people and I don't want to have that data there.

Is there a way to crawl the repository and replace all the passwords and account data with a text like "xxxxxxxxxx"?

Community
  • 1
  • 1

5 Answers5

13

Check the Subversion FAQ: How do I completely remove a file from the repository's history?

Rômulo Ceccon
  • 10,081
  • 5
  • 39
  • 47
  • 1
    Would you please add the command to execute. I haven't understood what they say in the help. What's it mean `to svnadmin dump your repository, then pipe the dumpfile through svndumpfilter (excluding the bad path) into an svnadmin load command`. No details in the link gave either. – Hunsu Jun 03 '14 at 13:34
10

If you do an

svnadmin dump > mysvn

you'll get a flat file of all the data of all the revisions in your repository. From there, you should be able to manually edit the file (if your repo was significant in size at all, you may need a line-editor, like pico, nano, vi, etc.).

Lastly, you would then reload this dump into a new repository. This will preserve your history of your project.

svnadmin load /path/to/new/repo < mysvn

This practice would be considered a no-no in any corporate environment where you undergo auditing, etc, but for a hobby project it may just do the trick for you.

EDIT: I've had to do this before trying to merge two different repositories together, so it required adding a new "directory node" the flat file. I'm not sure if SVN hashes the files or changes to determine if it's been tampered with.

Matt
  • 41,216
  • 30
  • 109
  • 147
  • 1
    It does in fact check the checksums as it reloads the data. Just attempted this approach for a similar problem. :) – Iain Aug 04 '10 at 20:34
  • This will work, but you will need to update the md5sum for any files (node-paths) that are edited. In vim you can use ctrl-v to highlight the section representing the file, then type ":!md5sum" to get the new hash. The file starts after the PROPS-END line, and ends with two blank lines followed by the next "Node-Path:" line. – Mark Grimes Jan 10 '12 at 14:37
8

It seems that there was a misunderstanding. I didn't want to delete a file. I want to delete passwords stored in the repository. I don't want to lose the files, neither the revisions, modifications and the history.

What I did is what Matt suggested, dump the repository and edit it.

To do this, I used a hexadecimal editor (khexedit) and replaced the password string with a string of the same lenght. That way, I don't have to update the size fields.

Next, I need to update the md5 fields with the hash of the file contents. For this, I wrote a script that used "svnadmin load" output to generate a error and get the old and new md5 from that error. Next, replace the old hash with sed and then, repeat until there aren't errors.

naw
  • 1,496
  • 12
  • 13
  • `svnadmin dump repo > svn.dump`, then find the versions of the file you need to edit. Export those files (`svn export file@r1234 file.1234`). Copy the exported files to file.1234.modified. Overwrite the password with `x`'s so they're the same size. Get new md5sums and sha1 sums (`md5sum file.*; sha1sum file.*`). Open svn.dump in vim and search for the pre-modification md5sum. Overwrite the password the exact same was as in your modified file, and update the md5sum and sha1sum. then `mv repo repo.bak && svnadmin load repo < svn.dump`. – dannysauer Mar 24 '15 at 21:24
5

I had same issue but than on code.google.com: I checked in some files which should not be accessible via the history on googlecode but I did not want to ditch all history, after some googling, trying, retrying and retrying i succeeded. Below the recipe which worked for my little project (6.5 MB, 90 revisions). Most knowledge came from googlecode, the rest mostly from the svn redbook

First create a local repo where you'll download googlecode's repo to:

svnadmin create /tmp/your_local_repo

create file /tmp/isd_gc/hooks/pre-revprop-change with contents

#!/bin/bash
exit 0

make it eXecutable:

chmod +x /tmp/isd_gc/hooks/pre-revprop-change

if you fail on this section you most likely will see an error: Revprop change blocked by pre-revprop-change hook (exit code 255) with no output.

now you can init the svn sync from code.google.com

svnsync init --username yourname@youremail file:///tmp/your_local_repo https://yourproject.googlecode.com/svn 

and start downloading all history:

svnsync sync --username  yourname@youremail file:///tmp/your_local_repo

Committed revision 1.

Copied properties for revision 1.

Transmitting file data .......................

Copied properties for revision 87.

Now we create a dumpfile which will be fed to svndumpfilter to remove unwanted files.

svnadmin dump . > /tmp/tst_dump_gc.dmp

use svndumpfilter to remove first unwanted file from it.

svndumpfilter exclude /trunk/unwanted file_1.jsvg < /tmp/tst_dump_gc.dmp > /tmp/tst_dump_clean1.dmp

Dropped 1 node:

'/trunk/unwanted file_new.jsvg'

remove second unwanted file:

svndumpfilter exclude /trunk/unwanted file_2.jsvg < /tmp/tst_dump_clean1.dmp > /tmp/tst_dump_clean2.dmp

recreate "old temp repo"

rm -rf /tmp/your_local_repo

svnadmin create /tmp/your_local_repo

load filtered dump into repo

[/tmp]$svnadmin load --ignore-uuid your_local_repo < /tmp/tst_dump_clean2.dmp

Check that everything is ok in a svn client (doing a history check on the trunk only shows 25 first results in my svn client).

svnsync sync --username yourname@youremail https://yourproject.googlecode.com/svn
dr jerry
  • 9,768
  • 24
  • 79
  • 122
0

The easiest thing would be to check out the contents of the repository, remove all the sensitive information, import the working directory into a new repository, and make that available to the public. It is very likely that whoever will be using your project will be interested in its current state, not in the change history.

Dima
  • 38,860
  • 14
  • 75
  • 115