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. 😄

Notebooks for computing approximations to the prime counting function using Riemann's formula.

Notebooks for computing approximations to the prime counting function using Riemann's formula.

Tom White 2 Aug 02, 2022
Collection of tools to be more productive in your work environment and to avoid certain repetitive tasks. 💛💙💚

Collection of tools to be more productive in your work environment and to avoid certain repetitive tasks. 💛💙💚

Raja Rakotonirina 2 Jan 10, 2022
The most widely used Python to C compiler

Welcome to Cython! Cython is a language that makes writing C extensions for Python as easy as Python itself. Cython is based on Pyrex, but supports mo

7.6k Jan 03, 2023
The presented desktop application was made to solve 1d schrodinger eqation

schrodinger_equation_1d_solver The presented desktop application was made to solve 1d schrodinger eqation. It implements Numerov's algorithm (step by

Artem Kashapov 2 Dec 29, 2021
Blender addon for executing the operator in response to the received OSC message.

I/F Joiner 受信したOSCメッセージに応じてオペレータ(bpy.ops)を実行するアドオンです. OSC通信に対応したコントローラやアプリをインストールしたスマートフォンを使用してBlenderを操作することが可能になります. 同時開発しているAndroidコントローラ化アプリMocopa

simasimataiyo 6 Oct 02, 2022
Яндекс тренировки по алгоритмам. Июнь 2021

Young&&Yandex Тренировки по алгоритмам Если вы хотите попасть на летнюю стажировку в Яндекс, но пока не уверены в своих силах, приходите на наши трени

Podlevskiy Viktor 6 Sep 03, 2021
Consolemenu on python with pynput

ConsoleMenu Consolemenu on python 3 with pynput Powered by pynput and colorama Description Модуль позволяющий сделать меню выбора с помощью стрелок дл

KrouZ_CZ 2 Nov 15, 2021
Projects using the Tkinter module in Python!

Tkinter projects This repository includes some Tkinter projects made by me. All of these are simple to understand. I create apps with good functionali

Amey 0 Sep 24, 2021
A script that convert WiiU BotW mods to Switch

UltimateBoTWConverter A script that convert WiiU BotW mods to Switch. It uses every resource I could find under the sun that allows for conversion, wi

11 Nov 08, 2022
Skip spotify ads by automatically restarting application when ad comes

SpotiByeAds No one likes interruptions! Don't you hate it when you're listening to your favorite jazz track or your EDM playlist and an ad for Old Spi

Partho 287 Dec 29, 2022
SQL centered, docker process running game

REQUIREMENTS Linux Docker Python/bash set up image "docker build -t game ." create db container "run my_whatever/game_docker/pdb create" # creating po

1 Jan 11, 2022
Your E-Canteen that is convenient and accessible wherever you are in the campus

Food Web E-Canteen System Your E-Canteen that is convenient and accessible wherever you are in the campus. Table of Contents About The Project Contrib

Pudding 5 Jan 07, 2023
Functional interface for concurrent futures, including asynchronous I/O.

Futured provides a consistent interface for concurrent functional programming in Python. It wraps any callable to return a concurrent.futures.Future,

A. Coady 11 Nov 27, 2022
用于导出墨墨背单词的词库,并生成适用于 List 背单词,不背单词,欧陆词典等的自定义词库

maimemo-export 用于导出墨墨背单词的词库,并生成适用于 List 背单词,欧陆词典,不背单词等的自定义词库。 仓库内已经导出墨墨背单词所有自带词库(暂不包括云词库),多达 900 种词库,可以在仓库中选择需要的词库下载(下载单个文件的方法),也可以去 蓝奏云(密码:666) 下载打包好

ourongxing 293 Dec 29, 2022
Reso is a low-level circuit design language and simulator, inspired by things like Redstone, Conway's Game of Life, and Wireworld.

Reso Reso is a low-level circuit design language and simulator, inspired by things like Redstone, Conway's Game of Life, and Wireworld. What is Reso?

Lynn 287 Nov 26, 2022
Fabric mod where anyone can PR anything, concerning or not. I'll merge everything as soon as it works.

Guess What Will Happen In This Fabric mod where anyone can PR anything, concerning or not (Unless it's too concerning). I'll merge everything as soon

anatom 65 Dec 25, 2022
Source code for Learn Programming: Python

This repository contains the source code of the game engine behind Learn Programming: Python. The two key files are game.py (the main source of the ga

Niema Moshiri 25 Apr 24, 2022
FollowSpot is a comprehensive audition tracking fullstack web application for entertainment industry professionals.

FollowSpot is a comprehensive audition tracking fullstack web application for entertainment industry professionals. This app allows users to store information/media for all of their auditions while a

Jen Brissman 9 Jul 12, 2022
A simple app that helps to train quick calculations.

qtcounter A simple app that helps to train quick calculations. Usage Manual Clone the repo in a folder using git clone https://github.com/Froloket64/q

0 Nov 27, 2021
Simple project to learn more about Bézier curves

Python Quadratic Bézier Simple project to learn more about Bézier curves. On this project i used some api's to graphics and gui pygame thorpy in theor

Kenned Ferreira 2 Mar 06, 2022