mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 22:45:27 +00:00
* chore: fix non-constant fmt string in call Signed-off-by: Dwi Siswanto <git@dw1.io> * build: bump all direct modules Signed-off-by: Dwi Siswanto <git@dw1.io> * chore(hosterrorscache): update import path Signed-off-by: Dwi Siswanto <git@dw1.io> * fix(charts): break changes Signed-off-by: Dwi Siswanto <git@dw1.io> * build: pinned `github.com/zmap/zcrypto` to v0.0.0-20240512203510-0fef58d9a9db Signed-off-by: Dwi Siswanto <git@dw1.io> * chore: golangci-lint auto fixes Signed-off-by: Dwi Siswanto <git@dw1.io> * chore: satisfy lints Signed-off-by: Dwi Siswanto <git@dw1.io> * build: migrate `github.com/xanzy/go-gitlab` => `gitlab.com/gitlab-org/api/client-go` Signed-off-by: Dwi Siswanto <git@dw1.io> * feat(json): update build constraints Signed-off-by: Dwi Siswanto <git@dw1.io> * chore: dont panicking on close err Signed-off-by: Dwi Siswanto <git@dw1.io> --------- Signed-off-by: Dwi Siswanto <git@dw1.io>
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
package json
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/input/types"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var expectedURLs = []string{
|
|
"https://ginandjuice.shop/",
|
|
"https://ginandjuice.shop/catalog/product?productId=1",
|
|
"https://ginandjuice.shop/resources/js/stockCheck.js",
|
|
"https://ginandjuice.shop/resources/js/xmlStockCheckPayload.js",
|
|
"https://ginandjuice.shop/resources/js/xmlStockCheckPayload.js",
|
|
"https://ginandjuice.shop/resources/js/stockCheck.js",
|
|
"https://ginandjuice.shop/catalog/product/stock",
|
|
"https://ginandjuice.shop/catalog/cart",
|
|
"https://ginandjuice.shop/catalog/product?productId=1",
|
|
"https://ginandjuice.shop/catalog/subscribe",
|
|
"https://ginandjuice.shop/blog",
|
|
"https://ginandjuice.shop/blog/?search=dadad&back=%2Fblog%2F",
|
|
"https://ginandjuice.shop/logger",
|
|
"https://ginandjuice.shop/blog/",
|
|
"https://ginandjuice.shop/blog/post?postId=3",
|
|
"https://ginandjuice.shop/about",
|
|
"https://ginandjuice.shop/my-account",
|
|
"https://ginandjuice.shop/login",
|
|
"https://ginandjuice.shop/login",
|
|
"https://ginandjuice.shop/login",
|
|
"https://ginandjuice.shop/my-account",
|
|
"https://ginandjuice.shop/catalog/cart",
|
|
"https://ginandjuice.shop/my-account",
|
|
"https://ginandjuice.shop/logout",
|
|
"https://ginandjuice.shop/",
|
|
"https://ginandjuice.shop/catalog",
|
|
}
|
|
|
|
func TestJSONFormatterParse(t *testing.T) {
|
|
format := New()
|
|
|
|
proxifyInputFile := "../testdata/ginandjuice.proxify.json"
|
|
|
|
file, err := os.Open(proxifyInputFile)
|
|
require.Nilf(t, err, "error opening proxify input file: %v", err)
|
|
defer func() {
|
|
_ = file.Close()
|
|
}()
|
|
|
|
var urls []string
|
|
err = format.Parse(file, func(request *types.RequestResponse) bool {
|
|
urls = append(urls, request.URL.String())
|
|
return false
|
|
}, proxifyInputFile)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if len(urls) != len(expectedURLs) {
|
|
t.Fatalf("invalid number of urls: %d", len(urls))
|
|
}
|
|
require.ElementsMatch(t, urls, expectedURLs)
|
|
}
|