This Python script is designed to facilitate asset deduplication using the Plextrac API. It identifies duplicate assets within a specific Plextrac client and updates associated findings to reference a primary asset for each group of duplicate assets. Below is an overview of the script functionality and usage instructions.
After installing Python, pip, and pipenv, run the following commands to setup the Python virtual environment.
git clone this_repo
cd path/to/cloned/repo
pipenv install
After setting up the Python environment the script will run in, you will need to setup a few things to configure the script before running.
In the config.yaml
file you should add the full URL to your instance of Plextrac.
The config also can store your username and password. Plextrac authentication lasts for 15 mins before requiring you to re-authenticate. The script is set up to do this automatically through the authentication handler. If these 3 values are set in the config, and MFA is not enabled for the user, the script will take those values and authenticate automatically, both initially and every 15 mins. If any value is not saved in the config, you will be prompted when the script is run and during re-authentication.
After setting everything up you can run the script with the following command. You should run the command from the folder where you cloned the repo.
pipenv run python main.py
You can also add values to the config.yaml
file to simplify providing the script with custom parameters needed to run.
The following values can either be added to the config.yaml
file or entered when prompted for when the script is run.
- PlexTrac Top Level Domain e.g. https://yourapp.plextrac.com
- Username
- Password
- Retrieve a list of clients from the Plextrac instance.
- Prompt the user to select a client for asset deduplication.
- Load assets for the selected client.
- Identify duplicate assets and group them together.
- Determine asset pair replacements needed to update associated findings.
- Update affected assets on finding records.
- Delete duplicate client assets no longer tied to any findings.
- Log the completion status and any failed operations.