refactor: Architecture cleanup — SOLID, DRY, banned patterns, dead code#19
Open
CybLow wants to merge 5 commits into
Open
refactor: Architecture cleanup — SOLID, DRY, banned patterns, dead code#19CybLow wants to merge 5 commits into
CybLow wants to merge 5 commits into
Conversation
added 5 commits
March 21, 2026 19:48
…jthread Iteration 1: Move FlowKey from infra/ to core/model/ - FlowKey is a pure value type (zero platform deps) — belongs in core - Old infra/flow/FlowKey.h becomes a forwarding alias header - All app/ and test files updated to use core::FlowKey Iteration 2: Extract shared test helpers (DRY) - Created tests/helpers/TestFixtures.h with makeFlow() and makeResult() - 8+ test files had identical helpers — now shared - Added includes to 6 test files (gradual migration) Iteration 3: Fix banned system() calls - Replaced std::system() in SetupWizard with fork()/execvp() (POSIX) - Platform-guarded: Linux uses fork/exec, others print manual command - Removed system() from cli_main.cpp rules download command Iteration 4: Fix detached std::thread - ServerDashboard streaming now uses std::jthread (RAII auto-join) - Stored as member streamThread_ — properly cleaned up on destruction - Replaced std::thread(...).detach() anti-pattern Total: 729 tests, all passing
- Remove unused CorrelationCriteria.h include from IHuntEngine.h (CorrelationCriteria exists but is not used in any interface method) - Final audit: zero layer violations, zero system() calls, zero infra::FlowKey references in app/ layer - 729 tests, all passing
…s of test code Pass 1: Remove backward compatibility - Delete infra/flow/FlowKey.h forwarding alias entirely - Update all infra/ headers to include core/model/FlowKey.h directly - Add 'using core::FlowKey' in infra namespaces that use it unqualified - Zero backward compat code remaining Pass 2: DRY — remove 152 lines of duplicated test helpers - 7 test files had identical makeFlow() (8-14 lines each) - 6 test files had identical makeResult() (6-8 lines each) - All now use shared nids::testing::makeFlow/makeResult from TestFixtures.h - Fixed test_JsonFileSink expectations to match shared helper values Total: 729 tests, all passing
- Delete CorrelationCriteria.h (declared but never used in any interface method, production code, or test) - Add toBytes() to TestFixtures.h (was duplicated in 3 test files) - Final audit: zero layer violations, zero banned patterns, zero backward compat, zero dead aliases 729 tests, all passing
…d docs - Remove 'backward compatibility' comment from FlowStats.h - Remove 'backward compatibility' reference from NidsServer.h - Fix 'workaround' comments to 'configuration' (AsanOptions.h refs) - Update docs/roadmap.md: all phases 6-18 marked DONE - Zero TODO/FIXME/HACK/deprecated in production code - 729 tests, all passing
|
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
Systematic architecture cleanup based on a deep codebase audit.
Iteration 1: Move FlowKey to core/ (layer violation fix)
FlowKeyis a pure value type (strings + ints + hash) — belongs incore/model/infra/flow/but used byapp/VerdictEngineandapp/BypassManagerinfra/flow/FlowKey.hbecomes a forwarding alias (backward compat for infra code)core::FlowKeydirectlyIteration 2: Shared test fixtures (DRY)
tests/helpers/TestFixtures.hwithmakeFlow()andmakeResult()Iteration 3: Remove banned
system()callsSetupWizard.cppusedstd::system()(banned per AGENTS.md)fork()/execvp()on Linux (POSIX-compliant)cli_main.cppsystem()also removedIteration 4: Fix detached
std::threadanti-patternServerDashboardusedstd::thread(...).detach()— resource leak riskstd::jthreadstored as memberstreamThread_request_stop()on disconnectIteration 5: Dead code removal
CorrelationCriteria.hinclude fromIHuntEngine.hAudit Results
system()calls remainingstd::thread::detach()calls remaininginfra::FlowKeyreferences in app/ layer