codeScanningListAlertsForRepo
List code scanning alerts for a repository
Details
- Method:
GET - Path:
/repos/{owner}/{repo}/code-scanning/alerts - Operation ID:
code-scanning/list-alerts-for-repo
Parameters
{
"owner": {
"description": "The account owner of the repository. The name is not case sensitive.",
"required": true,
"location": "path",
"type": "string"
},
"repo": {
"description": "The name of the repository without the `.git` extension. The name is not case sensitive.",
"required": true,
"location": "path",
"type": "string"
},
"tool_name": {
"description": "The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either `tool_name` or `tool_guid`, but not both.",
"required": false,
"location": "query",
"type": "string"
},
"tool_guid": {
"description": "The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either `tool_guid` or `tool_name`, but not both.",
"required": false,
"location": "query",
"type": "string"
},
"page": {
"description": "The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"",
"required": false,
"location": "query",
"type": "integer"
},
"per_page": {
"description": "The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"",
"required": false,
"location": "query",
"type": "integer"
},
"ref": {
"description": "The Git reference for the results you want to list. The `ref` for a branch can be formatted either as `refs/heads/<branch name>` or simply `<branch name>`. To reference a pull request use `refs/pull/<number>/merge`.",
"required": false,
"location": "query",
"type": "string"
},
"pr": {
"description": "The number of the pull request for the results you want to list.",
"required": false,
"location": "query",
"type": "integer"
},
"direction": {
"description": "The direction to sort the results by.",
"required": false,
"location": "query",
"type": "string",
"enum": [
"asc",
"desc"
]
},
"before": {
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"",
"required": false,
"location": "query",
"type": "string"
},
"after": {
"description": "A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\"",
"required": false,
"location": "query",
"type": "string"
},
"sort": {
"description": "The property by which to sort the results.",
"required": false,
"location": "query",
"type": "string",
"enum": [
"created",
"updated"
]
},
"state": {
"description": "If specified, only code scanning alerts with this state will be returned.",
"required": false,
"location": "query",
"type": "string",
"enum": [
"open",
"closed",
"dismissed",
"fixed"
]
},
"severity": {
"description": "If specified, only code scanning alerts with this severity will be returned.",
"required": false,
"location": "query",
"type": "string",
"enum": [
"critical",
"high",
"medium",
"low",
"warning",
"note",
"error"
]
},
"assignees": {
"description": "Filter alerts by assignees. Provide a comma-separated list of user handles (e.g., `octocat` or `octocat,hubot`).\nUse `*` to list alerts with at least one assignee or `none` to list alerts with no assignees.\n",
"required": false,
"location": "query",
"type": "string"
}
}Response Schema
{
"type": "array",
"items": {
"type": "object",
"properties": {
"number": {
"type": "integer",
"description": "The security alert number.",
"readOnly": true
},
"created_at": {
"type": "string",
"description": "The time that the alert was created in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.",
"format": "date-time",
"readOnly": true
},
"updated_at": {
"type": "string",
"description": "The time that the alert was last updated in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.",
"format": "date-time",
"readOnly": true
},
"url": {
"type": "string",
"description": "The REST API URL of the alert resource.",
"format": "uri",
"readOnly": true
},
"html_url": {
"type": "string",
"description": "The GitHub URL of the alert resource.",
"format": "uri",
"readOnly": true
},
"instances_url": {
"type": "string",
"description": "The REST API URL for fetching the list of instances for an alert.",
"format": "uri",
"readOnly": true
},
"state": {
"type": "string",
"description": "State of a code scanning alert.",
"nullable": true,
"enum": [
"open",
"dismissed",
"fixed"
]
},
"fixed_at": {
"type": "string",
"description": "The time that the alert was no longer detected and was considered fixed in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.",
"format": "date-time",
"readOnly": true,
"nullable": true
},
"dismissed_by": {
"title": "Simple User",
"description": "A GitHub user.",
"type": "object",
"properties": {
"name": {
"nullable": true,
"type": "string"
},
"email": {
"nullable": true,
"type": "string"
},
"login": {
"type": "string",
"example": "octocat"
},
"id": {
"type": "integer",
"format": "int64",
"example": 1
},
"node_id": {
"type": "string",
"example": "MDQ6VXNlcjE="
},
"avatar_url": {
"type": "string",
"format": "uri",
"example": "https://github.com/images/error/octocat_happy.gif"
},
"gravatar_id": {
"type": "string",
"example": "41d064eb2195891e12d0413f63227ea7",
"nullable": true
},
"url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat"
},
"html_url": {
"type": "string",
"format": "uri",
"example": "https://github.com/octocat"
},
"followers_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/followers"
},
"following_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/following{/other_user}"
},
"gists_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/gists{/gist_id}"
},
"starred_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/starred{/owner}{/repo}"
},
"subscriptions_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/subscriptions"
},
"organizations_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/orgs"
},
"repos_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/repos"
},
"events_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/events{/privacy}"
},
"received_events_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/received_events"
},
"type": {
"type": "string",
"example": "User"
},
"site_admin": {
"type": "boolean"
},
"starred_at": {
"type": "string",
"example": "\"2020-07-09T00:17:55Z\""
},
"user_view_type": {
"type": "string",
"example": "public"
}
},
"required": [
"avatar_url",
"events_url",
"followers_url",
"following_url",
"gists_url",
"gravatar_id",
"html_url",
"id",
"node_id",
"login",
"organizations_url",
"received_events_url",
"repos_url",
"site_admin",
"starred_url",
"subscriptions_url",
"type",
"url"
],
"nullable": true
},
"dismissed_at": {
"type": "string",
"description": "The time that the alert was dismissed in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.",
"format": "date-time",
"readOnly": true,
"nullable": true
},
"dismissed_reason": {
"type": "string",
"description": "**Required when the state is dismissed.** The reason for dismissing or closing the alert.",
"nullable": true,
"enum": [
"false positive",
"won't fix",
"used in tests"
]
},
"dismissed_comment": {
"type": "string",
"description": "The dismissal comment associated with the dismissal of the alert.",
"nullable": true,
"maxLength": 280
},
"rule": {
"type": "object",
"properties": {
"id": {
"nullable": true,
"type": "string",
"description": "A unique identifier for the rule used to detect the alert."
},
"name": {
"type": "string",
"description": "The name of the rule used to detect the alert."
},
"severity": {
"nullable": true,
"type": "string",
"description": "The severity of the alert.",
"enum": [
"none",
"note",
"warning",
"error"
]
},
"security_severity_level": {
"nullable": true,
"type": "string",
"description": "The security severity of the alert.",
"enum": [
"low",
"medium",
"high",
"critical"
]
},
"description": {
"type": "string",
"description": "A short description of the rule used to detect the alert."
},
"full_description": {
"type": "string",
"description": "A description of the rule used to detect the alert."
},
"tags": {
"nullable": true,
"type": "array",
"description": "A set of tags applicable for the rule.",
"items": {
"type": "string"
}
},
"help": {
"nullable": true,
"type": "string",
"description": "Detailed documentation for the rule as GitHub Flavored Markdown."
},
"help_uri": {
"nullable": true,
"type": "string",
"description": "A link to the documentation for the rule used to detect the alert."
}
}
},
"tool": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the tool used to generate the code scanning analysis."
},
"version": {
"nullable": true,
"type": "string",
"description": "The version of the tool used to generate the code scanning analysis."
},
"guid": {
"nullable": true,
"type": "string",
"description": "The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data."
}
}
},
"most_recent_instance": {
"type": "object",
"properties": {
"ref": {
"type": "string",
"description": "The Git reference, formatted as `refs/pull/<number>/merge`, `refs/pull/<number>/head`,\n`refs/heads/<branch name>` or simply `<branch name>`."
},
"analysis_key": {
"type": "string",
"description": "Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name."
},
"environment": {
"type": "string",
"description": "Identifies the variable values associated with the environment in which the analysis that generated this alert instance was performed, such as the language that was analyzed."
},
"category": {
"type": "string",
"description": "Identifies the configuration under which the analysis was executed. Used to distinguish between multiple analyses for the same tool and commit, but performed on different languages or different parts of the code."
},
"state": {
"type": "string",
"description": "State of a code scanning alert.",
"nullable": true,
"enum": [
"open",
"dismissed",
"fixed"
]
},
"commit_sha": {
"type": "string"
},
"message": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
},
"location": {
"type": "object",
"description": "Describe a region within a file for the alert.",
"properties": {
"path": {
"type": "string"
},
"start_line": {
"type": "integer"
},
"end_line": {
"type": "integer"
},
"start_column": {
"type": "integer"
},
"end_column": {
"type": "integer"
}
}
},
"html_url": {
"type": "string"
},
"classifications": {
"type": "array",
"description": "Classifications that have been applied to the file that triggered the alert.\nFor example identifying it as documentation, or a generated file.",
"items": {
"type": "string",
"description": "A classification of the file. For example to identify it as generated.",
"nullable": true,
"enum": [
"source",
"generated",
"test",
"library"
]
}
}
}
},
"dismissal_approved_by": {
"title": "Simple User",
"description": "A GitHub user.",
"type": "object",
"properties": {
"name": {
"nullable": true,
"type": "string"
},
"email": {
"nullable": true,
"type": "string"
},
"login": {
"type": "string",
"example": "octocat"
},
"id": {
"type": "integer",
"format": "int64",
"example": 1
},
"node_id": {
"type": "string",
"example": "MDQ6VXNlcjE="
},
"avatar_url": {
"type": "string",
"format": "uri",
"example": "https://github.com/images/error/octocat_happy.gif"
},
"gravatar_id": {
"type": "string",
"example": "41d064eb2195891e12d0413f63227ea7",
"nullable": true
},
"url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat"
},
"html_url": {
"type": "string",
"format": "uri",
"example": "https://github.com/octocat"
},
"followers_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/followers"
},
"following_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/following{/other_user}"
},
"gists_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/gists{/gist_id}"
},
"starred_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/starred{/owner}{/repo}"
},
"subscriptions_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/subscriptions"
},
"organizations_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/orgs"
},
"repos_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/repos"
},
"events_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/events{/privacy}"
},
"received_events_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/received_events"
},
"type": {
"type": "string",
"example": "User"
},
"site_admin": {
"type": "boolean"
},
"starred_at": {
"type": "string",
"example": "\"2020-07-09T00:17:55Z\""
},
"user_view_type": {
"type": "string",
"example": "public"
}
},
"required": [
"avatar_url",
"events_url",
"followers_url",
"following_url",
"gists_url",
"gravatar_id",
"html_url",
"id",
"node_id",
"login",
"organizations_url",
"received_events_url",
"repos_url",
"site_admin",
"starred_url",
"subscriptions_url",
"type",
"url"
],
"nullable": true
},
"assignees": {
"type": "array",
"items": {
"title": "Simple User",
"description": "A GitHub user.",
"type": "object",
"properties": {
"name": {
"nullable": true,
"type": "string"
},
"email": {
"nullable": true,
"type": "string"
},
"login": {
"type": "string",
"example": "octocat"
},
"id": {
"type": "integer",
"format": "int64",
"example": 1
},
"node_id": {
"type": "string",
"example": "MDQ6VXNlcjE="
},
"avatar_url": {
"type": "string",
"format": "uri",
"example": "https://github.com/images/error/octocat_happy.gif"
},
"gravatar_id": {
"type": "string",
"example": "41d064eb2195891e12d0413f63227ea7",
"nullable": true
},
"url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat"
},
"html_url": {
"type": "string",
"format": "uri",
"example": "https://github.com/octocat"
},
"followers_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/followers"
},
"following_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/following{/other_user}"
},
"gists_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/gists{/gist_id}"
},
"starred_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/starred{/owner}{/repo}"
},
"subscriptions_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/subscriptions"
},
"organizations_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/orgs"
},
"repos_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/repos"
},
"events_url": {
"type": "string",
"example": "https://api.github.com/users/octocat/events{/privacy}"
},
"received_events_url": {
"type": "string",
"format": "uri",
"example": "https://api.github.com/users/octocat/received_events"
},
"type": {
"type": "string",
"example": "User"
},
"site_admin": {
"type": "boolean"
},
"starred_at": {
"type": "string",
"example": "\"2020-07-09T00:17:55Z\""
},
"user_view_type": {
"type": "string",
"example": "public"
}
},
"required": [
"avatar_url",
"events_url",
"followers_url",
"following_url",
"gists_url",
"gravatar_id",
"html_url",
"id",
"node_id",
"login",
"organizations_url",
"received_events_url",
"repos_url",
"site_admin",
"starred_url",
"subscriptions_url",
"type",
"url"
]
}
}
},
"required": [
"number",
"created_at",
"url",
"html_url",
"instances_url",
"state",
"dismissed_by",
"dismissed_at",
"dismissed_reason",
"rule",
"tool",
"most_recent_instance"
]
}
}Usage
from ocp_agent import OCPAgent
agent = OCPAgent()
await agent.register_api('github')
# Call this tool
result = await agent.call_tool('codeScanningListAlertsForRepo', {
# Add required parameters here
})