Repository navigation
refactor: isolate session state, fix concurrency races and protocol/POC anti-patterns - #620
Merged
ZacharyZcR merged 3 commits intoDec 1, 2026
Merged
Conversation
…rograms, and guard SDK language state
ZacharyZcR
deleted the
refactor/session-isolation-and-antipattern-fixes
branch
December 1, 2026 17:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves several concurrency, session-isolation, networking, and performance anti-patterns across
common,core,plugins,webscan,web, andpkg/fscan:1. Session Isolation & Concurrency Safety
webscan/lib/Client.go,common/session.go,core/scanner.go,webscan/lib/Eval.go,plugins/web/webtitle.go):HTTPClientSet+InitSessionHTTP/GetSessionHTTPClientso concurrentRunScancalls maintain independent transports, proxy configs, and timeouts, and release idle connections on exit.os.Stdoutredirection hack during GM-TLS handshakes; GM-TLS now reusestr.DialContextto inherit proxy settings andcontext.Contextcancellation without serializing handshakes or swallowing stdout.sync.RWMutexand close idle connections on replaced transports.common/proxy/manager.go,common/session.go):NewIsolatedProxyManagerso eachScanSessionprobes and caches its own SOCKS5 reliability without mutating global proxy state.common/logger.go,core/web_scanner.go,plugins/web/webtitle.go):PushSilentLoggerresets withsync.RWMutex.coreglobalStatetoatomic.Pointer[common.State]and update cachedServiceInfo.Extrasvia copy-on-write (SetWebServiceProtocolWithState) to prevent concurrent map writes.web/ws/hub.go,web/api/scan.go,web/api/result.go,web/api/project.go):Client.sendwrites/closes to eliminatesend on closed channelpanics inreadPump; addHub.Stop()for clean shutdown.SetGlobalConfig/SetGlobalState/SetResultCallbackbridge inweb/api/scan.gowithsession.ResultSink, and fix unlockedh.startTimereads.ResultStoreandProjectStoreviasync.Onceinstead of performing filesystem I/O and panicking inside packageinit().2. Unified Dialing & Context Cancellation
mongodb,oracle,mssql,cassandra,kafka,netbios,elasticsearch, andDetectHTTPSchemeContextTLS/GM-TLS handshakes throughsession.DialTCP/session.DialUDPso proxy settings, rate limits, packet counters, andctxcancellation are honored consistently.main_cli.go) viasignal.NotifyContext(graceful cancel on first signal, force exit on second), add missingsignal.Stopincore/scanner.go, and propagatectx.Done()checks tocore/port_scan.go,core/icmp.go,webscan/lib/poc_executor.go, andplugins/services/credential_tester.go.3. Fingerprint Performance, Nuclei Semantics & SDK Fixes
webscan/fingerprint/enhanced.go,webscan/fingerprint_scanner.go): Precompute lowercased body/headers andstring(data.Body)once per page instead of thousands of times per scan, and collect worker matches into per-worker slices without allocating large buffered channels.webscan/lib/poc_adapter.go): Default single-matcher condition to OR per Nuclei spec (fixing always-false expressions such asstatus: [200, 302]), and map multi-path single-request templates to OR rule groups (poc.Groups) instead of AND rules.pkg/fscan/scanner.go,plugins/services/redis.go,plugins/services/credential_tester.go):Usernames/Passwordsdirectly intocfg.Credentialsso credentials containing commas are not split; enforceDisablePocScanwhenAllowUnsafePluginsis false.ModuleThreadNumin Redis plugin instead of hardcoding concurrency to 20.errors.Is/errors.As(context.DeadlineExceeded,io.EOF,net.Error) inClassifyErrorand replace custom case-insensitive substring loops withstrings.Verification
go test -race ./common/... ./core ./plugins/... ./webscan/... ./pkg/fscango test -tags web ./web/...go build -o /dev/null .go build -tags web -o /dev/null .