Note: Your site administrator must enable code scanning for your GitHub Enterprise Server instance before you can use this feature. If you want to use GitHub Actions to scan your code, the site administrator must also enable GitHub Actions and set up the infrastructure required. For more information, see "Configuring code scanning for your appliance."
About advanced setup for code scanning
Advanced setup for code scanning is helpful when you need to customize your code scanning. By creating and editing a workflow file, you can define how to build compiled languages, choose which queries to run, select the languages to scan, use a matrix build, and more. You also have access to all the options for controlling workflows, for example: changing the scan schedule, defining workflow triggers, specifying specialist runners to use. For more information about GitHub Actions workflows, see "About workflows."
Your site administrator can also make third-party actions available to users for code scanning, by setting up GitHub Connect. For more information, see "Configuring code scanning for your appliance."
If you run code scanning using multiple configurations, the same alert will sometimes be generated by more than one configuration. If an alert comes from multiple configurations, you can view the status of the alert for each configuration on the alert page. For more information, see "About code scanning alerts."
Note: This article describes the features available with the version of the CodeQL action and associated CodeQL CLI bundle included in the initial release of this version of GitHub Enterprise Server. If your enterprise uses a more recent version of the CodeQL action, see the GitHub Enterprise Cloud version of this article for information on the latest features. For information on using the latest version, see "Configuring code scanning for your appliance."
If you do not need a highly customizable code scanning configuration, consider using default setup for code scanning. For more information on eligibility for default setup, see "Configuring default setup for code scanning."
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 are enabled.
- GitHub Advanced Security is enabled.
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 "Configuring code scanning for your appliance."
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 "About workflows" and "Customizing your advanced setup for code scanning."
-
On your GitHub Enterprise Server instance, navigate to the main page of the repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
-
In the "Security" section of the sidebar, click Code security and analysis.
-
Scroll down to the "Code scanning" section, select Set up , then click Advanced.
Note: If you are switching from default setup to advanced setup, in the "Code scanning" section, select , then click Switch to advanced. In the pop-up window that appears, click Disable CodeQL.
-
To customize how code scanning scans your code, edit the workflow.
Generally, you can commit the CodeQL analysis workflow 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 "Customizing your advanced setup for code scanning" and "CodeQL code scanning for compiled languages."
-
Click Commit changes... to display the commit changes form.
-
In the commit message field, type a commit message.
-
Choose whether you'd like to commit directly to the default branch, or create a new branch and start a pull request.
-
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.
-
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 analysis workflow, 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 "Customizing your advanced setup for code scanning" and "Triggering a workflow."
For information on bulk enablement, see "Configuring advanced setup for code scanning with CodeQL at scale."
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 "About code scanning alerts" and "Managing code scanning alerts for your repository."
Learn how code scanning runs behave as checks on pull requests, see "Triaging code scanning alerts in pull requests."
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 "About the tool status page for code scanning."