fix: move result counter from module global to instance variable#2991
Open
ashvinctrl wants to merge 1 commit into
Open
fix: move result counter from module global to instance variable#2991ashvinctrl wants to merge 1 commit into
ashvinctrl wants to merge 1 commit into
Conversation
The module-level `globvar` in notify.py persisted across all username scans in a single process, causing `finish()` to print a cumulative count instead of a per-username count. Additionally, `finish()` called `self.countResults() - 1` which incremented the counter one extra time before subtracting 1 — a fragile pattern that masked the off-by-one. Replace `globvar` with `self._result_count = 0` initialised in `__init__`. Each `QueryNotifyPrint` instance now tracks its own scan independently and `finish()` reads the counter directly without an extra increment. Fixes sherlock-project#2990
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
Fixes #2990
QueryNotifyPrintused a module-levelglobvar = 0as its result counter. Because the global was never reset, scanning multiple usernames in one invocation (sherlock user1 user2) causedfinish()to print a cumulative total across all usernames rather than a per-username count.finish()also calledself.countResults() - 1— which incremented the counter one extra time before subtracting 1 — a fragile off-by-one workaround that breaks completely across multiple scans.Changes
sherlock_project/notify.py: remove module-levelglobvar; addself._result_count = 0inQueryNotifyPrint.__init__;countResults()now increments the instance variable;finish()readsself._result_countdirectly (no spurious extra increment)tests/test_notify.py: new test file verifying counter starts at zero, increments only onCLAIMED, and that two independent instances never share stateTest plan
pytest tests/test_notify.py— all new tests passpytest— full suite greensherlock user1 user2— each username shows its own independent count