Repository navigation
fix(runner): accept http2 and http3 in protocol validation #2670
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
|
|
||
| func TestValidateOptions_Protocol(t *testing.T) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win Add the package declaration and test imports. This file starts with 🧰 Tools🪛 GitHub Actions: 🔨 Release Test / 0_release-test.txt[error] 2-2: GoReleaser release --clean --snapshot failed while building binaries: Go compiler reported "expected 'package', found 'func'". The file is missing a package declaration or has invalid syntax at the start. 🪛 GitHub Actions: 🔨 Release Test / release-test[error] 2-2: GoReleaser command 'goreleaser release --clean --snapshot' failed while building binaries: expected 'package', found 'func'. 🪛 golangci-lint (2.13.2)[error] 2-2: expected 'package', found 'func' (typecheck) 🤖 Prompt for AI AgentsSources: Linters/SAST tools, Pipeline failures |
||
| tests := []struct { | ||
| protocol string | ||
| wantErr bool | ||
| }{ | ||
| {"", false}, | ||
| {"unknown", false}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Correct the
🤖 Prompt for AI Agents |
||
| {"UNKNOWN", false}, | ||
| {"http11", false}, | ||
| {"HTTP11", false}, | ||
| {"http2", false}, | ||
| {"HTTP2", false}, | ||
| {"http3", false}, | ||
| {"HTTP3", false}, | ||
| {"http10", true}, | ||
| {"invalid", true}, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.protocol, func(t *testing.T) { | ||
| opts := &Options{ | ||
| Protocol: tc.protocol, | ||
| } | ||
| err := opts.ValidateOptions() | ||
| if tc.wantErr { | ||
| require.Error(t, err) | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: projectdiscovery/httpx
Length of output: 2190
🏁 Script executed:
Repository: projectdiscovery/httpx
Length of output: 16322
Normalize accepted protocol values before the runtime handoff.
Validation accepts mixed-case values, but
runner/runner.gopasses the original value tohttpxOptions.Protocol. The exactHTTP11comparison incommon/httpx/httpx.gocan therefore miss the branch that disables HTTP/2. Normalize the value after validation so all accepted protocols reach exact-value dispatch consistently.Suggested fix
🤖 Prompt for AI Agents