synapse-shield 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {synapse_shield-0.2.0/src/synapse_shield.egg-info → synapse_shield-0.2.2}/PKG-INFO +5 -14
- synapse_shield-0.2.2/pyproject.toml +36 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/__init__.py +4 -3
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/engine.py +25 -1
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/main.py +11 -1
- synapse_shield-0.2.2/src/synapse_shield/static/index.html +856 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/tokens.py +2 -1
- {synapse_shield-0.2.0 → synapse_shield-0.2.2/src/synapse_shield.egg-info}/PKG-INFO +5 -14
- synapse_shield-0.2.0/pyproject.toml +0 -53
- synapse_shield-0.2.0/src/synapse_shield/static/index.html +0 -500
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/LICENSE +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/README.md +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/setup.cfg +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/cli.py +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/features.py +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/live_attacker.py +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/middleware.py +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield/static/synapse-sdk.js +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield.egg-info/SOURCES.txt +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield.egg-info/dependency_links.txt +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield.egg-info/entry_points.txt +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield.egg-info/requires.txt +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/src/synapse_shield.egg-info/top_level.txt +0 -0
- {synapse_shield-0.2.0 → synapse_shield-0.2.2}/tests/test_suite.py +0 -0
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: synapse-shield
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: Next-Gen Open-Source Behavioral Biometrics & Bot Mitigation Engine
|
|
5
|
-
Author-email: Mustafa
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Next-Gen Open-Source Behavioral Biometrics & Bot Mitigation Engine
|
|
5
|
+
Author-email: Mustafa Güngör <mustafagungor181881@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
6
7
|
Project-URL: Homepage, https://github.com/0xStoic-bit/Synapse_Shield
|
|
7
|
-
|
|
8
|
-
Project-URL: Documentation, https://github.com/0xStoic-bit/Synapse_Shield#readme
|
|
9
|
-
Keywords: cybersecurity,bot-detection,turnstile-alternative,behavioral-biometrics,kinematics,fastapi,zero-pii,anti-bot
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: Topic :: Security
|
|
13
|
-
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Keywords: cybersecurity,bot-detection,turnstile-alternative,behavioral-biometrics,kinematics,fastapi,zero-pii
|
|
18
9
|
Requires-Python: >=3.10
|
|
19
10
|
Description-Content-Type: text/markdown
|
|
20
11
|
License-File: LICENSE
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "synapse-shield"
|
|
7
|
+
version = "0.2.2"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Mustafa Güngör", email="mustafagungor181881@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "Next-Gen Open-Source Behavioral Biometrics & Bot Mitigation Engine"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = "MIT"
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
keywords = [
|
|
16
|
+
"cybersecurity", "bot-detection", "turnstile-alternative",
|
|
17
|
+
"behavioral-biometrics", "kinematics", "fastapi", "zero-pii"
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"fastapi>=0.110.0",
|
|
21
|
+
"uvicorn>=0.29.0",
|
|
22
|
+
"numpy>=1.26.0",
|
|
23
|
+
"scikit-learn>=1.4.0",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
synapse-shield = "synapse_shield.cli:main"
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.package-data]
|
|
33
|
+
"synapse_shield" = ["static/*"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/0xStoic-bit/Synapse_Shield"
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
Synapse Shield - Behavioral Biometrics & Bot Mitigation Engine
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from .engine import analyze_behavior, poisson_anomaly_score
|
|
5
|
+
from .engine import SynapseEngine, analyze_behavior, poisson_anomaly_score
|
|
6
6
|
from .features import extract_features
|
|
7
7
|
from .middleware import shield_protect
|
|
8
8
|
from .tokens import generate_challenge, verify_and_consume_token
|
|
9
9
|
|
|
10
|
-
__version__ = "0.2.
|
|
10
|
+
__version__ = "0.2.1"
|
|
11
11
|
__all__ = [
|
|
12
|
+
"SynapseEngine",
|
|
12
13
|
"analyze_behavior",
|
|
13
14
|
"poisson_anomaly_score",
|
|
14
15
|
"extract_features",
|
|
15
16
|
"shield_protect",
|
|
16
17
|
"generate_challenge",
|
|
17
|
-
"verify_and_consume_token"
|
|
18
|
+
"verify_and_consume_token",
|
|
18
19
|
]
|
|
@@ -98,4 +98,28 @@ def analyze_behavior(telemetry: Dict[str, Any], recent_request_count: int = 1) -
|
|
|
98
98
|
"poisson_anomaly_score": freq_anomaly
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
return bot_score, classification, reasons, details
|
|
101
|
+
return bot_score, classification, reasons, details
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class SynapseEngine:
|
|
105
|
+
"""
|
|
106
|
+
High-level Object-Oriented Interface for Synapse Shield.
|
|
107
|
+
Usage:
|
|
108
|
+
engine = SynapseEngine()
|
|
109
|
+
result = engine.evaluate(telemetry)
|
|
110
|
+
if not result["success"]:
|
|
111
|
+
# Block request (Bot detected)
|
|
112
|
+
"""
|
|
113
|
+
def __init__(self, sitekey: str = "synapse-default"):
|
|
114
|
+
self.sitekey = sitekey
|
|
115
|
+
|
|
116
|
+
def evaluate(self, telemetry: Dict[str, Any], recent_request_count: int = 1) -> Dict[str, Any]:
|
|
117
|
+
bot_score, classification, reasons, details = analyze_behavior(telemetry, recent_request_count)
|
|
118
|
+
return {
|
|
119
|
+
"success": classification == "Human" and bot_score < 50.0,
|
|
120
|
+
"decision": "ALLOW" if classification == "Human" else "BLOCK",
|
|
121
|
+
"bot_score": bot_score,
|
|
122
|
+
"classification": classification,
|
|
123
|
+
"reasons": reasons,
|
|
124
|
+
"details": details
|
|
125
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import tempfile
|
|
2
3
|
import json
|
|
3
4
|
import sqlite3
|
|
4
5
|
import uvicorn
|
|
@@ -12,7 +13,7 @@ from typing import Dict, Any, List
|
|
|
12
13
|
from .engine import analyze_behavior
|
|
13
14
|
from .tokens import generate_challenge, verify_and_consume_token
|
|
14
15
|
|
|
15
|
-
DB_FILE = "synapse_shield.db"
|
|
16
|
+
DB_FILE = os.environ.get("SYNAPSE_DB_PATH", os.path.join(tempfile.gettempdir(), "synapse_shield.db"))
|
|
16
17
|
|
|
17
18
|
def init_db():
|
|
18
19
|
conn = sqlite3.connect(DB_FILE)
|
|
@@ -76,6 +77,15 @@ def save_log(ip: str, user_agent: str, bot_score: float, classification: str, re
|
|
|
76
77
|
""",
|
|
77
78
|
(now, ip, user_agent, bot_score, classification, json.dumps(reasons), json.dumps(features), json.dumps(telemetry))
|
|
78
79
|
)
|
|
80
|
+
# Otomatik temizlik: sadece son 500 logu tut
|
|
81
|
+
cursor.execute("""
|
|
82
|
+
DELETE FROM logs
|
|
83
|
+
WHERE id NOT IN (
|
|
84
|
+
SELECT id FROM logs
|
|
85
|
+
ORDER BY id DESC
|
|
86
|
+
LIMIT 500
|
|
87
|
+
)
|
|
88
|
+
""")
|
|
79
89
|
conn.commit()
|
|
80
90
|
conn.close()
|
|
81
91
|
|