mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 15:05:26 +00:00
* Extending deny list to support filenames and folders * fixing field name * adding missing edge case with relative path + filename * handling root path + relative path * Improving matchers to handle all deny cases
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package file
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
|
)
|
|
|
|
func TestFileCompile(t *testing.T) {
|
|
options := testutils.DefaultOptions
|
|
|
|
testutils.Init(options)
|
|
templateID := "testing-file"
|
|
request := &Request{
|
|
ID: templateID,
|
|
MaxSize: 1024,
|
|
NoRecursive: false,
|
|
Extensions: []string{"all", ".lock"},
|
|
DenyList: []string{".go"},
|
|
}
|
|
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
|
ID: templateID,
|
|
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
|
})
|
|
err := request.Compile(executerOpts)
|
|
require.Nil(t, err, "could not compile file request")
|
|
|
|
require.Contains(t, request.denyList, ".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")
|
|
}
|