Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to erase sensitive information from Subversion?

Tags:

svn

I one of the previous versions of my code, stored in a Subversion repository, there is sensitive information. How to erase it while keeping all other versions?

EDIT: The repository is Google Code Project Hosting, so I can't dump and restore the repository =(

like image 282
Jader Dias Avatar asked Aug 18 '09 15:08

Jader Dias


2 Answers

Want you want is a SVN feature commonly called "obliterate", which unfortunately still is not implemented.

As a workaround, you will have to dump, filter & reimport your repository. See e.g. the entry in the SVN faq How do I completely remove a file from the repository's history?.

BTW: It's a dupe :-). https://stackoverflow.com/questions/663584/subversion-permanently-remove-incorrectly-checked-in-directory-project

EDIT:

The repository is Google Code Project Hosting, so I can't dump and restore the repository =(

As far as I can see, the only solution in this case is to (ask Google to) reset your respository (see this FAQ, and this blog post). This will completely remove all data from the repository (both current data and history), as if you had just started the repository using svnadmin create.

Obviously, you'll need a backup of your repository first.

The best solution probably is:

  • create a backup of your repo using snvsync (this will also back up the history)
  • do the dump/filter/restore dance (see above) on your backup of the repo, to remove the problematic commmits
  • reset the Google repository
  • put back your filtered repo, again using snvsync (see FAQ How do I import my existing source code? )
like image 128
sleske Avatar answered Nov 05 '22 01:11

sleske


You can't remove what's commited to subversion other than completely dump, erase the original, and recreate the repository from the dump.

If you want to completely remove a file/path, you can do that with the svndumpfilter:

svnadmin dump /path/to/repository > svndump
svndumpfilter exclude path/to/sensitivefile > svndump-excluded
svnadmin create /tmp/newrepository
svnadmin load /tmp/newrepository < svndump-excluded

Then backup your /path/to/repository and replace it with /tmp/newrepository after you've verified everything is ok.

If you want to only exclude a single revision, you'd have to do something like

svnadmin dump  -r 0:1000 /path/to/repository > svndump1
svnadmin dump  -r 1002:HEAD --incremental /path/to/repository > svndump2
svnadmin create /tmp/newrepository
svnadmin load /tmp/newrepository <svndump1
svnadmin load /tmp/newrepository <svndump2

That is, revision 1001 is excluded. You can't do it more fine grained btw, a whole revision have to be excluded. Same deal here, backup your original repository, verify that everything needed in the new repository is there.

like image 43
nos Avatar answered Nov 05 '22 01:11

nos