Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
Pure-python implementation of the MySQL server wire protocol.
This can be used to create applications that act as a MySQL server.
pip install mysql-mimic
A minimal use case might look like this:
import asyncio
from mysql_mimic import MysqlServer, Session
class MySession(Session):
async def query(self, expression, sql, attrs):
print(f"Parsed abstract syntax tree: {expression}")
print(f"Original SQL string: {sql}")
print(f"Query attributes: {sql}")
print(f"Currently authenticated user: {self.username}")
print(f"Currently selected database: {self.database}")
return [("a", 1), ("b", 2)], ["col1", "col2"]
async def schema(self):
# Optionally provide the database schema.
# This is used to serve INFORMATION_SCHEMA and SHOW queries.
return {
"table": {
"col1": "TEXT",
"col2": "INT",
}
}
if __name__ == "__main__":
server = MysqlServer(session_factory=MySession)
asyncio.run(server.serve_forever())
Using sqlglot, the abstract Session
class handles queries to metadata, variables, etc. that many MySQL clients expect.
To bypass this default behavior, you can implement the mysql_mimic.session.BaseSession
interface.
See examples for more examples.
MySQL-mimic has built in support for several standard MySQL authentication plugins:
mysql_mimic.auth.AbstractClearPasswordAuthPlugin
, which can be extended.By default, a session naively accepts whatever username the client provides.
Plugins are provided to the server by implementing mysql_mimic.IdentityProvider
, which configures all available plugins and a callback for fetching users.
Custom plugins can be created by extending mysql_mimic.auth.AuthPlugin
.
You can install dependencies with make deps
.
You can format your code with make format
.
You can lint with make lint
.
You can check type annotations with make types
.
You can run tests with make test
. This will build a coverage report in ./htmlcov/index.html
.
You can run all the checks with make check
.
You can build a pip package with make build
.
FAQs
A python implementation of the mysql server protocol
We found that mysql-mimic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.