This library attempts to abstract the handling of Sigma rules in Python

Overview

Python Sigma Rule Parsing Library

This library attempts to abstract the handling of Sigma rules in Python. The rules are parsed using a schema defined with pydantic, and can be easily loaded from YAML files into a structured Python object.

from sigma.schema import Rule

# Load a rule into a python object
rule = Rule.from_yaml("test-rule.yml")

# Simple properties are accessible directly
print(rule.title)
print(rule.author)

# Detection conditions are also available unchanged
print(rule.detection.condition)
print(rule.detection.my_condition_name)

# Parsed/unified grammar from the condition is easy!
print(rule.detection.expression)

This project is under active development, and this readme may or may not reflect the most up-to-date documentation. In general, you should refer to the generated documentation (instructions for building below) and the command-line help output for details until the library/tools reach a stable state.

Installation

The library and command line interface can be installed using pip from github with:

# Install directly from github
pip install git+ssh://[email protected]/calebstewart/python-sigma.git

# Checkout the repo, then install
git clone [email protected]:calebstewart/python-sigma.git
cd python-sigma
pip install .

If you would like to participate in development, you should use Python Poetry to manage your virtual environment and dependencies. For more information see the Poetry documentation.

# Setup Python development environment
git clone [email protected]:calebstewart/python-sigma.git
cd python-sigma
poetry install

# Enter the virtual environment to interact with the package
poetry shell

# Type "exit" to leave the poetry virtual environment

Documentation

Documentation can be built using Sphinx from this repository. First, install the package with the documentation dependencies, then run make html from the docs/ directory:

# Install with the docs extras
poetry install -E docs

# Enter the poetry virtual environment
poetry shell

# Build the documentation
cd docs
make html

# Open the documentation in docs/_build/index.html

At this time, documentation is built automatically from docstrings and type-hinting in the project code itself. The plan is to eventually augment this auto-generated documentation, but that is a project for later after the API and CLI interfaces solidify. That being said, extensive examples and documentation have been added where appropriate using module docstrings throughout the project, so the documentation should at least be usable.

Command Line Interface

There is a command line interface exposed by the entrpoint sigma which is installed with this package. The sigma command provides subcommands for inspecting rule and configuration schema, viewing/updating the MITRE ATT&CK database cache, validating serializer or rule configurations, and converting rules using built-in or custom serializers.

This project is still under active development, and the interface could change at any time. You should check the built-in help by running sigma --help at the command line, however for completeness sake, the current help output/list of subcommands is:

$ sigma --help
Usage: sigma [OPTIONS] COMMAND [ARGS]...

  Sigma Rule conversion and validation CLI.

Options:
  --help  Show this message and exit.

Commands:
  convert    Convert Sigma rules to various formats using built-in or...
  list       List built-in transforms and serializers
  mitre      Browse and update the MITRE ATT&CK data cache
  schema     Dump the schema for rules, serializers, and transforms
  transform  Transform a list of rules using a list of transforms in a...
  validate   Validate Sigma rule or serializer schema

But... why?

The official Sigma repository contains the sigmac tool for converting sigma rules from sigma format to a variety of backend detection systems. However, this tool has aged poorly. The code is messy and hard to follow and documentation is limited. It appears the Sigma team is attempting to replace sigmac with pySigma, but the project is pretty new, and I wanted something I could iterate on and have control over in the short term.

Also, the processing of sigma rules simply seems overly complex in both cases. This may be a "grass is greener" problem on my part, but the worst case for me doing this is that I better understand the problems inherent in building a Sigma rule API/converter, and can hopefully give back to the community in some way in the future.

Lastly, I wanted to build this tool with a focus on modern API interfaces and aggressive documentation. I plan to utilize pydantic heavily to make validation of fields and values more straightforward and pythonic as well as provide a simple interface for others to ingest Sigma rules directly. For example, being able to load, inspect and possibly modify sigma rules from Python without using the conversion tool would be a great feature for teams trying to work Sigma into their automation pipeline.

All that being said, I want to be abundantly clear: The sigma project and all the code associated with it have been immensely helpful, and the above is not meant to dig on the team, their code or their contributions to the community. I greatly appreciate and admire all the hard work the SigmaHQ team has put into making the detection of malicious activity better over the years. I only hope that I can either learn something or maybe provide something useful back to the community myself. 😄

Sequence clustering and database creation using mmseqs, from local fasta files

Sequence clustering and database creation using mmseqs, from local fasta files

Ana Julia Velez Rueda 3 Oct 27, 2022
Hacking and Learning consistently for 100 days straight af.

#100DaysOfHacking Hacking and Learning consistently for 100 days straight af. [yes, no breaks except mental-break ones, Obviously.] This Repo is one s

FENIL SHAH 17 Sep 09, 2022
Set named timers for cooking, watering plants, brewing tea and more.

Timer Set named timers for cooking, watering plants, brewing tea and more. About Use Mycroft when your hands are messy or you need more that the one t

OpenVoiceOS 3 Nov 02, 2022
Find virtual hosts (vhosts) from IP addresses and hostnames

Features Enumerate vhosts from a list of IP addresses and domain names. Virtual Hosts are enumerated using the following process: Supplied domains are

3 Jul 09, 2022
Prometheus exporter for chess.com player data

chess-exporter Prometheus exporter for chess.com player data implemented via chess.com's published data API and Prometheus Python Client Example use c

Mário Uhrík 7 Feb 28, 2022
A new mini-batch framework for optimal transport in deep generative models, deep domain adaptation, approximate Bayesian computation, color transfer, and gradient flow.

BoMb-OT Python3 implementation of the papers On Transportation of Mini-batches: A Hierarchical Approach and Improving Mini-batch Optimal Transport via

Khai Ba Nguyen 18 Nov 14, 2022
2021华为软件精英挑战赛 程序输出分析器

AutoGrader 0.2.0更新:加入资源分配溢出检测,如果发生资源溢出会输出溢出发生的位置。 如果通过检测,会显示通过符号 如果没有通过检测,会显示警告,并输出溢出发生的位置和操作

54 Aug 14, 2022
Modelling the 30 salamander problem from `Pure Mathematics` by Martin Liebeck

Salamanders on an island The Problem From A Concise Introduction to Pure Mathematics By Martin Liebeck Critic Ivor Smallbrain is watching the horror m

Faisal Jina 1 Jul 10, 2022
Generate PNG filles from NFO files.

Installation git clone https://github.com/pcroland/nfopng cd nfopng pip install -r requirements.txt Usage ❯ ./nfopng.py usage: nfopng.py [-h] [-v] [-i

4 Jun 26, 2022
A Lite Package focuses on making overwrite and mending functions easier and more flexible.

Overwrite Make Overwrite More flexible In Python A Lite Package focuses on making overwrite and mending functions easier and more flexible. Certain Me

2 Jun 15, 2022
Credit Card Fraud Detection

Credit Card Fraud Detection For this project, I used the datasets from the kaggle competition called IEEE-CIS Fraud Detection. The competition aims to

RayWu 4 Jun 21, 2022
Gaia: a chrome extension that curates environmental news of a company

Gaia - Gaia: Your Environment News Curator Call for Code 2021 Gaia: a chrome extension that curates environmental news of a company Explore the docs »

4 Mar 19, 2022
Projeto para ajudar no aprendizado da linguagem Pyhon

Economize Este projeto tem o intuito de criar desáfios para a codificação em Python, fazendo com que haja um maior entendimento da linguagem em seu to

Lucas Cunha Rodrigues 1 Dec 16, 2021
A Github Action for sending messages to a Matrix Room.

matrix-commit A Github Action for sending messages to a Matrix Room. Screenshot: Example Usage: # .github/workflows/matrix-commit.yml on: push:

3 Sep 11, 2022
A jokes python module

Made with Python3 (C) @FayasNoushad Copyright permission under MIT License License - https://github.com/FayasNoushad/Jokes/blob/main/LICENSE Deploy

Fayas Noushad 3 Nov 28, 2021
CoreSE - basic of social Engineering tool

Core Social Engineering basic of social Engineering tool. just for fun :) About First of all, I must say that I wrote such a project because of my int

Hamed Mohammadvand 7 Jun 10, 2022
Freeze your objects in python

gelidum Freeze your objects in python. Latin English Caelum est hieme frigidum et gelidum; myrtos oleas quaeque alia assiduo tepore laetantur, asperna

Diego J. 51 Dec 22, 2022
Python framework to build apps with the GASP metaphor

Gaspium Python framework to build apps with the GASP metaphor This project is part of the Pyrustic Open Ecosystem. Installation | Documentation | Late

5 Jan 01, 2023
A simple BrainF**k compiler written in Python

bf-comp A simple BrainF**k compiler written in Python. What else were you looking for?

1 Jan 09, 2022
A collection of simple tools that proved to be needed for hadling large periodic calculations with the VASP software package.

VESTA-tools A collection of simple tools that proved to be needed for handling large periodic calculations with the VASP software package. distTotCalc

Ilia Kichev 2 Dec 14, 2021