This script pulls Advanced Security alerts (Code, Dependency, Secret) from Azure DevOps for a given repository and branch, and exports them to a CSV file.
A PAT Token will be required to run the application with the following permissions:
Advanced Security (READ)
Code (READ)A .env file can be used to set environment variables for convenience.
ADO_ORG=<org>
ADO_PROJECT=<Project Name>
ADO_REPO=<Repo Name>
ADO_BRANCH=develop
MAPPED_ADO_PAT=<your_personal_access_token_here> # Needs read access to Adv Security
ADO_API_VERSION=7.2-preview.1python AdvSecAlertDownloader.py --pat PAT --org ORG --project PROJECT --repo REPO [options]--pat Azure DevOps Personal Access Token (or set env MAPPED_ADO_PAT)
--org Azure DevOps organization name (or set env ADO_ORG)
--project Azure DevOps project name (or set env ADO_PROJECT)
--repo Azure DevOps repository name (or set env ADO_REPO)
--branch Branch name (default: develop, or set env ADO_BRANCH)
--api-version Azure DevOps API version (default: 7.2-preview.1)--pipeline Pipeline name (optional, or set env ADO_PIPELINE)
-h, --help Show this help message and exitpython AdvSecAlertDownloader.py --org <myorg> --project <myproj> --repo Demo --pat <PAT> --api-version 7.2-preview.1# Using the --repo all parameter will attempt to download all results for each repository in a project. Requires the branch parameter to be set.
python advSecAlertDownloader.py --org <myorg> --project <myproj> --repo all --pat <PAT> --branch developADO_ORG=<org>
ADO_PROJECT=<Project Name>
ADO_REPO=<Repo Name>
ADO_BRANCH=develop
ADO_API_VERSION=7.2-preview.1
MAPPED_ADO_PAT=C4oyQ.....AZFO2eJQpython AdvSecAlertDownloader.py --repo Demo --pipeline Gated_Scan