Edit

AlertRestClient class

Base class that should be used (derived from) to make requests to VSS REST apis

Extends

Methods

createAutofixRequest(string, number, string)

Create an autofix request for the specified alert.

createLegalReview(string, string, number, string)

Create legal review. This creates the legal review associated with the alert. It include the review work item url.

deleteAllPipelineAnalyses(string, string)

Soft-deletes analysis data for all pipelines in a repository, cleaning up the associated Advanced Security alerts.

deletePipelineAnalysis(string, string, number)

Soft-deletes analysis data for a specific pipeline, cleaning up the associated Advanced Security alerts.

exportSarif(string, string, number[], string)

Export alerts as a single SARIF file

getAlert(string, number, string, string, ExpandOption)

Get an alert.

getAlertInstances(string, number, string, string)

Get instances of an alert on a branch specified with @ref. If @ref is not provided, return instances of an alert on default branch(if the alert exist in default branch) or latest affected branch.

getAlertMetadata(string, number, string)

Get an alert metadata.

getAlertMetadataBatch(AlertMetadataBatchRequest, string, string)

Get alerts metadata.

getAlerts(string, string, number, string, SearchCriteria, AlertListExpandOption, string)

Get alerts for a repository

getAlertSarif(string, number, string, string, ExpandOption)

Get an alert.

getAlertsByIds(AlertBatchRequest, string, string)

Get alerts by alert IDs Currently supports fetching secret alerts only.

getBranches(string, string, AlertType, string, string, number, boolean)

Returns the branches for which analysis results were submitted.

getOrgLevelAlertsByIds(number[])

Get alerts by their IDs at the organization level. Only retruns alerts that the user has permission to view. Only returns alerts of sku plans that are enabled.

getSarif(number)

Get the status of the Sarif processing job

getUxFilters(string, string, AlertType)
getValidityData(string, string, number)

Get the validity details for an alert.

initiateValidation(string, string, number)

Initiate the validation process for a given alert

updateAlert(AlertStateUpdate, string, number, string)

Update the status of an alert

updateAlertsMetadata(AlertMetadata[], string, string)

Update alert metadata associations.

uploadOrgSarif(string)

Upload a Sarif file at the organization level

uploadSarif(string, string, string, String)

Upload a Sarif containing security alerts

uploadSarifToGitHub(string, string, string, string, string)

Upload a SARIF to GitHub Code Scanning via a GitOps app.

Constructor Details

AlertRestClient(IVssRestClientOptions)

new AlertRestClient(options: IVssRestClientOptions)

Parameters

Method Details

createAutofixRequest(string, number, string)

Create an autofix request for the specified alert.

function createAutofixRequest(project: string, alertId: number, repository: string): Promise<AutofixRequest>

Parameters

project

string

Project ID or project name

alertId

number

The ID of the alert to create an autofix for.

repository

string

The name or ID of the repository.

Returns

Promise<AutofixRequest>

createLegalReview(string, string, number, string)

Create legal review. This creates the legal review associated with the alert. It include the review work item url.

function createLegalReview(project: string, repository: string, alertId: number, ref?: string): Promise<LegalReview>

Parameters

project

string

Project ID or project name

repository

string

Name or id of a repository for the legal alert

alertId

number

Advance Security alert id of the legal alert to get the legal review

ref

string

Returns

Promise<LegalReview>

deleteAllPipelineAnalyses(string, string)

Soft-deletes analysis data for all pipelines in a repository, cleaning up the associated Advanced Security alerts.

function deleteAllPipelineAnalyses(project: string, repository: string): Promise<void>

Parameters

project

string

Project ID or project name

repository

string

The name or ID of the repository.

Returns

Promise<void>

deletePipelineAnalysis(string, string, number)

Soft-deletes analysis data for a specific pipeline, cleaning up the associated Advanced Security alerts.

function deletePipelineAnalysis(project: string, repository: string, adoPipelineId: number): Promise<void>

Parameters

project

string

Project ID or project name

repository

string

The name or ID of the repository.

adoPipelineId

number

The ID of the ADO pipeline whose analysis data should be cleaned up.

Returns

Promise<void>

exportSarif(string, string, number[], string)

Export alerts as a single SARIF file

function exportSarif(project: string, repository: string, alertIds: number[], branchName?: string): Promise<any>

Parameters

project

string

Project ID or project name

repository

string

The name or ID of a repository

alertIds

number[]

List of alert IDs to export

branchName

string

The branch name of the target alerts. If not specified, the default branch will be used.

Returns

Promise<any>

getAlert(string, number, string, string, ExpandOption)

Get an alert.

function getAlert(project: string, alertId: number, repository: string, ref?: string, expand?: ExpandOption): Promise<Alert>

Parameters

project

string

Project ID or project name

alertId

number

ID of alert to retrieve

repository

string

Name or id of a repository that alert is part of

ref

string

expand
ExpandOption

Expand attributes of a secret alert. Possible values are None and ValidationFingerprint. Defaults to None. Be aware that if expand is set to ValidationFingerprint, the response may contain the secret in its unencrypted form. Please exercise caution when using this data.

Returns

Promise<Alert>

getAlertInstances(string, number, string, string)

Get instances of an alert on a branch specified with @ref. If @ref is not provided, return instances of an alert on default branch(if the alert exist in default branch) or latest affected branch.

function getAlertInstances(project: string, alertId: number, repository: string, ref?: string): Promise<AlertAnalysisInstance[]>

Parameters

project

string

Project ID or project name

alertId

number

ID of alert to retrieve

repository

string

Name or id of a repository that alert is part of

ref

string

Returns

getAlertMetadata(string, number, string)

Get an alert metadata.

function getAlertMetadata(project: string, alertId: number, repository: string): Promise<AlertMetadata>

Parameters

project

string

Project ID or project name

alertId

number

ID of alert to retrieve

repository

string

Name or id of a repository that alert is part of

Returns

Promise<AlertMetadata>

getAlertMetadataBatch(AlertMetadataBatchRequest, string, string)

Get alerts metadata.

function getAlertMetadataBatch(alertMetadataBatchRequest: AlertMetadataBatchRequest, project: string, repository: string): Promise<AlertMetadata[]>

Parameters

alertMetadataBatchRequest
AlertMetadataBatchRequest
project

string

Project ID or project name

repository

string

Name or id of a repository that alert is part of

Returns

Promise<AlertMetadata[]>

getAlerts(string, string, number, string, SearchCriteria, AlertListExpandOption, string)

Get alerts for a repository

function getAlerts(project: string, repository: string, top?: number, orderBy?: string, criteria?: SearchCriteria, expand?: AlertListExpandOption, continuationToken?: string): Promise<PagedList<Alert>>

Parameters

project

string

Project ID or project name

repository

string

The name or ID of the repository

top

number

The maximum number of alerts to return

orderBy

string

Must be "id" "firstSeen" "lastSeen" "fixedOn" or "severity" Defaults to "id"

criteria
SearchCriteria

Options to limit the alerts returned

continuationToken

string

If there are more alerts than can be returned, a continuation token is placed in the "x-ms-continuationtoken" header. Use that token here to get the next page of alerts

Returns

Promise<PagedList<Alert>>

getAlertSarif(string, number, string, string, ExpandOption)

Get an alert.

function getAlertSarif(project: string, alertId: number, repository: string, ref?: string, expand?: ExpandOption): Promise<string>

Parameters

project

string

Project ID or project name

alertId

number

ID of alert to retrieve

repository

string

Name or id of a repository that alert is part of

ref

string

expand
ExpandOption

Expand attributes of a secret alert. Possible values are None and ValidationFingerprint. Defaults to None. Be aware that if expand is set to ValidationFingerprint, the response may contain the secret in its unencrypted form. Please exercise caution when using this data.

Returns

Promise<string>

getAlertsByIds(AlertBatchRequest, string, string)

Get alerts by alert IDs Currently supports fetching secret alerts only.

function getAlertsByIds(request: AlertBatchRequest, project: string, repository: string): Promise<Alert[]>

Parameters

request
AlertBatchRequest

Request containing alert IDs and optional alert type filter

project

string

Project ID or project name

repository

string

The name or ID of the repository

Returns

Promise<Alert[]>

getBranches(string, string, AlertType, string, string, number, boolean)

Returns the branches for which analysis results were submitted.

function getBranches(project: string, repository: string, alertType: AlertType, continuationToken?: string, branchNameContains?: string, top?: number, includePullRequestBranches?: boolean): Promise<Branch[]>

Parameters

project

string

Project ID or project name

repository

string

alertType
AlertType

The type of alert: Dependency Scanning (1), Secret (2), Code QL (3), etc.

continuationToken

string

A string variable that represents the branch name and is used to fetch branches that follow it in alphabetical order.

branchNameContains

string

A string variable used to fetch branches that contain this string anywhere in the branch name, case insensitive.

top

number

An int variable used to return the top k branches that satisfy the search criteria.

includePullRequestBranches

boolean

A bool variable indicating whether or not to include pull request branches.

Returns

Promise<Branch[]>

getOrgLevelAlertsByIds(number[])

Get alerts by their IDs at the organization level. Only retruns alerts that the user has permission to view. Only returns alerts of sku plans that are enabled.

function getOrgLevelAlertsByIds(alertIds: number[]): Promise<Alert[]>

Parameters

alertIds

number[]

List of alert IDs to retrieve

Returns

Promise<Alert[]>

getSarif(number)

Get the status of the Sarif processing job

function getSarif(sarifId: number): Promise<SarifUploadStatus>

Parameters

sarifId

number

Sarif ID returned when the Sarif was uploaded

Returns

getUxFilters(string, string, AlertType)

function getUxFilters(project: string, repository: string, alertType: AlertType): Promise<UxFilters>

Parameters

project

string

Project ID or project name

repository

string

alertType
AlertType

Returns

Promise<UxFilters>

getValidityData(string, string, number)

Get the validity details for an alert.

function getValidityData(project: string, repository: string, alertId: number): Promise<ValidationRequestInfo>

Parameters

project

string

Project ID or project name

repository

string

The name or ID of a repository

alertId

number

The ID of the alert

Returns

initiateValidation(string, string, number)

Initiate the validation process for a given alert

function initiateValidation(project: string, repository: string, alertId: number): Promise<AlertValidationRequestStatus>

Parameters

project

string

Project ID or project name

repository

string

The name or ID of a repository

alertId

number

The ID of the alert

Returns

updateAlert(AlertStateUpdate, string, number, string)

Update the status of an alert

function updateAlert(stateUpdate: AlertStateUpdate, project: string, alertId: number, repository: string): Promise<Alert>

Parameters

stateUpdate
AlertStateUpdate

The new status of the alert

project

string

Project ID or project name

alertId

number

The ID of the alert

repository

string

The name or ID of the repository

Returns

Promise<Alert>

updateAlertsMetadata(AlertMetadata[], string, string)

Update alert metadata associations.

function updateAlertsMetadata(alertsMetadata: AlertMetadata[], project: string, repository: string): Promise<AlertMetadataChange[]>

Parameters

alertsMetadata

AlertMetadata[]

A list of metadata to associate with alerts.

project

string

Project ID or project name

repository

string

The name or ID of the repository.

Returns

Promise<AlertMetadataChange[]>

uploadOrgSarif(string)

Upload a Sarif file at the organization level

function uploadOrgSarif(content: string): Promise<number>

Parameters

content

string

Content to upload

Returns

Promise<number>

uploadSarif(string, string, string, String)

Upload a Sarif containing security alerts

function uploadSarif(content: string, project: string, repository: string, notificationFlag?: String): Promise<number>

Parameters

content

string

Content to upload

project

string

Project ID or project name

repository

string

The name or ID of a repository

notificationFlag

String

Header to signal that this is a progress notification

Returns

Promise<number>

uploadSarifToGitHub(string, string, string, string, string)

Upload a SARIF to GitHub Code Scanning via a GitOps app.

function uploadSarifToGitHub(content: string, project: string, hostname: string, owner: string, repo: string): Promise<string>

Parameters

content

string

Content to upload

project

string

Project ID or project name

hostname

string

The GitHub hostname (e.g., github.com or microsoft.ghe.com)

owner

string

The GitHub repository owner (organization or user)

repo

string

The GitHub repository name

Returns

Promise<string>