Skip to content

Commit

Permalink
Update generated graph drawing and add map of allowed keys for condit…
Browse files Browse the repository at this point in the history
…ional edges
  • Loading branch information
P1llus committed Dec 2, 2024
1 parent f6c400e commit ab7c000
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export function getRuleMigrationAgent({
.addNode('translationSubGraph', translationSubGraph)
// Edges
.addEdge(START, 'matchPrebuiltRule')
.addConditionalEdges('matchPrebuiltRule', matchedPrebuiltRuleConditional)
.addConditionalEdges(
'matchPrebuiltRule',
(state: MigrateRuleState) => matchedPrebuiltRuleConditional(state),
{ translate: 'translationSubGraph', end: END }
)
.addEdge('translationSubGraph', END);

const graph = siemMigrationAgentGraph.compile();
Expand All @@ -46,7 +50,7 @@ export function getRuleMigrationAgent({

const matchedPrebuiltRuleConditional = (state: MigrateRuleState) => {
if (state.elastic_rule?.prebuilt_rule_id) {
return END;
return 'end';
}
return 'translation';
return 'translate';
};
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function getTranslateRuleGraph({
.addEdge('retrieveIntegrations', 'translateRule')
.addEdge('translateRule', 'validation')
.addEdge('esql_errors', 'validation')
.addConditionalEdges('validation', (state: TranslateRuleState) => validationRouter({ state }), {
.addConditionalEdges('validation', (state: TranslateRuleState) => validationRouter(state), {
esql_error: 'esql_errors',
end: END,
});
Expand All @@ -69,7 +69,7 @@ export function getTranslateRuleGraph({
return graph;
}

const validationRouter = ({ state }: TranslateRuleState) => {
const validationRouter = (state: TranslateRuleState) => {
if (
state.validation_errors.iterations <= MAX_VALIDATION_ITERATIONS &&
state.translation_result === SiemMigrationRuleTranslationResult.FULL
Expand Down

0 comments on commit ab7c000

Please sign in to comment.