-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from noobpk/dev
bump to v0.1.6
- Loading branch information
Showing
23 changed files
with
24,288 additions
and
722 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
34 changes: 34 additions & 0 deletions
34
gemini-python/gemini_self_protector/src/gemini_self_protector/_behavior.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from flask import session, request | ||
from ._logger import logger | ||
from ._gemini import _Gemini | ||
from ._utils import _Utils | ||
|
||
|
||
class _Behavior(object): | ||
def init_behavior() -> None: | ||
if "gemini_session" not in session: | ||
client_ip = _Utils.flask_client_ip() | ||
session["gemini_session"] = hash(client_ip + request.user_agent.string) | ||
behavior_id = _Behavior.end_user(request.endpoint) | ||
return behavior_id | ||
|
||
def end_user(action) -> None: | ||
end_user_ip = _Utils.flask_client_ip() | ||
g_session = session.get("gemini_session") | ||
method = request.method | ||
size = request.content_length | ||
useragent = request.user_agent.string | ||
behavior_id = _Gemini.store_gemini_behavior_log( | ||
_ipaddress = end_user_ip, | ||
_end_user_session = g_session, | ||
_endpoint = action, | ||
_useragent = useragent, | ||
_method = method, | ||
_status_code = None, | ||
_start_time = None, | ||
_end_time = None, | ||
_elapsed_time = None, | ||
_size = size, | ||
_performance = None, | ||
) | ||
return behavior_id |
This file contains 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
Oops, something went wrong.