Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix make http request inconsistencies #3243

Merged
merged 7 commits into from Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 35 additions & 3 deletions integration_tests/debug.sh
@@ -1,17 +1,49 @@
#!/bin/bash

if [ $1 = "-h" ]; then
echo "Help for ./debug.sh"
printf "\n1. To run all integration tests of 'x' protocol:\n"
printf " \$ ./debug.sh http\n\n"
printf "2. To run all integration tests of 'x' protocol that contains 'y' in template name:\n"
printf " \$ ./debug.sh http self\n\n"
printf "3. To run all integration tests of 'x' protocol that contains 'y' in template name and pass extra args to nuclei:\n"
printf " \$ ./debug.sh http self -svd -debug-req\n\n"
printf "nuclei binary is created everytime script is run but integration-test binary is not"
exit 0
fi


echo "::group::Build nuclei"
rm nuclei 2>/dev/null
cd ../v2/cmd/nuclei
go build .
mv nuclei ../../../integration_tests/nuclei
echo "::endgroup::"
echo -e "::endgroup::\n"
cd ../../../integration_tests
pwd
./integration-test -protocol $1 -template $2

cmdstring=""

if [ -n "$1" ]; then
cmdstring+=" -protocol $1 "
fi

if [ -n "$2" ]; then
cmdstring+=" -template $2 "
fi

# Parse any extra args that are directly passed to nuclei
if [ -n $debugArgs ]; then
export DebugExtraArgs="${@:3}"
fi

echo "$DebugExtraArgs"

echo -e "::group::Run Integration Test\n"
./integration-test $cmdstring

if [ $? -eq 0 ]
then
echo -e "::endgroup::\n"
exit 0
else
exit 1
Expand Down
10 changes: 9 additions & 1 deletion v2/cmd/integration-test/integration-test.go
Expand Up @@ -40,13 +40,21 @@ var (
// For debug purposes
runProtocol = ""
runTemplate = ""
extraArgs = []string{}
)

func main() {
flag.StringVar(&runProtocol, "protocol", "", "run integration tests of given protocol")
flag.StringVar(&runTemplate, "template", "", "run integration test of given template")
flag.Parse()

// allows passing extra args to nuclei
eargs := os.Getenv("DebugExtraArgs")
if eargs != "" {
extraArgs = strings.Split(eargs, " ")
testutils.ExtraDebugArgs = extraArgs
}

if runProtocol != "" {
debug = true
debugTests()
Expand All @@ -73,7 +81,7 @@ func debugTests() {
continue
}
if err := testcase.Execute(tpath); err != nil {
panic(err)
fmt.Printf("\n%v", err.Error())
tarunKoyalwar marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down