mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 21:51:28 +00:00
Catch a few more config corruption issues. i18n for error messages
This commit is contained in:
@@ -123,6 +123,7 @@ import re
|
|||||||
|
|
||||||
from types import StringTypes
|
from types import StringTypes
|
||||||
from ConfigParser import DuplicateSectionError, NoSectionError, NoOptionError
|
from ConfigParser import DuplicateSectionError, NoSectionError, NoOptionError
|
||||||
|
from ConfigParser import Error as ConfigParser_Error
|
||||||
|
|
||||||
from zenmapCore.Paths import Path
|
from zenmapCore.Paths import Path
|
||||||
from zenmapCore.UmitLogging import log
|
from zenmapCore.UmitLogging import log
|
||||||
@@ -258,11 +259,11 @@ class Profile(UmitConfigParser, object):
|
|||||||
user_profile = Path.scan_profile
|
user_profile = Path.scan_profile
|
||||||
|
|
||||||
self.read(user_profile)
|
self.read(user_profile)
|
||||||
except Exception as e:
|
except ConfigParser_Error as e:
|
||||||
# No scan profiles found is not a reason to crash.
|
# No scan profiles found is not a reason to crash.
|
||||||
self.add_profile("Profiles not found",
|
self.add_profile(_("Profiles not found"),
|
||||||
command="nmap",
|
command="nmap",
|
||||||
description="The {} file was not found".format(user_profile))
|
description=_("The {} file is missing or corrupted").format(user_profile))
|
||||||
|
|
||||||
self.attributes = {}
|
self.attributes = {}
|
||||||
|
|
||||||
@@ -418,6 +419,11 @@ class CommandProfile (Profile, object):
|
|||||||
|
|
||||||
def get_command(self, profile):
|
def get_command(self, profile):
|
||||||
command_string = self._get_it(profile, 'command')
|
command_string = self._get_it(profile, 'command')
|
||||||
|
# Corrupted config file can include multiple commands. Take the first one.
|
||||||
|
if isinstance(command_string, list):
|
||||||
|
command_string = command_string[0]
|
||||||
|
if not hasattr(command_string, "endswith"):
|
||||||
|
return "nmap"
|
||||||
# Old versions of Zenmap used to append "%s" to commands and use that
|
# Old versions of Zenmap used to append "%s" to commands and use that
|
||||||
# to substitute the target. Ignore it if present.
|
# to substitute the target. Ignore it if present.
|
||||||
if command_string.endswith("%s"):
|
if command_string.endswith("%s"):
|
||||||
|
|||||||
Reference in New Issue
Block a user