Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing pipeline must be merged with another one. #62

Open
Koirin3224 opened this issue May 23, 2024 · 1 comment
Open

Processing pipeline must be merged with another one. #62

Koirin3224 opened this issue May 23, 2024 · 1 comment

Comments

@Koirin3224
Copy link

Hello! So, I'm fairly new with SIGMA-rules and PySigma, but slowly getting there.
I want to generate some Elasticsearch queries for the API, based on some SIGMA-rules I have generated.
With PySigma I am using the "elasticsearch" backend, and I have made my own, though very simple, pipeline for field-mapping.
When using one of my generated rules, and the pipeline on the website https://sigconverter.io/, I am able to generate a query I can use.

But right now, I am having trouble with the PySigma module, as I get the following error:
TypeError: Processing pipeline must be merged with another one.

Do I have to use two different pipelines for the queries to be generated properly? Or what exactly does this mean?

@andurin
Copy link
Collaborator

andurin commented May 24, 2024

Hi,

it's a bit hard to tell where the problem may be, without some sample code.
From my past experiences with pipelines the following code may work:

Hint: the ecs_windows pipeline comes from https://github.com/SigmaHQ/pySigma-backend-elasticsearch/blob/main/sigma/pipelines/elasticsearch/windows.py#L59. But I guess you get the point.

from sigma.backends.elasticsearch.elasticsearch_lucene import LuceneBackend
from sigma.pipelines.elasticsearch.windows import ecs_windows  #, ecs_windows_old
from sigma.collection import SigmaCollection
from sigma.processing.resolver import ProcessingPipelineResolver

sigma_rule_yaml = """
    title: Test
    status: test
    logsource:
        category: test_category
        product: windows
    detection:
        selection:
            ipfield: 192.168.1.1
        condition: selection
"""

piperesolver = ProcessingPipelineResolver()
piperesolver.add_pipeline_class(ecs_windows())

resolved_pipeline = piperesolver.resolve(piperesolver.pipelines)

backend = LuceneBackend(resolved_pipeline)
rules = SigmaCollection.from_yaml(sigma_rule_yaml)
print("Result: \n" + "\n".join(backend.convert(rules)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants