Skip to content

Commit d54dcfa

Browse files
sophiethekingmyarb
andauthored
Agentic autofix generation for code scanning alerts [Public Preview] (#62062)
Co-authored-by: Melanie Yarbrough <11952755+myarb@users.noreply.github.com>
1 parent cb5d694 commit d54dcfa

8 files changed

Lines changed: 115 additions & 81 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: About autofix for code scanning
3+
shortTitle: Autofix
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Autofix provides targeted recommendations to help you fix {% data variables.product.prodname_code_scanning %} alerts and avoid introducing new security vulnerabilities.'
6+
product: '{% data reusables.rai.code-scanning.gated-feature-autofix %}'
7+
versions:
8+
feature: code-scanning-autofix
9+
contentType: concepts
10+
category:
11+
- Find and fix code vulnerabilities
12+
redirect_from:
13+
- /code-security/concepts/code-scanning/copilot-autofix-for-code-scanning
14+
---
15+
16+
Autofix provides you with targeted recommendations to help you fix {% data variables.product.prodname_code_scanning %} alerts so you can avoid introducing new security vulnerabilities. The potential fixes are generated automatically by large language models (LLMs) using data from the codebase and from {% data variables.product.prodname_code_scanning %} analysis.
17+
18+
## How autofix works
19+
20+
Autofix translates the description and location of a {% data variables.product.prodname_code_scanning %} alert into code changes that may fix it. It interfaces with the large language model {% data variables.copilot.copilot_gpt_53_codex %} from OpenAI, which has sufficient generative capabilities to produce both suggested fixes in code and explanatory text for those fixes.
21+
22+
There are two ways to get a fix for an alert: agentic autofix and {% data variables.copilot.copilot_autofix_short %}. If {% data variables.copilot.copilot_cloud_agent %} is available in a repository, assigning an alert uses agentic autofix instead of {% data variables.copilot.copilot_autofix_short %}.
23+
24+
## Agentic autofix
25+
26+
> [!NOTE] This feature is currently in public preview and is subject to change.
27+
28+
Assign a {% data variables.product.prodname_code_scanning %} alert to {% data variables.product.prodname_copilot_short %} to have it resolve the alert for you. Assigning an alert starts an agent session: {% data variables.copilot.copilot_cloud_agent %} calls tools to explore your codebase beyond the affected file, generates a fix, validates it (for example, by re-running {% data variables.product.prodname_codeql %}), and iterates until it opens a pull request with the changes. See [AUTOTITLE](/code-security/how-tos/manage-security-alerts/manage-code-scanning-alerts/resolve-alerts#fixing-alerts-with-copilot).
29+
30+
Keep the following in mind:
31+
32+
* Agentic autofix requires {% data variables.copilot.copilot_cloud_agent %} and {% data variables.copilot.copilot_autofix_short %} to be available in the repository. If {% data variables.copilot.copilot_cloud_agent %} isn't available, assigning an alert falls back to {% data variables.copilot.copilot_autofix_short %} instead.
33+
* Each agentic autofix session is billed as a {% data variables.copilot.copilot_cloud_agent %} session and consumes {% data variables.product.prodname_ai_credits_short %}. See [AUTOTITLE](/copilot/concepts/agents/cloud-agent/about-cloud-agent#copilot-cloud-agent-usage-costs).
34+
* {% data variables.product.prodname_copilot_short %} follows any custom instructions configured for the repository or organization when it generates a fix.
35+
* Agentic autofix works on a best-effort basis. {% data variables.product.prodname_copilot_short %} validates fixes by re-running {% data variables.product.prodname_codeql %} using the code-scanning query suite, so it can't confirm that a fix resolves alerts generated by custom queries or the security-extended query suite. Fix quality for alerts from third-party tools is also not guaranteed.
36+
37+
## Getting a suggested fix with {% data variables.copilot.copilot_autofix_short %}
38+
39+
{% data variables.copilot.copilot_autofix_short %} generates a single suggested fix for an alert, which you review and apply yourself.
40+
41+
You do not need a subscription to {% data variables.product.prodname_copilot %} to use {% data variables.copilot.copilot_autofix %}, and it does not consume {% data variables.product.prodname_ai_credits_short %}. {% data variables.copilot.copilot_autofix_short %} is available to all public repositories on {% data variables.product.prodname_dotcom_the_website %}, as well as internal or private repositories owned by organizations and enterprises that have a license for {% data variables.product.prodname_GH_code_security %}.
42+
43+
{% data variables.copilot.copilot_autofix_short %} is allowed by default and enabled for every repository that uses {% data variables.product.prodname_codeql %}, regardless of whether it uses default or advanced setup for {% data variables.product.prodname_code_scanning %}. There is no separate step to enable {% data variables.copilot.copilot_autofix_short %}: enabling {% data variables.product.prodname_code_scanning %} with {% data variables.product.prodname_codeql %} is sufficient. See [AUTOTITLE](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning).
44+
45+
Administrators at the enterprise, organization, and repository levels can choose to disable {% data variables.copilot.copilot_autofix_short %}. If {% data variables.copilot.copilot_autofix_short %} has been disabled at your level, you can re-enable it by following the same steps used to disable it and selecting the option to allow {% data variables.copilot.copilot_autofix_short %}. To learn how to manage {% data variables.copilot.copilot_autofix_short %} at each level, see [AUTOTITLE](/code-security/how-tos/manage-security-alerts/manage-code-scanning-alerts/disabling-autofix-for-code-scanning).

content/code-security/concepts/code-scanning/copilot-autofix-for-code-scanning.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

content/code-security/concepts/code-scanning/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ children:
1313
- /code-scanning
1414
- /code-scanning-alerts
1515
- /risk-assessment
16-
- /copilot-autofix-for-code-scanning
16+
- /autofix-for-code-scanning
1717
- /ai-powered-security-detections
1818
- /setup-types
1919
- /integration-with-code-scanning

content/code-security/how-tos/manage-security-alerts/manage-code-scanning-alerts/disabling-autofix-for-code-scanning.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Disabling Copilot Autofix for code scanning security alerts
3-
shortTitle: Disable Copilot Autofix
2+
title: Disabling autofix for code scanning security alerts
3+
shortTitle: Disable autofix
44
allowTitleToDifferFromFilename: true
5-
intro: You can block availability of {% data variables.copilot.copilot_autofix %} for security alerts for an enterprise or disable {% data variables.copilot.copilot_autofix %} at the organization and repository level.
5+
intro: 'You can disable {% data variables.copilot.copilot_autofix_short %}, which also blocks agentic autofix, for an enterprise, organization, or repository.'
66
product: '{% data reusables.rai.code-scanning.gated-feature-autofix %}'
77
versions:
88
feature: code-scanning-autofix
@@ -13,16 +13,27 @@ category:
1313
- Find and fix code vulnerabilities
1414
---
1515

16-
{% data reusables.rai.code-scanning.copilot-autofix-note %}
16+
## Disabling agentic autofix
17+
18+
Disabling agentic autofix can be done in two ways:
19+
20+
1. By disabling {% data variables.copilot.copilot_autofix_short %} since agentic autofix relies on the same underlying setting. For instructions, see the sections below.
21+
1. By opting repositories out of {% data variables.copilot.copilot_cloud_agent %}. See [AUTOTITLE](/copilot/concepts/agents/cloud-agent/access-management#opting-repositories-out-of-copilot-cloud-agent).
22+
23+
For more information about agentic autofix, see [AUTOTITLE](/code-security/concepts/code-scanning/autofix-for-code-scanning#agentic-autofix).
24+
25+
## Disabling {% data variables.copilot.copilot_autofix_short %}
26+
27+
You can disable {% data variables.copilot.copilot_autofix_short %} at the enterprise, organization, or repository level.
1728

1829
Disabling {% data variables.copilot.copilot_autofix_short %} at any level will close all open {% data variables.copilot.copilot_autofix_short %} suggestions that were added as comments on {% data variables.product.prodname_code_scanning %} alerts in pull requests. If {% data variables.copilot.copilot_autofix_short %} is later re-enabled, suggestions will only be generated for pull requests opened after that point, or after re-running {% data variables.product.prodname_code_scanning %} security analysis on existing pull requests.
1930

2031
> [!NOTE]
2132
> {% data variables.copilot.copilot_autofix_short %} is an integral part of {% data variables.product.prodname_code_quality %} and will continue to run on code quality results even when it is disabled for code security results.
2233
23-
For more information about {% data variables.copilot.copilot_autofix_short %}, see [AUTOTITLE](/code-security/concepts/code-scanning/copilot-autofix-for-code-scanning).
34+
For more information about {% data variables.copilot.copilot_autofix_short %}, see [AUTOTITLE](/code-security/concepts/code-scanning/autofix-for-code-scanning).
2435

25-
## Blocking use of {% data variables.copilot.copilot_autofix_short %} for an enterprise
36+
### Blocking use of {% data variables.copilot.copilot_autofix_short %} for an enterprise
2637

2738
Enterprise administrators can disallow {% data variables.copilot.copilot_autofix_short %} for security results in their enterprise. If you disallow {% data variables.copilot.copilot_autofix_short %} for an enterprise, {% data variables.copilot.copilot_autofix_short %} cannot be enabled for any organizations or repositories within the enterprise.
2839

@@ -35,7 +46,7 @@ Disallowing {% data variables.copilot.copilot_autofix_short %} at the enterprise
3546
{% data reusables.enterprise-accounts.code-security-and-analysis-policies %}
3647
1. Under "{% data variables.copilot.copilot_autofix_short %}", use the dropdown menu to choose "Not allowed."
3748

38-
## Disabling {% data variables.copilot.copilot_autofix_short %} for an organization
49+
### Disabling {% data variables.copilot.copilot_autofix_short %} for an organization
3950

4051
If {% data variables.copilot.copilot_autofix_short %} is allowed at the enterprise level, organization administrators have the option to disable {% data variables.copilot.copilot_autofix_short %} for an organization. If you disable {% data variables.copilot.copilot_autofix_short %} for an organization, {% data variables.copilot.copilot_autofix_short %} cannot be enabled for any repositories within the organization.
4152

@@ -48,7 +59,7 @@ Disabling {% data variables.copilot.copilot_autofix_short %} at the organization
4859

4960
For more information about configuring global {% data variables.product.prodname_code_scanning %} settings, see [AUTOTITLE](/code-security/securing-your-organization/enabling-security-features-in-your-organization/configuring-global-security-settings-for-your-organization#configuring-global-code-scanning-settings).
5061

51-
## Disabling {% data variables.copilot.copilot_autofix_short %} for a repository
62+
### Disabling {% data variables.copilot.copilot_autofix_short %} for a repository
5263

5364
If {% data variables.copilot.copilot_autofix_short %} is allowed at the enterprise level and enabled at the organization level, repository administrators have the option to disable {% data variables.copilot.copilot_autofix_short %} for a repository. Disabling {% data variables.copilot.copilot_autofix_short %} at the repository level will remove all open {% data variables.copilot.copilot_autofix_short %} suggestions that were added as comments on {% data variables.product.prodname_code_scanning %} alerts in pull requests across the repository.
5465

0 commit comments

Comments
 (0)