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

Added CIDR modifier for detection fields #693

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const detectionModifierOptions = [
{ value: 'base64', label: 'base64' },
{ value: 'endswith', label: 'endswith' },
{ value: 'startswith', label: 'startswith' },
{ value: 'cidr', label: 'cidr' },
];

const defaultDetectionObj: DetectionObject = {
Expand Down Expand Up @@ -177,24 +178,28 @@ export class DetectionVisualEditor extends React.Component<
const selectionMapJSON = detectionJSON[selectionKey];
const selectionDataEntries: SelectionData[] = [];

Object.keys(selectionMapJSON).forEach((fieldKey, dataIdx) => {
const [field, modifier] = fieldKey.split('|');
const val = selectionMapJSON[fieldKey];
const values: any[] = typeof val === 'string' ? [val] : val;
selectionDataEntries.push({
field,
modifier,
values,
selectedRadioId: `${
values.length <= 1 ? SelectionMapValueRadioId.VALUE : SelectionMapValueRadioId.LIST
}-${selectionIdx}-${dataIdx}`,
if (typeof selectionMapJSON === 'object') {
Object.keys(selectionMapJSON).forEach((fieldKey, dataIdx) => {
const [field, modifier] = fieldKey.split('|');
const val = selectionMapJSON[fieldKey];
const values: any[] = Array.isArray(val) ? val : [val];
selectionDataEntries.push({
field,
modifier,
values,
selectedRadioId: `${
values.length <= 1 ? SelectionMapValueRadioId.VALUE : SelectionMapValueRadioId.LIST
}-${selectionIdx}-${dataIdx}`,
});
});
});
}

detectionObj.selections.push({
name: selectionKey,
data: selectionDataEntries,
});
if (selectionDataEntries.length) {
detectionObj.selections.push({
name: selectionKey,
data: selectionDataEntries,
});
}
});

return detectionObj;
Expand Down
Loading