2021-02-03 17:49:10 +05:30
|
|
|
package file
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2021-07-19 21:04:08 +03:00
|
|
|
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
2021-09-03 16:48:39 +03:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
2021-02-03 17:49:10 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestFileCompile(t *testing.T) {
|
|
|
|
|
options := testutils.DefaultOptions
|
|
|
|
|
|
|
|
|
|
testutils.Init(options)
|
|
|
|
|
templateID := "testing-file"
|
|
|
|
|
request := &Request{
|
2021-02-05 14:43:11 +05:30
|
|
|
ID: templateID,
|
|
|
|
|
MaxSize: 1024,
|
|
|
|
|
NoRecursive: false,
|
2021-03-08 19:20:40 +05:30
|
|
|
Extensions: []string{"all", ".lock"},
|
2021-02-05 14:43:11 +05:30
|
|
|
ExtensionDenylist: []string{".go"},
|
2021-02-03 17:49:10 +05:30
|
|
|
}
|
|
|
|
|
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
|
|
|
|
ID: templateID,
|
2021-09-03 16:48:39 +03:00
|
|
|
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
2021-02-03 17:49:10 +05:30
|
|
|
})
|
|
|
|
|
err := request.Compile(executerOpts)
|
|
|
|
|
require.Nil(t, err, "could not compile file request")
|
|
|
|
|
|
|
|
|
|
require.Contains(t, request.extensionDenylist, ".go", "could not get .go in denylist")
|
|
|
|
|
require.NotContains(t, request.extensions, ".go", "could get .go in allowlist")
|
|
|
|
|
require.True(t, request.allExtensions, "could not get correct allExtensions")
|
|
|
|
|
}
|