Skip to main content

Configuring advanced setup for code scanning

You can configure advanced setup for a repository to find security vulnerabilities in your code using a highly customizable code scanning configuration.

Wer kann dieses Feature verwenden?

Repositorybesitzerinnen, Organisationsbesitzerinnen, Sicherheitsmanagerinnen und Benutzerinnen mit der Administratorrolle

Code scanning ist für die folgenden Repositorytypen verfügbar:

  • Öffentliche Repositorys auf GitHub.com
  • Organisationseigene Repositorys für GitHub Team, GitHub Enterprise Cloud oder GitHub Enterprise Server, wobei GitHub Advanced Security aktiviert sind.

Hinweis

Der Websiteadministrator muss code scanning aktivieren, damit du dieses Feature verwenden kannst. Wenn du GitHub Actions zum Überprüfen deines Codes verwenden möchtest, muss der Websiteadministrator auch GitHub Actions aktivieren und die erforderliche Infrastruktur einrichten. Weitere Informationen finden Sie unter Konfigurieren der Codeüberprüfung für Ihre Anwendung.

Hinweis

In diesem Artikel werden die Features beschrieben, die in der Version der CodeQL-Aktion und dem zugehörigen CodeQL CLI-Bundle im ursprünglichen Release dieser Version von GitHub Enterprise Server enthalten sind. Wenn dein Unternehmen eine neuere Version der CodeQL-Aktion verwendet, findest du Informationen zu den neuesten Features in der GitHub Enterprise Cloud-Version dieses Artikels. Informationen zum Verwenden der aktuellen Version findest du unter Konfigurieren der Codeüberprüfung für Ihre Anwendung.

If you do not need a highly customizable code scanning configuration, consider using default setup for code scanning. For more information, see Informationen zu Konfigurationstypen für die Code-Analyse.

Prerequisites

Your repository is eligible for advanced setup if it meets these requirements.

  • It uses CodeQL-supported languages or you plan to generate code scanning results with a third-party tool.
  • GitHub Actions ist aktiviert.
  • GitHub Advanced Security ist aktiviert.

If the server on which you are running GitHub Enterprise Server is not connected to the internet, your site administrator can enable CodeQL code scanning by making the CodeQL analysis bundle available on the server. For more information, see Konfigurieren der Codeüberprüfung für Ihre Anwendung.

Configuring advanced setup for code scanning with CodeQL

You can customize your CodeQL analysis by creating and editing a workflow file. Selecting advanced setup generates a basic workflow file for you to customize using standard workflow syntax and specifying options for the CodeQL action. See Workflows and Workflowkonfigurationsoptionen für die Codeüberprüfung.

  1. Navigieren Sie auf GitHub zur Hauptseite des Repositorys.

  2. Klicke unter dem Repositorynamen auf Settings. Wenn die Registerkarte „Einstellungen“ nicht angezeigt wird, wähle im Dropdownmenü die Option Einstellungen aus.

    Screenshot eines Repositoryheaders mit den Registerkarten. Die Registerkarte „Einstellungen“ ist dunkelorange umrandet.

  3. Klicke im Abschnitt „Security“ der Randleiste auf Code security.

  4. Scroll down to "Code scanning", in the "CodeQL analysis" row select Set up , then click Advanced.

    Hinweis

    If you are switching from default setup to advanced setup, in the "CodeQL analysis" row, select , then click Switch to advanced. In the pop-up window that appears, click Disable CodeQL.

    Screenshot of the "Code scanning" section of "Code security" settings. The "Advanced setup" button is highlighted with an orange outline.

  5. To customize how code scanning scans your code, edit the workflow.

    Generally, you can commit the CodeQL-Analyseworkflow without making any changes to it. However, many of the third-party workflows require additional configuration, so read the comments in the workflow before committing.

    For more information, see Workflowkonfigurationsoptionen für die Codeüberprüfung and CodeQL code scanning for compiled languages.

  6. Click Commit changes... to display the commit changes form.

    Screenshot of the form to create a new file. To the right of the file name, a green button, labeled "Commit changes...", is outlined in dark orange.

  7. In the commit message field, type a commit message.

  8. Choose whether you'd like to commit directly to the default branch, or create a new branch and start a pull request.

  9. Click Commit new file to commit the workflow file to the default branch or click Propose new file to commit the file to a new branch.

  10. If you created a new branch, click Create pull request and open a pull request to merge your change into the default branch.

In the suggested CodeQL-Analyseworkflow, code scanning is configured to analyze your code each time you either push a change to the default branch or any protected branches, or raise a pull request against the default branch. As a result, code scanning will now commence.

The on:pull_request and on:push triggers for code scanning are each useful for different purposes. See Workflowkonfigurationsoptionen für die Codeüberprüfung and Auslösen eines Workflows.

For information on bulk enablement, see Konfigurieren des erweiterten Setups für das Codescanning mit CodeQL im großen Stil.

Next steps

After your workflow runs successfully at least once, you are ready to start examining and resolving code scanning alerts. For more information on code scanning alerts, see Informationen zu Codeüberprüfungswarnungen and Bewertung von Code-Scanning-Warnungen für Ihr Repository.

Learn how code scanning runs behave as checks on pull requests, see Filtern von Codescanbenachrichtigungen in Pull-Anforderungen.

You can find detailed information about your code scanning configuration, including timestamps for each scan and the percentage of files scanned, on the tool status page. For more information, see Use the tool status page for code scanning.

Further reading