Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __new_oyente_analyzer(args="", storage_dir="/tmp", timeout_sec=60):
logger = getLogger("test")
oyente_wrapper = Wrapper(
wrappers_dir="{0}/analyzers/wrappers".format(project_root()),
analyzer_name="oyente",
args="-ce",
storage_dir=storage_dir,
timeout_sec=timeout_sec,
logger=logger,
)
return Analyzer(oyente_wrapper, logger)
import structlog
from libtaxii.constants import (
MSG_POLL_REQUEST, MSG_POLL_FULFILLMENT_REQUEST, SVC_POLL
)
from ..entities import ResultSetEntity
from .abstract import TAXIIService
from .handlers import PollRequestHandler, PollFulfilmentRequestHandler
log = structlog.getLogger(__name__)
DEFAULT_MAX_RESULT_SIZE = 1000000
DEFAULT_MAX_RESULT_COUNT = 10 * DEFAULT_MAX_RESULT_SIZE
class PollService(TAXIIService):
handlers = {
MSG_POLL_REQUEST: PollRequestHandler,
MSG_POLL_FULFILLMENT_REQUEST: PollFulfilmentRequestHandler
}
service_type = SVC_POLL
subscription_required = False
from asyncpg.connection import Connection
from pylru import WriteThroughCacheManager
from sqlalchemy.dialects.postgresql import JSONB
from yo.rpc_client import get_user_data
from ..schema import NOTIFICATION_TYPES
from ..schema import NotificationType
from yo.db import metadata
class UserNotFoundError(Exception):
pass
logger = structlog.getLogger(__name__, source='users')
PoolOrConn = TypeVar('PoolOrConn', Pool, Connection)
DEFAULT_SENTINEL = 'default_transports'
DEFAULT_USER_TRANSPORT_SETTINGS = {
"desktop": {
"notification_types": NOTIFICATION_TYPES,
"data": None
}
}
DEFAULT_USER_TRANSPORT_SETTINGS_STRING = ujson.dumps(DEFAULT_USER_TRANSPORT_SETTINGS)
CREATE_USER_STMT = '''INSERT INTO users(username,transports, created, updated) VALUES($1,$2,NOW(),NOW()) ON CONFLICT DO NOTHING RETURNING username'''
CREATE_USER_WITHOUT_TRANSPORTS_STMT = '''INSERT INTO users(username) VALUES($1) ON CONFLICT DO NOTHING RETURNING username'''
ACT_SUBSCRIBE, ACT_UNSUBSCRIBE, ACT_PAUSE,
ACT_RESUME, ACT_STATUS, ACT_TYPES_11,
ACT_TYPES_10
)
from ...exceptions import StatusMessageException, raise_failure
from ...converters import (
subscription_to_subscription_instance,
parse_content_bindings
)
from ...entities import PollRequestParametersEntity, SubscriptionEntity
from .base_handlers import BaseMessageHandler
from .poll_request_handlers import retrieve_collection
log = structlog.getLogger(__name__)
def action_subscribe(request, service, collection, version, **kwargs):
if version == 11:
params = request.subscription_parameters
response_type = params.response_type
if not params.content_bindings:
supported_contents = []
else:
requested_bindings = parse_content_bindings(
params.content_bindings,
version=version)
supported_contents = \
<a href="http://{host}:{port}/resetpassword?t={forgot_resp.token}&e={email}&u={forgot_resp.user}">\
http://{host}:{port}/resetpassword?t={forgot_resp.token}&e={email}&u={forgot_resp.user}</a>"
self.logger.info(f"forgot username link sent to {email}")
return flask.render_template("message.html", caption=caption, message=message)
class Confirmation(View):
"""
Route: /sendconfirmation
Users will be lead to this route when they submit an email for server sign up from route /
sendconfirmation() will check whether users posted data via a form.
It then checks that form data to make sure it's a valid UCC email.
Sends an email with a link to validate the email holder is who is registering.
"""
# Logger instance
logger = logging.getLogger("netsocadmin.sendconfirmation")
# Specify which method(s) are allowed to be used to access the route
methods = ["POST"]
def dispatch_request(self) -> str:
# make sure is ucc email
email = flask.request.form['email']
with sentry_sdk.configure_scope() as scope:
scope.user = {
"email": email,
}
if not re.match(r"[0-9]{8,11}@umail\.ucc\.ie", email) and not re.match(r"[a-zA-Z.0-9]+@uccsocieties.ie", email):
self.logger.info(f"email {email} is not a valid UCC email")
return flask.render_template(
"index.html",
from resumable_uploads.models import ResumableFile
from base.viewmixins import MenuItemMixin
from core.editor.models import IssueSubmission
from core.metrics.metric import metric
from core.editor.utils import get_archive_date
from ..viewmixins import JournalScopePermissionRequiredMixin
from .viewmixins import IssueSubmissionContextMixin
from .forms import IssueSubmissionForm
from .forms import IssueSubmissionTransitionCommentForm
from .forms import IssueSubmissionUploadForm
from .signals import userspace_post_transition
logger = structlog.getLogger(__name__)
class IssueSubmissionListView(
JournalScopePermissionRequiredMixin, MenuItemMixin, ListView):
menu_journal = 'editor'
model = IssueSubmission
template_name = 'userspace/journal/editor/issues.html'
def get_queryset(self):
qs = super(IssueSubmissionListView, self).get_queryset()
return qs.filter(journal=self.current_journal, archived=False)
def has_permission(self):
obj = self.get_permission_object()
return self.request.user.has_perm('editor.manage_issuesubmission', obj) \
or self.request.user.has_perm('editor.review_issuesubmission')
import structlog
import six
from sqlalchemy import func, and_, or_
from opentaxii.persistence import OpenTAXIIPersistenceAPI
from opentaxii.sqldb_helper import SQLAlchemyDB
from . import converters as conv
from .models import (
Base, Service, ResultSet, ContentBlock,
DataCollection, InboxMessage, Subscription)
__all__ = ['SQLDatabaseAPI']
log = structlog.getLogger(__name__)
YIELD_PER_SIZE = 100
class SQLDatabaseAPI(OpenTAXIIPersistenceAPI):
"""SQL database implementation of OpenTAXII Persistence API.
Implementation will work with any DB supported by SQLAlchemy package.
Note: this implementation ignores ``context.account`` and does not have
any access rules.
:param str db_connection: a string that indicates database dialect and
connection arguments that will be passed directly
to :func:`~sqlalchemy.engine.create_engine` method.
import argparse
import structlog
from opentaxii.cli import app
log = structlog.getLogger(__name__)
def create_account():
parser = argparse.ArgumentParser(
description="Create Account via OpenTAXII Auth API",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"-u", "--username", dest="username",
help="Username for the new account", required=True)
parser.add_argument(
"-p", "--password", dest="password",
help="Password for the new account", required=True)
from funcy import flatten
from ...db.notifications import create_notification
from ...db import create_asyncpg_pool
from .handlers import handle_vote
from .handlers import handle_account_update
from .handlers import handle_send
from .handlers import handle_receive
from .handlers import handle_follow
from .handlers import handle_resteem
from .handlers import handle_power_down
from .handlers import handle_mention
from .handlers import handle_comment
logger = structlog.getLogger(__name__,service_name='blockchain_follower')
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
logger = logger.bind()
EXECUTOR = ThreadPoolExecutor()
'''
{
"block": 20000000,
"op": [
"author_reward",
{
"author": "ivelina89",
"permlink": "friends-forever",
"sbd_payout": "2.865 SBD",
"steem_payout": "0.000 STEEM",
"vesting_payout": "1365.457442 VESTS"
}