Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move on main #20

Merged
merged 4 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
2 changes: 2 additions & 0 deletions .trunk/configs/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
10 changes: 10 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
5 changes: 5 additions & 0 deletions .trunk/configs/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generic, formatter-friendly config.
select = ["B", "D3", "E", "F"]

# Never enforce `E501` (line length violations). This should be handled by formatters.
ignore = ["E501"]
14 changes: 14 additions & 0 deletions .trunk/configs/svgo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
sortAttrs: true,
removeOffCanvasPaths: true,
},
},
},
],
};
35 changes: 35 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.20.1
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.4.4
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- [email protected]
- [email protected]
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ Interested in contributing? Check out the contributing guidelines. Please note t
## Theme

https://appseed.us/product/datta-able/flask/

## Research Publication

`Phuc Le-Thanh, Tuan Le-Anh, and Quan Le-Trung. 2023. Research and Development of a Smart Solution for Runtime Web Application Self-Protection. In Proceedings of the 12th International Symposium on Information and Communication Technology (SOICT '23). Association for Computing Machinery, New York, NY, USA, 304–311. https://doi.org/10.1145/3628797.3628901`
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import session, request
from ._logger import logger
from flask import request, session

from ._gemini import _Gemini
from ._utils import _Utils

Expand All @@ -19,16 +19,16 @@ def end_user(action) -> None:
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,
_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
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import csv
import json
import os

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from ._logger import logger
import json
import csv
from ipaddress import ip_address
from datetime import datetime
from ._model import (
Base,
tb_User,
tb_Config,
tb_Summary,
tb_RequestLog,
tb_AccessControlList,
tb_BehaviorLog,
tb_Config,
tb_Dependency,
tb_Feedback,
tb_BehaviorLog,
tb_RequestLog,
tb_Summary,
tb_User,
)


Expand All @@ -28,6 +28,7 @@ def __init__(self, working_directory):
Session = sessionmaker(bind=engine)
session = Session()

# trunk-ignore(bandit/B106)
user = tb_User(username="superadmin", password="")
config = tb_Config(
is_install=0,
Expand Down Expand Up @@ -354,7 +355,7 @@ def get_tb_acl() -> None:
return acl
except Exception as e:
logger.error(
"[x_x] Something went wrong, please check your error message.\n Message - {0}".format(
"[x_x] Something went wrong at {0}, please check your error message.\n Message - {1}".format(
"_Config.get_tb_acl", e
)
)
Expand Down Expand Up @@ -449,7 +450,7 @@ def get_tb_dependency() -> None:
return dependency
except Exception as e:
logger.error(
"[x_x] Something went wrong, please check your error message.\n Message - {0}".format(
"[x_x] Something went wrong at {0}, please check your error message.\n Message - {1}".format(
"_Config.get_tb_dependency", e
)
)
Expand Down Expand Up @@ -477,8 +478,8 @@ def get_tb_feedback() -> None:
return feedback
except Exception as e:
logger.error(
"[x_x] Something went wrong, please check your error message.\n Message - {0}".format(
"_Config.get_tb_dependency", e
"[x_x] Something went wrong at {0}, please check your error message.\n Message - {1}".format(
"_Config.get_tb_feedback", e
)
)

Expand Down Expand Up @@ -516,7 +517,7 @@ def export_tb_feedback() -> str:
return csv_file_path
except Exception as e:
logger.error(
"[x_x] Something went wrong, please check your error message.\n Message - {0}".format(
"[x_x] Something went wrong at {0}, please check your error message.\n Message - {1}".format(
"_Config.export_tb_feedback", e
)
)
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import os
import json
from functools import wraps
from ._logger import logger
from flask import request
from ._utils import _Utils, _Validator
from ._template import _Template

from ._audit import _Audit
from ._config import _Config
from ._logger import logger
from ._protect import _Protect
from ._audit import _Audit
from datetime import datetime, timezone
from ._template import _Template
from ._utils import _Utils, _Validator


class _Gemini(object):
Expand Down
Loading