diff --git a/go.sum b/go.sum index 74ada56..8a51ad8 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gabriel-vasile/mimetype v1.4.0 h1:Cn9dkdYsMIu56tGho+fqzh7XmvY2YyGU0FnbhiOsEro= github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8= -github.com/goccy/go-json v0.9.5 h1:ooSMW526ZjK+EaL5elrSyN2EzIfi/3V0m4+HJEDYLik= -github.com/goccy/go-json v0.9.5/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -22,8 +20,6 @@ github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -31,8 +27,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -43,8 +37,6 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32 h1:Js08h5hqB5xyWR789+QqueR6sDE8mk+YvpETZ+F6X9Y= golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/main.go b/main.go index e09d57b..50e6813 100644 --- a/main.go +++ b/main.go @@ -184,8 +184,14 @@ fmt.Println(err) os.Exit(1) } - fmt.Println(color.InBlue(strconv.Itoa(len(configDetailledAnalyze.XML.ListDTD)) + " DTD files for analysis")) - fmt.Println(color.InBlue(strconv.Itoa(len(configDetailledAnalyze.XML.ListXSD)) + " XSD files for analysis")) + fmt.Println(color.InBlue(strconv.Itoa(len(configDetailledAnalyze.XML.ListDTD)) + " DTD files for analysis.")) + for i, dtdName := range configDetailledAnalyze.XML.ListDTD { + fmt.Println(color.InBlue("\t" + strconv.Itoa(i+1) + ": " + dtdName)) + } + fmt.Println(color.InBlue(strconv.Itoa(len(configDetailledAnalyze.XML.ListXSD)) + " XSD files for analysis.")) + for i, xsdName := range configDetailledAnalyze.XML.ListXSD { + fmt.Println(color.InBlue("\t" + strconv.Itoa(i+1) + ": " + xsdName)) + } } func main() { @@ -217,7 +223,7 @@ } fmt.Println(string(result)) } - + // Generation xpaths.csv if !*noXpath { log.Println(color.InBlue("Run xpath process")) @@ -228,7 +234,7 @@ } fmt.Println(string(result)) } else { - result, err := exec.Command("/bin/bash", "xpath.sh", *corpusPath, logPath, "noattval").CombinedOutput() + result, err := exec.Command("/bin/bash", "xpath.sh", *corpusPath, logPath, "noattval").CombinedOutput() if err != nil { fmt.Println(color.InRed("Error xpath.sh")) } diff --git a/xml.go b/xml.go index ce9ef87..4738a91 100644 --- a/xml.go +++ b/xml.go @@ -117,7 +117,12 @@ if errorsMessages != nil && linesMessages != nil { for i := 0; i < len(errorsMessages); i++ { if errorsMessages[i] != nil || linesMessages[i] != nil { - listError = append(listError, ErrorXML{Message: strings.NewReplacer(`"`, "").Replace(errorsMessages[i][1]), Line: linesMessages[i][1], File: file}) + if i < len(linesMessages) { + listError = append(listError, ErrorXML{Message: strings.NewReplacer(`"`, "").Replace(errorsMessages[i][1]), File: file}) + } else { + listError = append(listError, ErrorXML{Message: strings.NewReplacer(`"`, "").Replace(errorsMessages[i][1]), File: file}) + fmt.Print("XML validation error...") + } } } } @@ -139,7 +144,12 @@ // if dtd exist in xml file process only this if len(configDetailledAnalyze.XML.ListDTD) > 0 { if xmlInfo.doctype.Sysid != "" { - dtdPath := GetStringWithSuffixInList(configDetailledAnalyze.XML.ListDTD, xmlInfo.doctype.Sysid) + sysId := xmlInfo.doctype.Sysid + if strings.Contains(sysId, "/") { + t := strings.Split(xmlInfo.doctype.Sysid, "/") + sysId = t[len(t)-1] + } + dtdPath := GetStringWithSuffixInList(configDetailledAnalyze.XML.ListDTD, sysId) if dtdPath != "" { result, _ := exec.Command("xmllint", "--dtdvalid", pathExec+"/dtd/"+dtdPath, pathXml, "--noout", "--nowarning").CombinedOutput() if string(result) == "" {