guardicore / monkey

Infection Monkey - An open-source adversary emulation platform
https://www.guardicore.com/infectionmonkey/
GNU General Public License v3.0
6.67k stars 784 forks source link

Write a custom widget for comma separated input field #3886

Open ilija-lazoroski opened 11 months ago

ilija-lazoroski commented 11 months ago

Is your feature request related to a problem? Please describe. We need a custom widget that will be used in a schema for Data Exfiltration payload. That widget should be a comma separated input field that will be used as file extension option in the payload. We need it in order to provide an option to set which file extensions will be selected during Data Exfiltration.

Describe the solution you'd like I have found a pretty cool sandbox that will kind of do that. From the sandbox we can see that if we enter .exe, it will make it is own badge.

image

Describe alternatives you've considered Maybe something better then this.

The actual component code from the sandbox:

/* eslint-disable no-use-before-define */
import React from "react";
import Autocomplete from "@material-ui/lab/Autocomplete";
import TextField from "@material-ui/core/TextField";

export default function Tags() {
  const [value, setValue] = React.useState([]);
  const [inputValue, setInputValue] = React.useState("");

  return (
    <Autocomplete
      multiple
      freeSolo
      id="tags-standard"
      options={["Option 1"]}
      value={value}
      inputValue={inputValue}
      onChange={(event, newValue) => {
        setValue(newValue);
      }}
      onInputChange={(event, newInputValue) => {
        const options = newInputValue.split(",");

        if (options.length > 1) {
          setValue(
            value
              .concat(options)
              .map(x => x.trim())
              .filter(x => x)
          );
        } else {
          setInputValue(newInputValue);
        }
      }}
      renderInput={params => (
        <TextField
          {...params}
          label="Automatic tokenization"
          placeholder="Use , as a delimiter"
        />
      )}
    />
  );
}

Tasks

VakarisZ commented 11 months ago

We need to decide if we want to use this component for all our string lists. The downside is that this UI component doesn't prioritize, so for lists where priority matters it doesn't fit.

An alternative is to create a UI component library for plugin configuration: #3887