Skip to content

Commit

Permalink
[frontend] improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Nov 13, 2024
1 parent a3cb613 commit 5050046
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,21 @@ export const getPlaybookDefinition = async (context: AuthContext, playbook: Basi
};

const checkPlaybookFiltersAndBuildConfigWithCorrectFilters = (input: PlaybookAddNodeInput) => {
if (!input.configuration) {
return '{}';
}
let stringifiedFilters;
if (input.configuration) {
const config = JSON.parse(input.configuration);
if (config.filters) {
const filterGroup = JSON.parse(config.filters) as FilterGroup;
if (input.component_id === PLAYBOOK_INTERNAL_DATA_CRON.id) {
stringifiedFilters = JSON.stringify(checkAndConvertFilters(filterGroup));
} else { // our stix matching is currently limited, we need to validate the input filters
validateFilterGroupForStixMatch(filterGroup);
stringifiedFilters = config.filters;
}
const config = JSON.parse(input.configuration);
if (config.filters) {
const filterGroup = JSON.parse(config.filters) as FilterGroup;
if (input.component_id === PLAYBOOK_INTERNAL_DATA_CRON.id) {
stringifiedFilters = JSON.stringify(checkAndConvertFilters(filterGroup));
} else { // our stix matching is currently limited, we need to validate the input filters
validateFilterGroupForStixMatch(filterGroup);
stringifiedFilters = config.filters;
}
}
return input.configuration ? JSON.stringify({ ...JSON.parse(input.configuration), filters: stringifiedFilters }) : '{}';
return JSON.stringify({ ...config, filters: stringifiedFilters });
};

export const playbookAddNode = async (context: AuthContext, user: AuthUser, id: string, input: PlaybookAddNodeInput) => {
Expand Down

0 comments on commit 5050046

Please sign in to comment.