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

feat: add multi pipeline yml #32

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,34 @@ def convert():
for p in request.json["pipeline"]:
pipeline.append(p)

template_pipeline = ""
custom_pipelines_list = []
if request.json["pipelineYml"]:
try:
template = str(base64.b64decode(request.json["pipelineYml"]), "utf-8")
template_pipeline = pipeline_generic.from_yaml(template)
except:
return Response(
f"YamlError: Malformed Pipeline Yaml", status=400, mimetype="text/html"
)
pipelineYml = str(base64.b64decode(request.json["pipelineYml"]), "utf-8")
pipelineYml_list = pipelineYml.split("\n---")
for pipeline_ in pipelineYml_list:
try:
custom_pipelines_list.append(pipeline_generic.from_yaml(pipeline_))
except:
return Response(
f"YamlError: Malformed Pipeline Yaml", status=400, mimetype="text/html"
)

target = request.json["target"]
format = request.json["format"]

backend_class = backends[target]
processing_pipeline = pipeline_resolver.resolve(pipeline)
try:
backend_class = backends[target]
except:
return Response(f"Unknown Backend", status=400, mimetype="text/html")

try:
processing_pipeline = pipeline_resolver.resolve(pipeline)
except:
return Response(f"Unknown Builtin Pipeline", status=400, mimetype="text/html")

if isinstance(template_pipeline, ProcessingPipeline):
processing_pipeline += template_pipeline
else:
print("no processing pipeline")
for pipeline_ in custom_pipelines_list:
if isinstance(pipeline_, ProcessingPipeline):
processing_pipeline += pipeline_

backend: Backend = backend_class(processing_pipeline=processing_pipeline)

Expand All @@ -96,6 +104,8 @@ def convert():
result = result[0]
except SigmaError as e:
return Response(f"SigmaError: {str(e)}", status=400, mimetype="text/html")
except:
return Response(f"UnknownError: {str(e)}", status=400, mimetype="text/html")

return result

Expand Down