AlertRestClient class

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

Extends

Constructors

AlertRestClient(IVssRestClientOptions)

Methods

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

Get an alert.

getAlertInstances(string, number, string, string)

Get instances of an alert.

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

Get alerts for a repository

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

Get an alert.

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

Returns the branches for which analysis results were submitted.

getSarif(number)

Get the status of the Sarif processing job

getUxFilters(string, string, AlertType)
updateAlert(AlertStateUpdate, string, number, string)

Update the status of an alert

updateAlertsMetadata(AlertMetadata[], string, string)

Update alert metadata associations.

uploadSarif(string, string, string, String)

Upload a Sarif containing security alerts

Constructor Details

AlertRestClient(IVssRestClientOptions)

new AlertRestClient(options: IVssRestClientOptions)

Parameters

Method Details

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 alert attributes. Possible options are {ValidationFingerprint, None}

Returns

Promise<Alert>

getAlertInstances(string, number, string, string)

Get instances of an alert.

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

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

Get alerts for a repository

function getAlerts(project: string, repository: string, top?: number, orderBy?: string, criteria?: SearchCriteria, 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 alert attributes. Possible options are {ValidationFingerprint, None}

Returns

Promise<string>

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[]>

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>

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[]>

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>