completed event entropy analyzer spam detection#212
Open
buggythanos wants to merge 1 commit intobnb-chain:mainfrom
Open
completed event entropy analyzer spam detection#212buggythanos wants to merge 1 commit intobnb-chain:mainfrom
buggythanos wants to merge 1 commit intobnb-chain:mainfrom
Conversation
|
Congratulations! You have received a Cookbook reward. Please reply with your BSC wallet address.Thanks |
Author
|
Hi there, thank you! |
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.
Description
This PR adds an Event Entropy Analyzer for detecting spam patterns in blockchain events on BNB Smart Chain (BSC). The tool analyzes Transfer and Approval events from smart contracts using Shannon entropy calculations to identify suspicious patterns that indicate automated spam activity.
By measuring the randomness and diversity of event data (addresses and values), the analyzer can distinguish between legitimate activity and spam. It calculates entropy scores, detects repetitive patterns, and provides actionable recommendations for security teams and developers.
Key Features:
/api/analyzeendpoint for programmatic accessSpam Detection Indicators:
Spam Score Components:
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
The implementation includes a comprehensive test suite with 33 unit tests covering:
Entropy Calculation:
Pattern Analysis:
Spam Score Calculation:
Spam Level Classification:
Recommendation Generation:
Complete Event Entropy Analysis:
Test execution:
npm testAll 33 tests pass successfully. The test suite uses Jest with comprehensive edge case coverage to ensure reliable spam detection across various scenarios.
Manual testing:
http://localhost:3000and analyzing various contract addresses and block ranges/api/analyzewith different contract addresses, event types, and block rangesnpm startwithout arguments and accessing the web interfaceChecklist:
Additional notes:
setup.shscript for one-command installation and setupenv.templatefor environment variable configurationH(X) = -Σ P(x) * log2(P(x))