[Openvas-commits] r1336 - in trunk/openvas-client: . tools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Sep 12 12:28:32 CEST 2008


Author: mwiegand
Date: 2008-09-12 12:28:31 +0200 (Fri, 12 Sep 2008)
New Revision: 1336

Added:
   trunk/openvas-client/tools/
   trunk/openvas-client/tools/openvas1_to_openvas2.sh
Modified:
   trunk/openvas-client/ChangeLog
Log:
Added migration script to convert user data from IDs to OIDs.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2008-09-12 07:57:23 UTC (rev 1335)
+++ trunk/openvas-client/ChangeLog	2008-09-12 10:28:31 UTC (rev 1336)
@@ -1,5 +1,14 @@
 2008-09-12  Michael Wiegand <michael.wiegand at intevation.de>
 
+	Added migration script to convert user data from IDs to OIDs.
+
+	* tools/: Created.
+
+	* tools/openvas1_to_openvas2.sh: Added. Migration script to convert
+	user data from IDs to OIDs.
+
+2008-09-12  Michael Wiegand <michael.wiegand at intevation.de>
+
 	* nessus/comm.c (parse_plugin, comm_get_plugins_md5): Fixed parser to
 	correctly handle the OIDs send by the server.
 

Added: trunk/openvas-client/tools/openvas1_to_openvas2.sh
===================================================================
--- trunk/openvas-client/tools/openvas1_to_openvas2.sh	2008-09-12 07:57:23 UTC (rev 1335)
+++ trunk/openvas-client/tools/openvas1_to_openvas2.sh	2008-09-12 10:28:31 UTC (rev 1336)
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+# OpenVAS
+# $Id$
+# Description: Script for migrating existing reports from 1.0 to 2.0 to keep the
+# reports readable with OpenVAS-Client 2.0
+#
+# Authors:
+# Michael Wiegand <michael.wiegand at intevation.de>
+#
+# Copyright:
+# Copyright (C) 2008 Intevation GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later,
+# as published by the Free Software Foundation
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+OPTERROR=33
+dir=~/.openvas/
+force=0
+purge=0
+confirm="N"
+
+show_usage () {
+  echo "Usage: $0 [-D <directory>] [-p] [-f]"
+  echo "  -D <directory> :  Migrate files in <directory> (default: ~/.openvas/)"
+  echo "  -p :              Purge files with old IDs after migration"
+  echo "  -f :              Do not ask for confirmation, migrate all found files"
+  exit $OPTERROR
+}
+
+if [ -n $1 ]
+then
+  while getopts ":pfhD:" Option
+  do
+    case $Option in
+      p     ) purge=1;;
+      D     ) dir=$OPTARG;;
+      f     ) force=1;;
+      h     ) show_usage;;
+      *     ) show_usage;;
+    esac
+  done
+fi
+
+
+if [ $force -ne 1 ]
+then
+  find $dir -name report.nbe
+  find $dir -name nessus_plugin_cache
+  find $dir -name nessusrc
+  echo -n "Do you want to migrate the above files from the OpenVAS 1.0 file format to the 2.0 file format"
+  if [ $purge -eq 1 ]
+  then
+    echo -n " and purge the old files after migration"
+  fi
+  echo -n "? [y/N] "
+  read confirm
+  if [ "$confirm" != "y" ]
+  then
+    exit 0
+  fi
+fi
+
+
+for d in `find $dir -name report.nbe -type f -printf '%h\n'`; do
+  echo "Migrating $d/report.nbe ... ";
+  mv $d/report.nbe $d/report.nbe.openvas1 ;
+  sed -e "/^results/s/|/|1.3.6.1.4.1.25623.1.0./4" $d/report.nbe.openvas1 > $d/report.nbe;
+  if [ $purge -eq 1 ]
+  then
+    echo "Purging $d/report.nbe.openvas1 ... ";
+    rm $d/report.nbe.openvas1
+  fi
+done
+
+for d in `find $dir -name nessus_plugin_cache -type f -printf '%h\n'`; do
+  echo "Migrating $d/nessus_plugin_cache ... ";
+  sed -e "1s/NessusClientPluginCache/OpenVASNVTDescCache/" -e "s/^plugin/nvt/" -e "2,\$s/|/|1.3.6.1.4.1.25623.1.0./" $d/nessus_plugin_cache > $d/openvas_nvt_cache
+  if [ $purge -eq 1 ]
+  then
+    echo "Purging $d/nessus_plugin_cache ... ";
+    rm $d/nessus_plugin_cache
+  fi
+done
+
+for d in `find $dir -name nessusrc -type f -printf '%h\n'`; do
+  echo "Migrating $d/nessusrc ... ";
+  sed -e "/^ [0-9]/s/^ / 1.3.6.1.4.1.25623.1.0./" $d/nessusrc > $d/openvasrc
+  if [ $purge -eq 1 ]
+  then
+    echo "Purging $d/nessusrc ... ";
+    rm $d/nessusrc
+  fi
+done
+
+echo -n "All files have been converted, "
+if [ $purge -eq 1 ]
+then
+  echo "the old files have been purged.";
+else
+  echo "the original reports have been backed up to report.nbe.openvas1."
+fi


Property changes on: trunk/openvas-client/tools/openvas1_to_openvas2.sh
___________________________________________________________________
Name: svn:executable
   + *



More information about the Openvas-commits mailing list