Skip to main content
Publicamos actualizaciones para la documentación con frecuencia y es posible que aún se esté traduciendo esta página. Para obtener la información más reciente, consulta la documentación en inglés.
Ahora la API de REST tiene control de versiones. Para obtener más información, consulta "Acerca del control de versiones de la API".

Examen del código

Usa la API de REST para recuperar y actualizar alertas de code scanning de un repositorio.

Acerca del examen de código

Puedes recuperar y actualizar alertas de code scanning de un repositorio. Puedes utilizar las terminales para crear reportes automatizados para las alertas del code scanning en una organización o cargar resutlados de análisis que se hayan generado utilizando con herramientas fuera de línea del code scanning. Para obtener más información, vea «Encontrar errores y vulnerabilidades de seguridad en tu código con el escaneo de código».

Tipos de medios personalizados para el code scanning

Hay un tipo de medios personalizado compatible para los puntos de conexión de code scanning.

application/sarif+json

Puede usar esto con solicitudes GET enviadas al punto de conexión /analyses/{analysis_id}. Para más información sobre esta operación, vea "Obtención de un análisis de code scanning para un repositorio". Cuando se usa este tipo de medio con esta operación, la respuesta incluye un subconjunto de los datos reales que se cargaron para el análisis especificado, en lugar del resumen del análisis que se devuelve cuando se usa el tipo de medio predeterminado. La respuesta también incluye datos adicionales, como las propiedades github/alertNumber y github/alertUrl. El formato de los datos es SARIF, versión 2.1.0.

Para obtener más información, vea «Tipos de medios».

List code scanning alerts for an organization

Funciona con GitHub Apps

Lists code scanning alerts for the default branch for all eligible repositories in an organization. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "Managing security managers in your organization."

To use this endpoint, you must be an owner or security manager for the organization, and you must use an access token with the repo scope or security_events scope.

For public repositories, you may instead use the public_repo scope.

GitHub Apps must have the security_events read permission to use this endpoint.

Parámetros para "List code scanning alerts for an organization"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
org string Requerido

The organization name. The name is not case sensitive.

Parámetros de consulta
Nombre, Tipo, Descripción
tool_name string

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.

tool_guid string or null

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.

before string

A cursor, as given in the Link header. If specified, the query only searches for results before this cursor.

after string

A cursor, as given in the Link header. If specified, the query only searches for results after this cursor.

page integer

Page number of the results to fetch.

Valor predeterminado: 1

per_page integer

The number of results per page (max 100).

Valor predeterminado: 30

direction string

The direction to sort the results by.

Valor predeterminado: desc

Puede ser uno de los siguientes: asc, desc

state string

If specified, only code scanning alerts with this state will be returned.

Puede ser uno de los siguientes: open, closed, dismissed, fixed

sort string

The property by which to sort the results.

Valor predeterminado: created

Puede ser uno de los siguientes: created, updated

severity string

If specified, only code scanning alerts with this severity will be returned.

Puede ser uno de los siguientes: critical, high, medium, low, warning, note, error

Códigos de estado de respuesta HTTP para "List code scanning alerts for an organization"

status codeDescripción
200

OK

404

Resource not found

503

Service unavailable

Ejemplos de código para "List code scanning alerts for an organization"

get/orgs/{org}/code-scanning/alerts
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/code-scanning/alerts

Response

Status: 200
[ { "number": 4, "created_at": "2020-02-13T12:29:18Z", "url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4", "html_url": "https://github.com/octocat/hello-world/code-scanning/4", "state": "open", "dismissed_by": null, "dismissed_at": null, "dismissed_reason": null, "dismissed_comment": null, "rule": { "id": "js/zipslip", "severity": "error", "tags": [ "security", "external/cwe/cwe-022" ], "description": "Arbitrary file write during zip extraction", "name": "js/zipslip" }, "tool": { "name": "CodeQL", "guid": null, "version": "2.4.0" }, "most_recent_instance": { "ref": "refs/heads/main", "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", "environment": "{}", "state": "open", "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930", "message": { "text": "This path depends on a user-provided value." }, "location": { "path": "spec-main/api-session-spec.ts", "start_line": 917, "end_line": 917, "start_column": 7, "end_column": 18 }, "classifications": [ "test" ] }, "instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4/instances", "repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/