Skip to content

Files

Latest commit

0b4a3d7 · Oct 10, 2023

History

History

bulk-delete

README.md

What is this tool for?


This tool allows you to delete projects in bulk within Snyk by specifying a set of organazations and types of projects to delete

Installation instructions


Clone this repo and run

pip3 install -r requirements.txt

How do I use this tool?


Set your snyk token with

export SNYK_TOKEN=TOKEN-GOES-HERE

Within the cloned repo run

python3 snyk-bulk-delete.py (add flags here)

add the necessary flags listed below

PROJECTS ARE DE-ACTIVATED BY DEFAULT AND NO ACTIONS ARE APPLIED UNLESS --FORCE FLAG IS USED, SEE DETAILS BELOW


--help : Returns this page \n--orgs/
--orgs : A set of orgs upon which to perform delete, be sure to use org slug instead of org display name (use ! for all orgs)
--sca-types : Defines SCA type/s of projects to deletes
--after : Only delete projects that were created after a certain date time (in ISO 8601 format, i.e 2023-09-01T00:00:00.000Z)
--before : Only delete projects that were created before a certain date time (in ISO 8601 format, i.e 2023-09-01T00:00:00.000Z)
--ignore-keys : An array of key's, if any of these key's are present in a project name then that project will not be targeted for deletion/deactivation
--products : Defines product/s types of projects to delete(opensource,container,iac,or sast)
--delete : By default this script will deactivate projects, add this flag to delete active projects instead
--delete-non-active-projects : By default this script will deactivate projects, add this flag to delete non-active projects instead (if this flag is active no active projects will be deleted)
--force : By default this script will perform a dry run, add this flag to apply actions
--origins : Defines origin types of projects to delete
--delete-empty-orgs : This will delete all orgs that do not have any projects in them
* Please replace spaces with dashes(-) when entering orgs
* If entering multiple values use the following format: "value-1 value-2 value-3"
* Types and origins are defined under this API > https://snyk.docs.apiary.io/#reference/projects/individual-project/retrieve-a-single-project

Example where all opensource npm and gradle projects from github are deleted within test-org-1 and test-org-2

python3 snyk-bulk-delete.py --orgs "test-org-1 test-org-2" --products opensource --sca-types "npm gradle" --origins github