Implement NetEase bundled rules runtime - #23
Merged
Merged
Conversation
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.
Motivation
Description
netease-g79.json.gzandnetease-x19.json.gzunderbundled_rules.data_dir, performs bounded reads throughsafepath, callsReadPackGzipandValidatePack, converts selected compatiblePackRuletorules.Rule, and merges them with the localrules.Set(internal/bundled/runtime.go).engine.NewWithOptions) while keepingengine.New(root)compatible, perform bundled merge and matcher compilation inPrepareWithOptions, and atomically swap engine state only after successful validation and compilation (internal/engine/engine.go).re2mode onlyRE2Compatible==truerules are activated and incompatible rules are skipped and counted (sanitized hints exposed);pcre2mode returns a clear unsupported-mode error only when NetEase is effectively enabled (internal/bundled/runtime.go).cfg.BundledRulesinto engine (cmd/server/main.go).docs/bundled-rules-phase-b-runtime.md, README, CHANGELOG, config examples).Testing
gofmt/make fmt-checkpassed andgo vet ./...passed.go test ./internal/bundled/... ./internal/engine/... ./internal/config/...,go test ./..., and race testsgo test -race ./internal/bundled/... ./internal/engine/...all passed; bundled runtime unit tests exercise disabled/no-read, dataset/group combos, RE2 incompatibilities, pcre2-mode behavior, missing/wrong/unsafe pack handling, ID collisions, and reload preservation.go build ./...andCGO_ENABLED=0 go build ./...passed;make smoke,make gosec, andmake e2epassed in this environment.make govulncheckfailed due to environment/network access returningForbiddenwhen fetchinghttps://vuln.go.dev/index/modules.json.gz(environment limitation, not code failure).Codex Task