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

Linux GUI app to codon optimize many single-fasta files with coding sequences , using many taxonomy ids

codon_optimize_cds_with_many_taxids_singlefasta Linux GUI app to codon optimize many single-fasta files with coding sequences, using many taxonomy ids

Olga Tsiouri 1 Jan 23, 2022
One destination for all the developer's learning resources.

DevResources One destination for all the developer's learning resources. Find all of your learning resources under one roof and add your own. Live ✨ Y

Gaurav Sharma 33 Oct 21, 2022
Python library for ODE integration via Taylor's method and LLVM

heyoka.py Modern Taylor's method via just-in-time compilation Explore the docs » Report bug · Request feature · Discuss The heyókȟa [...] is a kind of

Francesco Biscani 45 Dec 21, 2022
Displays Christmas-themed ASCII art

Christmas Color Scripts Displays Christmas-themed ASCII art. This was mainly inspired by DistroTube's Shell Color Scripts Screenshots ASCII Shadow Tex

1 Aug 09, 2022
Python script for diving image data to train test and val

dataset-division-to-train-val-test-python python script for dividing image data to train test and val If you have an image dataset in the following st

Muhammad Zeeshan 1 Nov 14, 2022
PIP VA TASHQI KUTUBXONALAR

39-dars PIP VA TASHQI KUTUBXONALAR KIRISH Avvalgi darsimizda Python bilan birga o'rnatluvchi, standart kutubxona va undagi ba'zi foydali modullar bila

Sayfiddin 3 Nov 25, 2021
Script to produce `.tex` files of example GAP sessions

Introduction The main file GapToTex.py in this directory is used to produce .tex files of example GAP sessions. Instructions Run python GapToTex.py [G

Friedrich Rober 2 Oct 06, 2022
Exploiting Linksys WRT54G using a vulnerability I found.

Exploiting Linksys WRT54G Exploit # Install the requirements. pip install -r requirements.txt ROUTER_HOST=192.169.1.1 ROUTER_USERNAME=admin ROUTER_P

Elon Gliksberg 31 May 29, 2022
Performance data for WASM SIMD instructions.

WASM SIMD Data This repository contains code and data which can be used to generate a JSON file containing information about the WASM SIMD proposal. F

Evan Nemerson 5 Jul 24, 2022
Pokehandy - Data web app sobre Pokémon TCG que desarrollo durante transmisiones de Twitch, 2022

⚡️ Pokéhandy – Pokémon Hand Simulator [WIP 🚧 ] This application aims to simulat

Rodolfo Ferro 5 Feb 23, 2022
Submission to the HEAR2021 Challenge

Submission to the HEAR 2021 Challenge For model evaluation, python=3.8 and cuda10.2 with cudnn7.6.5 have been tested. The work uses a mixed supervised

Heinrich Dinkel 10 Dec 08, 2022
In this project, we'll be creating a virtual personal assistant for ourselves using our favorite programming language

In this project, we'll be creating a virtual personal assistant for ourselves using our favorite programming language, Python. We can perform several offline as well as online operations using the bo

Ashutosh Krishna 188 Jan 03, 2023
The Python Fuzzer that the world deserves 🐍

pip3 install frelatage Current release : 0.0.2 The Python Fuzzer that the world deserves Installation | How it works | Features | Use Frelatage | Conf

Rog3r 219 Dec 21, 2022
Py-Parser est un parser de code python en python encore en plien dévlopement.

PY - PARSER Py-Parser est un parser de code python en python encore en plien dévlopement. Une fois achevé, il servira a de nombreux projets comme glad

pf4 3 Feb 21, 2022
A simple, light-weight and highly maintainable online judge system for secondary education

y³OJ a simple, light-weight and highly maintainable online judge system for secondary education 一个简单、轻量化、易于维护的、为中学信息技术学科课业教学设计的 Online Judge 系统。 Onlin

20 Oct 04, 2022
Final Fantasy XIV Auto House Clicker

Final Fantasy XIV Auto House Clicker

KanameS 0 Mar 31, 2022
The worst and slowest programming language you have ever seen

VenumLang this is a complete joke EXAMPLE: fizzbuzz in venumlang x = 0

Venum 7 Mar 12, 2022
A Python Web Application for Checking vaccine slots by pincodes and auto slot booking.

The Dashboard is developed using Bokeh and python 3.5+. This dashboard is useful for you if you are looking for something which will help you to book the vaccine slot once slots become available. Oth

Suraj Deshmukh 10 Jan 23, 2022
TikTok Auto Claimer Made By Aim low!#9999 Leaked By bazooka#0001

Zues Auto Claimer Leaked By bazooka#0001 put proxies in prox.txt put ssid in sid.txt put all users you want to target in user.txt for the login just t

1 Jan 14, 2022
📙 Super lightweight function registries for your library

catalogue: Super lightweight function registries for your library catalogue is a tiny, zero-dependencies library that makes it easy to add function (o

Explosion 139 Jan 02, 2023