neverrend / XMLChecker

Cyber Ninjas XML Checker
GNU General Public License v3.0
1 stars 0 forks source link

Warning for empty elements #4

Closed oxr463 closed 5 years ago

oxr463 commented 5 years ago

We currently check for the max length of 255, but we also need to make sure it isn't empty.

        c = XSDCheck3.search(x)
        if c:
            orgLine = lineNum

            while range(len(lines[lineNum])):

                line = line + lines[lineNum]
                end = XSDCheck4.search(lines[lineNum])
                lineNum += 1

                if end:
                    line = len(list(line))
                    if line > 255:
                        print("- has to large of a location field. Remove some sites")
                    lineNum = orgLine
                    break

Source: XMLCheck.py

neverrend commented 5 years ago

This has flipped. It now checks for empty "Location" element but does not do the character count. Need to add this next.

    def Analyze(self):                                                                                  
        names = ["Name", "CWE", "Count", "CAPEC", "CVSS", "Description",                                
                    "Remediation", "Remediation Effort", "Exploit Description",                         
                    "Severity Description", "Note", "Input Vector", "Location",                         
                    "Exploit Difficulty"]                                                               
        for flaw in self.flaws:                                                                         
            print("{}: {}".format(flaw, self.flaws[flaw]["Flaw Name"]))                                 
            for name in names:                                                                          
                if self.flaws[flaw]["Flaw "+name] == None or \                                          
                    self.flaws[flaw]["Flaw "+name] == "":                                               
                    print("[*]\t Flaw {} is missing.".format(name))                                     
                elif name == "Count":                                                                   
                    print("[*]\t Counts/Instance Count: ({}/{})".format(self.flaws[flaw]["Flaw Count"],\
                            self.flaws[flaw]["Flaw Appendix"]["Instance Count"]))                       
                elif name == "CVSS":                                                                    
                    digits = re.compile("([\d\.]{3})")                                                  
                    cvssNum = digits.search(self.flaws[flaw]["Flaw Note"]).group()                      
                    if float(self.flaws[flaw]["Flaw "+name]) != float(cvssNum):                         
                        print("[*]\t Flaw CVSS score({}) doesnt match the Note score({})"\              
                                .format(self.flaws[flaw]["Flaw "+name],cvssNum))                        

            print()                                                                                     
neverrend commented 5 years ago

This has now been fixed with the latest commit.