Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ziirish committed Mar 19, 2023
1 parent b23a107 commit 7f2832d
Show file tree
Hide file tree
Showing 81 changed files with 389 additions and 386 deletions.
7 changes: 4 additions & 3 deletions burpui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"""
import os
import sys

from argparse import ArgumentParser, REMAINDER
from argparse import REMAINDER, ArgumentParser

ROOT = os.path.dirname(os.path.realpath(__file__))
# Try to load modules from our current env first
Expand Down Expand Up @@ -79,7 +78,7 @@ def parse_args(mode=True, name=None):
unknown = []

if options.version:
from burpui.desc import __title__, __version__, __release__
from burpui.desc import __release__, __title__, __version__

ver = "{}: v{}".format(mname or __title__, __version__)
if options.log:
Expand Down Expand Up @@ -153,6 +152,7 @@ def server(options=None, unknown=None):

def agent(options=None):
import trio

from burpui.engines.agent import BUIAgent as Agent
from burpui.utils import lookup_file

Expand All @@ -172,6 +172,7 @@ def agent(options=None):

def monitor(options=None):
import trio

from burpui.engines.monitor import MonitorPool
from burpui.utils import lookup_file

Expand Down
3 changes: 1 addition & 2 deletions burpui/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"""
import pickle # noqa

from urllib.parse import unquote, quote, urlparse, urljoin # noqa
from urllib.parse import quote, unquote, urljoin, urlparse # noqa

text_type = str
string_types = (str,)
Expand Down
14 changes: 7 additions & 7 deletions burpui/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
"""
import hashlib
import os
import sys
import uuid
import hashlib
from functools import wraps
from importlib import import_module

from flask import Blueprint, Response, request, current_app, session, abort, g
from flask_restx import Api as ApiPlus
from flask import Blueprint, Response, abort, current_app, g, request, session
from flask_login import current_user
from importlib import import_module
from functools import wraps
from flask_restx import Api as ApiPlus

from .._compat import to_bytes
from ..desc import __version__, __release__, __url__, __doc__
from ..config import config
from ..desc import __doc__, __release__, __url__, __version__
from ..engines.server import BUIServer # noqa
from ..exceptions import BUIserverException
from ..config import config
from ..tools.logging import logger

bui = current_app # type: BUIServer
Expand Down
17 changes: 9 additions & 8 deletions burpui/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
.. moduleauthor:: Ziirish <hi+burpui@ziirish.me>
"""
from . import api
import json

from flask import current_app
from flask_babel import gettext
from flask_login import current_user

from ..engines.server import BUIServer # noqa
from ..sessions import session_manager
from ..misc.acl.meta import meta_grants
from ..sessions import session_manager
from ..utils import NOTIF_OK
from .custom import fields, Resource
from . import api
from .custom import Resource, fields

# from ..exceptions import BUIserverException

from flask import current_app
from flask_login import current_user
from flask_babel import gettext

import json

bui = current_app # type: BUIServer
ns = api.namespace("admin", "Admin methods")
Expand Down
10 changes: 5 additions & 5 deletions burpui/api/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
.. moduleauthor:: Ziirish <hi+burpui@ziirish.me>
"""
from . import api
from ..engines.server import BUIServer # noqa
from .custom import Resource
from ..exceptions import BUIserverException

from flask import current_app
from flask_login import current_user

from ..engines.server import BUIServer # noqa
from ..exceptions import BUIserverException
from . import api
from .custom import Resource

bui = current_app # type: BUIServer
ns = api.namespace("backup", "Backup methods")

Expand Down
18 changes: 9 additions & 9 deletions burpui/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import os
import re

from . import api, cache_key, force_refresh
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from ..decorators import browser_cache
from ..ext.cache import cache
from ..exceptions import BUIserverException

from flask_restx.marshalling import marshal
from flask_restx import inputs
from flask import current_app, request
from flask_login import current_user
from flask_restx import inputs
from flask_restx.marshalling import marshal

from ..decorators import browser_cache
from ..engines.server import BUIServer # noqa
from ..exceptions import BUIserverException
from ..ext.cache import cache
from . import api, cache_key, force_refresh
from .custom import Resource, fields

bui = current_app # type: BUIServer
ns = api.namespace("client", "Client methods")
Expand Down
20 changes: 10 additions & 10 deletions burpui/api/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
.. moduleauthor:: Ziirish <hi+burpui@ziirish.me>
"""
from . import api, cache_key, force_refresh
from flask import current_app, g
from flask_login import current_user

from ..decorators import browser_cache
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from .client import ClientLabels
from ..ext.cache import cache
from ..exceptions import BUIserverException
from ..decorators import browser_cache
from ..ext.cache import cache
from ..filter import mask

from flask import current_app, g
from flask_login import current_user
from . import api, cache_key, force_refresh
from .client import ClientLabels
from .custom import Resource, fields

bui = current_app # type: BUIServer
ns = api.namespace("clients", "Clients methods")
Expand Down Expand Up @@ -229,7 +229,7 @@ def _is_one_backup_running(self, res, server):
res = [x for x in res if x in allowed]
running = False
if isinstance(res, dict):
for (_, run) in res.items():
for _, run in res.items():
running = running or (len(run) > 0)
if running:
break
Expand Down Expand Up @@ -776,7 +776,7 @@ def get(self, server=None):
else:
for serv in bui.client.servers:
grants[serv] = "all"
for (serv, clients) in grants.items():
for serv, clients in grants.items():
if not isinstance(clients, list):
clients = clients_cache.get(serv, [])
ret += [{"name": x, "agent": serv} for x in clients]
Expand Down
10 changes: 5 additions & 5 deletions burpui/api/custom/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"""
import flask_restx.fields

from flask_restx.fields import * # noqa # pylint: disable=locally-disabled, wildcard-import, unused-wildcard-import

from .my_fields import (
DateTime,
DateTimeHuman,
BackupNumber,
SafeString,
DateTime,
DateTimeHuman, # noqa
LocalizedString,
) # noqa
SafeString,
)

__all__ = flask_restx.fields.__all__ + (
DateTime,
Expand Down
10 changes: 5 additions & 5 deletions burpui/api/custom/my_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"""
import datetime
import arrow

from ...ext.i18n import get_locale

from flask_restx import fields
from flask_babel import gettext as _
import arrow
from flask import escape
from flask_babel import gettext as _
from flask_restx import fields
from tzlocal import get_localzone

from ...ext.i18n import get_locale

TZ = str(get_localzone())


Expand Down
34 changes: 17 additions & 17 deletions burpui/api/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
.. moduleauthor:: Ziirish <hi+burpui@ziirish.me>
"""
from . import api, cache_key, force_refresh
import random
import re

from flask import current_app, flash, get_flashed_messages, session, url_for
from flask_login import current_user

from ..decorators import browser_cache
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from .client import ClientLabels
from ..filter import mask
from ..exceptions import BUIserverException
from ..decorators import browser_cache
from ..ext.cache import cache
from ..ext.i18n import LANGUAGES

from flask import flash, get_flashed_messages, url_for, current_app, session
from flask_login import current_user

import random
import re
from ..filter import mask
from . import api, cache_key, force_refresh
from .client import ClientLabels
from .custom import Resource, fields

bui = current_app # type: BUIServer
ns = api.namespace("misc", "Misc methods")
Expand Down Expand Up @@ -213,7 +213,7 @@ def get(self, server=None, client=None):
)
else:
found = False
for (_, cls) in running.items():
for _, cls in running.items():
if client in cls:
found = True
break
Expand Down Expand Up @@ -346,7 +346,7 @@ def get(self, server=None):
else:
running = bui.client.is_one_backup_running()
if isinstance(running, dict):
for (serv, clients) in running.items():
for serv, clients in running.items():
for client in clients:
# ACL
if mask.has_filters(current_user) and not mask.is_client_allowed(
Expand Down Expand Up @@ -533,15 +533,15 @@ def get(self, server=None):
srv = bui.client.get_server_version(server)
multi = {}
if isinstance(cli, dict):
for (name, val) in cli.items():
for name, val in cli.items():
multi[name] = {"client": val}
if isinstance(srv, dict):
for (name, val) in srv.items():
for name, val in srv.items():
multi[name]["server"] = val
if not multi:
res["burp"].append({"client": cli, "server": srv})
else:
for (name, val) in multi.items():
for name, val in multi.items():
tmp = val
tmp.update({"name": name})
res["burp"].append(tmp)
Expand Down Expand Up @@ -841,7 +841,7 @@ def _get_backup_history(self, client=None, server=None, data=None):
]
else:
grants[serv] = "all"
for (serv, clients) in grants.items():
for serv, clients in grants.items():
if not isinstance(clients, list):
if data and serv in data:
clients = data[serv].keys()
Expand Down
6 changes: 3 additions & 3 deletions burpui/api/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
.. moduleauthor:: Ziirish <hi+burpui@ziirish.me>
"""
from flask import session, current_app, request
from flask import current_app, request, session
from flask_login import current_user
from werkzeug.datastructures import MultiDict

from . import api
from ..engines.server import BUIServer # noqa
from ..ext.i18n import LANGUAGES
from .custom import fields, Resource
from . import api
from .custom import Resource, fields

bui = current_app # type: BUIServer
ns = api.namespace("preferences", "Preferences methods")
Expand Down
16 changes: 8 additions & 8 deletions burpui/api/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
"""
import select
import struct

from . import api
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from ..exceptions import BUIserverException

from zlib import adler32
from time import gmtime, strftime, time
from flask import Response, send_file, make_response, after_this_request, current_app
from zlib import adler32

from flask import Response, after_this_request, current_app, make_response, send_file
from flask_login import current_user
from flask_restx import inputs
from werkzeug.datastructures import Headers
from werkzeug.exceptions import HTTPException

from ..engines.server import BUIServer # noqa
from ..exceptions import BUIserverException
from . import api
from .custom import Resource, fields

bui = current_app # type: BUIServer
ns = api.namespace("restore", "Restore methods")

Expand Down
16 changes: 8 additions & 8 deletions burpui/api/servers.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# -*- coding: utf8 -*-

# This is a submodule we can also use "from ..api import api"
from . import api, cache_key, force_refresh
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from ..filter import mask
from ..ext.cache import cache
from ..decorators import browser_cache
from ..exceptions import BUIserverException

from flask import current_app, g
from flask_login import current_user

from ..decorators import browser_cache
from ..engines.server import BUIServer # noqa
from ..exceptions import BUIserverException
from ..ext.cache import cache
from ..filter import mask
from . import api, cache_key, force_refresh
from .custom import Resource, fields

bui = current_app # type: BUIServer
ns = api.namespace("servers", "Servers methods")

Expand Down
Loading

0 comments on commit 7f2832d

Please sign in to comment.