mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-21 17:15:30 +00:00
* Add s3 bucket template provider - Refactor the custom github template code - add interface for template provider * Validate if aws creds are passed if bucket flag - refactor s3 provider struct to take client - add function which returns the aws s3 client - update error messages * Add aws s3 bucket flags documentation in README.md - Rename the github_test.go to customTemplate_test.go * go mod update * Move template provider code to pkg/external/customtemplates dir * Remove github and aws update variables from flag * Rename CustomTemplateProvider to Provider * Update integration and function command in makefile * Update github test case, accept token * readme update * go mod tidy * Update build-test.yml * handle empty dir in s3 * Add requested changes - download/update s3 and github only when `-ut` is passed - only print the missing env variable for s3 - add the custom templates path in ~/.config/nuclei/.template-config.json * print custom paths only if exists in config file * misc update * tag update Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com> Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package customtemplates
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/gologger"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDownloadCustomTemplatesFromGitHub(t *testing.T) {
|
|
gologger.DefaultLogger.SetWriter(&testutils.NoopWriter{})
|
|
|
|
templatesDirectory, err := os.MkdirTemp("", "template-custom-*")
|
|
require.Nil(t, err, "could not create temp directory")
|
|
defer os.RemoveAll(templatesDirectory)
|
|
|
|
options := testutils.DefaultOptions
|
|
options.GithubTemplateRepo = []string{"projectdiscovery/nuclei-templates", "ehsandeep/nuclei-templates"}
|
|
options.GithubToken = os.Getenv("GITHUB_TOKEN")
|
|
customTemplates := ParseCustomTemplates(options)
|
|
|
|
for _, ct := range customTemplates {
|
|
ct.Download(templatesDirectory, context.Background())
|
|
}
|
|
|
|
require.DirExists(t, filepath.Join(templatesDirectory, "github", "nuclei-templates"), "cloned directory does not exists")
|
|
require.DirExists(t, filepath.Join(templatesDirectory, "github", "nuclei-templates-ehsandeep"), "cloned directory does not exists")
|
|
}
|