
Security News
TC39 Advances Temporal to Stage 4 Alongside Several ECMAScript Proposals
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.
cmagic
Advanced tools
.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg :target: https://saythanks.io/to/me@mosquito.su
.. image:: https://github.com/mosquito/cmagic/workflows/tox/badge.svg :target: https://github.com/mosquito/cmagic/actions?query=workflow%3Atox :alt: Github Actions
.. image:: https://img.shields.io/pypi/v/cmagic.svg :target: https://pypi.python.org/pypi/cmagic/ :alt: Latest Version
.. image:: https://img.shields.io/pypi/wheel/cmagic.svg :target: https://pypi.python.org/pypi/cmagic/
.. image:: https://img.shields.io/pypi/pyversions/cmagic.svg :target: https://pypi.python.org/pypi/cmagic/
.. image:: https://img.shields.io/pypi/l/cmagic.svg :target: https://pypi.python.org/pypi/cmagic/
Python wrapper for libmagic.
.. code-block::
$ export MAGIC=/usr/local/Cellar/libmagic/5.39/share/misc/magic.mgc
$ export MAGIC=/usr/lib/file/magic.mgc
.. code-block:: python
import cmagic
m = cmagic.Magic()
if m.check(): print("Database is ok")
m.load()
m.guess_file("/etc/hosts")
m.guess_bytes("hello world")
m.set_flags(mime_type=True)
m = cmagic.Magic( # Setting flags here mime_type=True )
m.load(cmagic.find_db())
m.guess_file("/etc/hosts")
m.guess_bytes("hello world")
asyncio example +++++++++++++++
.. code-block:: python
import asyncio import cmagic from threading import local
magic_tls = local()
def get_instance(): global magic_tls
if not hasattr(magic_tls, "instance"):
m = cmagic.Magic(mime_type=True)
m.load(cmagic.find_db())
magic_tls.instance = m
return magic_tls.instance
async def guess_file(fname): loop = asyncio.get_event_loop()
def run():
m = get_instance()
return m.guess_file(fname)
return await loop.run_in_executor(None, run)
async def guess_bytes(payload): loop = asyncio.get_event_loop()
def run():
m = get_instance()
return m.guess_bytes(payload)
return await loop.run_in_executor(None, run)
if name == "main": print(asyncio.run(guess_file("/etc/hosts"))) # text/plain print(asyncio.run(guess_bytes(b"\0\0\0\0\0\0\0"))) # application/octet-stream
Ubuntu/Debian +++++++++++++
.. code-block:: bash
apt-get install -y libmagic1 libmagic-mgc # when using manilinux wheel apt-get install -y libmagic-dev # for building from sources python3 -m pip install cmagic
Centos ++++++
.. code-block:: bash
yum install -y file-libs # when using manilinux wheel yum install -y file-devel # for building from sources python3 -m pip install cmagic
MacOS +++++
.. code-block:: bash
brew install libmagic export CFLAGS="-I$(brew --prefix libmagic)/include" LDFLAGS="-L$(brew --prefix libmagic)/lib" python3 -m pip install cmagic
FAQs
Python wrapper for libmagic
We found that cmagic 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
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.

Research
/Security News
Since January 31, 2026, we identified at least 72 additional malicious Open VSX extensions, including transitive GlassWorm loader extensions targeting developers.

Research
Six malicious Packagist packages posing as OphimCMS themes contain trojanized jQuery that exfiltrates URLs, injects ads, and loads FUNNULL-linked redirects.