From 718489133860efc32d6f11d79bfde058d3375ef6 Mon Sep 17 00:00:00 2001 From: M09Ic Date: Mon, 9 Jan 2023 22:41:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E4=B8=80=E6=AD=A5=E4=BC=98=E5=8C=96cr?= =?UTF-8?q?awl=E7=9A=84=E6=AD=A3=E5=88=99=E4=B8=8E=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pool.go | 2 ++ pkg/utils.go | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/pool.go b/internal/pool.go index 81ffbc0..f709533 100644 --- a/internal/pool.go +++ b/internal/pool.go @@ -520,6 +520,8 @@ func (pool *Pool) doCrawl(bl *pkg.Baseline) { } else { u = pkg.URLJoin(path.Dir(bl.Url.Path), u[2:]) } + } else if strings.HasPrefix(u, "../") { + u = path.Join(path.Dir(bl.Url.Path), u) } else if !strings.HasPrefix(u, "http") { // 相对目录拼接 if bl.Dir { diff --git a/pkg/utils.go b/pkg/utils.go index a76311f..361e9aa 100644 --- a/pkg/utils.go +++ b/pkg/utils.go @@ -30,7 +30,7 @@ var ( URLRegexps []*regexp.Regexp = []*regexp.Regexp{ regexp.MustCompile(`["'‘“]\s{0,6}(https{0,1}:[^\s^,^'^’^"^”^>^<^),^(]{2,250}?)\s{0,6}["'‘“]`), regexp.MustCompile(`=\s{0,6}(https{0,1}:[^\s^'^,^’^"^”^>^<^;^(^)^|^*^\[]{2,250})`), - regexp.MustCompile(`["'](\w{2,250}?\.\w{2,4}?)["']`), + regexp.MustCompile(`["']([\w/]{2,250}?\.\w{2,4}?)["']`), regexp.MustCompile(`["'‘“]\s{0,6}([#,.]{0,2}/[^\s^'^,^’^"^”^>^<^;^(^)^|^*^\[]{2,250}?)\s{0,6}["'‘“]`), regexp.MustCompile(`href\s{0,6}=\s{0,6}["'‘“]{0,1}\s{0,6}([^\s^'^,^’^"^”^>^<^;^(^)^|^*^\[]{2,250})|action\s{0,6}=\s{0,6}["'‘“]{0,1}\s{0,6}([^\s^'^’^"^“^>^<^)^(]{2,250})`), } @@ -226,7 +226,7 @@ func FingerDetect(content string) Frameworks { } var ( - BadExt = []string{".js", ".css", ".scss", ",", ".jpeg", ".jpg", ".png", ".gif", ".svg", ".vue", ".ts"} + BadExt = []string{".js", ".css", ".scss", ".,", ".jpeg", ".jpg", ".png", ".gif", ".svg", ".vue", ".ts", ".swf", ".pdf"} BadURL = []string{";", "}", "{", "www.w3.org", "example.com", ".src", ".url", ".att", ".href", "location.href", "javascript:", "location:", ".createObject", ":location", ".path", "*#__PURE__*"} ) @@ -249,7 +249,7 @@ func filterUrl(u string) bool { } else { ext := path.Ext(parsed.Path) for _, e := range BadExt { - if e == ext { + if strings.EqualFold(e, ext) { return true } } @@ -269,7 +269,7 @@ func formatURL(u string) string { } func commonFilter(u string) bool { - if strings.HasPrefix(u, "http") && len(u) < 9 { + if strings.HasPrefix(u, "http") && len(u) < 15 { return true }