コード例 #1
0
    def __init__(self, obj):
        self.isPCRE = False
        self.compiledValue = None

        if isinstance(obj, bytes):
            obj = obj.decode("utf-8")

        if isinstance(obj, six.text_type):
            self.value = obj

            # Support the short form using forward slashes to indicate a PCRE
            if self.value.startswith("/") and self.value.endswith("/"):
                self.isPCRE = True
                self.value = self.value[1:-1]
                try:
                    self.compiledValue = re.compile(self.value)
                except re.error as e:
                    raise RuntimeError("Error in regular expression: %s" % e)
        else:
            self.value = JSONHelper.getStringChecked(obj, "value", True)

            matchType = JSONHelper.getStringChecked(obj, "matchType", False)
            if matchType is not None:
                if matchType.lower() == "contains":
                    pass
                elif matchType.lower() == "pcre":
                    self.isPCRE = True
                    try:
                        self.compiledValue = re.compile(self.value)
                    except re.error as e:
                        raise RuntimeError("Error in regular expression: %s" %
                                           e)
                else:
                    raise RuntimeError("Unknown match operator specified: %s" %
                                       matchType)
コード例 #2
0
    def __init__(self, obj):
        self.isPCRE = False
        self.compiledValue = None

        if isinstance(obj, str) or isinstance(obj, unicode):
            self.value = str(obj)

            # Support the short form using forward slashes to indicate a PCRE
            if self.value.startswith("/") and self.value.endswith("/"):
                self.isPCRE = True
                self.value = self.value[1:-1]
                try:
                    self.compiledValue = re.compile(self.value)
                except re.error as e:
                    raise RuntimeError("Error in regular expression: %s" % e)
        else:
            self.value = JSONHelper.getStringChecked(obj, "value", True)

            matchType = JSONHelper.getStringChecked(obj, "matchType", False)
            if matchType != None:
                if matchType.lower() == "contains":
                    pass
                elif matchType.lower() == "pcre":
                    self.isPCRE = True
                    try:
                        self.compiledValue = re.compile(self.value)
                    except re.error as e:
                        raise RuntimeError("Error in regular expression: %s" % e)
                else:
                    raise RuntimeError("Unknown match operator specified: %s" % matchType)
コード例 #3
0
ファイル: Matchers.py プロジェクト: secworld/FuzzManager
    def __init__(self, obj):
        self.isPCRE = False
        self.compiledValue = None

        if isinstance(obj, str) or isinstance(obj, unicode):
            self.value = str(obj)

            # Support the short form using forward slashes to indicate a PCRE
            if self.value.startswith("/") and self.value.endswith("/"):
                self.isPCRE = True
                self.value = self.value[1:-1]
                self.compiledValue = re.compile(self.value)
        else:
            self.value = JSONHelper.getStringChecked(obj, "value", True)

            matchType = JSONHelper.getStringChecked(obj, "matchType", False)
            if matchType != None:
                if matchType.lower() == "contains":
                    pass
                elif matchType.lower() == "pcre":
                    self.isPCRE = True
                    self.compiledValue = re.compile(self.value)
                else:
                    raise RuntimeError("Unknown match operator specified: %s" %
                                       matchType)
コード例 #4
0
    def __init__(self, obj):
        '''
        Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly.
        '''
        Symptom.__init__(self, obj)
        self.output = StringMatch(JSONHelper.getObjectOrStringChecked(obj, "value", True))
        self.src = JSONHelper.getStringChecked(obj, "src")

        if self.src != None:
            self.src = self.src.lower()
            if self.src != "stderr" and self.src != "stdout" and self.src != "crashdata":
                raise RuntimeError("Invalid source specified: %s" % self.src)
コード例 #5
0
ファイル: Symptom.py プロジェクト: crowell/FuzzManager
 def __init__(self, obj):
     '''
     Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly.
     '''
     Symptom.__init__(self, obj)
     self.output = StringMatch(JSONHelper.getObjectOrStringChecked(obj, "value", True))
     self.src = JSONHelper.getStringChecked(obj, "src")
     
     if self.src != None:
         self.src = self.src.lower()
         if self.src != "stderr" and self.src != "stdout" and self.src != "crashdata":
             raise RuntimeError("Invalid source specified: %s" % self.src)