This tool helps you identify archived repositories in GitHub that are also imported into Snyk. It will generate a JSON file with matching projects and provides a command to deactivate or delete them in Snyk.
-
Clone the Repository
git clone https://github.com/yourusername/yourrepository.git cd yourrepository
-
Install Dependencies
It's recommended to use a virtual environment:
python -m venv venv source venv/bin/activate pip install -r requirements.txt
-
Environment Variables
Ensure you have the following environment variables set:
GITHUB_TOKEN
: Your GitHub personal access token.SNYK_TOKEN
: Your Snyk API token.
This command generates a JSON file containing Snyk projects that match archived GitHub repositories.
python index.py generate-archived-repos-json --github-org-name <GITHUB_ORG_NAME> --snyk-org-id <SNYK_ORG_ID> [--output-file <OUTPUT_FILE>] [--snyk-tenant <SNYK_TENANT>]
--github-org-name
or-g
: The name of the GitHub organization to search for archived repos.--snyk-org-id
or-s
: The ID of the Snyk organization to search for targets.--output-file
or-o
: (Optional) The file path to write the JSON data. Defaults toarchived-projects.json
.--snyk-tenant
or-st
: (Optional) The tenant of the Snyk organization. Defaults toapi.us.snyk.io
.
This command reads a JSON file and deactivates the corresponding projects in Snyk.
python index.py deactivate-from-json --input-file <INPUT_FILE> [--snyk-tenant <SNYK_TENANT>]
--input-file
or-i
: The file path to read the JSON data from.--snyk-tenant
or-st
: (Optional) The tenant of the Snyk organization. Defaults toapi.us.snyk.io
.
This command reads a JSON file and deletes the corresponding projects in Snyk.
python index.py delete-from-json --input-file <INPUT_FILE> [--snyk-tenant <SNYK_TENANT>]
--input-file
or-i
: The file path to read the JSON data from.--snyk-tenant
or-st
: (Optional) The tenant of the Snyk organization. Defaults toapi.us.snyk.io
.
Generate a JSON file of archived projects:
python index.py generate-archived-repos-json -g my-github-org -s my-snyk-org
Deactivate projects from the generated JSON file:
python index.py deactivate-from-json -i archived-projects.json
Delete projects from the generated JSON file:
python index.py delete-from-json -i archived-projects.json