Setting up an AppScan Presence to scan a GitLab repository
Use an AppScan Presence to run analysis on GitLab Cloud and GitLab Self-Managed repositories.
AppScan Presence includes support for running static analysis on GitLab repositories from a GitLab Self-Managed server or GitLab Cloud instance using a GitLab app. The GitLab server doesn’t have to be publicly accessible; however, the AppScan user must have network access to the GitLab server and permission to access the repositories in GitLab.
An instance of AppScan Presence with GitLab scanning enabled can be associated with one GitLab Self-Managed server and Cloud instance using one GitLab app defined.
- Create and install an AppScan Presence to a
folder location on a private network with access to the GitLab Self-Managed
server or Cloud instance.Note:A single AppScan Presence connected to a single GitLab Self-Managed server or Cloud instance allows all the users in the organization to scan repositories on that server to which they have access.
- Create a GitLab app on the GitLab Self-Managed server or Cloud instance.
- Activate and configure GitLab-specific parameters in the AppScan Presence.
- Create the scan.
- Log in to GitLab.
- Open profile settings:
- In the upper-right, click your avatar.
- Click Edit profile.
- Click Access.
- Click Applications.
- On the Applications page, click Add new application.
- Specify the following application parameters:
Parameter Value Name Your name for the app Redirect URI Your AppScan Presence-embedded web application URL plus /signin-gitlab. For example,https://my-presence-host-fqdn/signin-gitlab.Scope Select the OAuth 2 scopes required by AppScan Presence. - Click Save application.
- Application ID: Used as Client ID.
- Client Secret: Copy immediately after application creation.
- Redirect URI: Retain for AppScan Presence configuration.
Configure and activate an AppScan Presence
- Create a PAT (Personal Access Token) for the GitLab app:
- Sign in to GitLab.
- In the upper-right, click your avatar.
- Click Edit profile.
- Click Access tokens.
In some GitLab versions, it may be under .
- Enter a token name.
For example “PresenceGitLabTest”.
- Set an expiration date if required by your GitLab policy.
- Select scopes.
For repository fetch scenarios such as this,
read_apiandread_repositoryare common choices. - Click Create personal access token.
- Copy the token immediately.
GitLab shows this token only once.
- In the AppScan Presence installation
directory, locate the
git_connect_settings.jsonfile and open it for editing. - In the
GitConnectOptionssection ofgit_connect_settings.json, edit parameters as follows:Parameter Description Example GitServerNameThe name of the GitLab server GitLab Cloud instance or GitLab Self-Managed server. GitConnectUrlThe URL of the web application exposed by this AppScan Presence. This is the same value as CallbackURL when you created the GitLab app. https://my-presence-host-fqdn:443GithubAppIdAppId of the GitLab app you created for this connection. 1 GitHubAppUrlApplication URl of the GitLab app. https://gitlab.example.com/oauth/applications/1 ClientIdApplication ID of the GitLab app. <oauth client id>ClientSecretClient secret of the GitLab app. <oauth client secret>GitPlatformDomainURL for the GitLab Self-Managed server or Cloud instance. https://gitlab.example.com ProxyIf a proxy is required to connect to the GitLab server, uncomment this line and provide the proxy details. 127.0.0.1:8888ActiveEnable or disable GitLab connection functionality in the AppScan Presence. The default value is false.trueGitPlatformTypeType of the config server GitLab AccessTokenPersonal Access Token of the GitLab server <Personal Access Token> - HTTPS is required. In the
kestrelsection ofgit_connect_settings.json, edit the parameters as follows to configure your secure connection.Parameter Description Example HttpThe protocol to be used by the AppScan Presence HttpsUrlThe port to be used by the AppScan Presence. https://*:443(or your default secure port)Note:AppScan Presence uses Kestrel to host its web application. Kestrel is an embedded web server and it can be configured using the Kestrel section in the configuration file. For more information on the structure of this server configuration, see Configure endpoints for the ASP.NET Core Kestrel web server.
AppScan Presence GitLab scanning flow

- The user logs in to ASoC. (1,2)
- From ASoC, users select the SCM GitLab and then choose GitLab Self-Managed server or GitLab Cloud. A list of configured enabled AppScan Presencees with the connected servers is returned. The user then chooses Presence.
- When the user clicks Authorize presence, ASoC opens a new browser tab that points to AppScan Presence (3) which initiates the oAuth Authorization code flow. The user is then redirected to the GitLab Self-Managed server or Cloud instance, logs in, consents to AppScan Presence accessing the GitLab account, and then is redirected back to the AppScan Presence with the authorization code.
- AppScan Presence gets the user access token
from the GitLab Self-Managed server or Cloud instance or cloud (4) and sends
it back to the user (3) together with a script that sends the token to ASoC using
window.postMessage. - ASoC uses the GitLab access token (3) to get a list of repositories that are accessible by the user and to the GitLab app that is used by AppScan Presence. The user can then choose a repository to scan.
- Before a scan is created for the selected repository, ASoC verifies that the repository is accessible by
the user. The AppScan Presence API (3)
function
RepoSignaturecreates a signature for the repository details (repository owner and repository name). Once access is verified, the repository details are signed with a private key that is unique for the AppScan Presence. The signature is returned by the API call to ASoC. - ASoC creates a scan using UsersAPI (2) by provisioning the AppScan Presence ID (Git Connect), the repository details and the signature. UserAPI verifies the signature using a public key associated with the provided AppScan Presence instance. If the validation succeeds, a scan is created for the repository.
- The AppScan Presence service, which polls the AppScan Presence WebAPI (5) for tasks, gets a new task to fetch the scanned repository. The AppScan Presence connects to the GitLab Self-Managed server or Cloud instance (6) using access token from config file, fetches the repository as ZIP file, and streams it to the AppScan Presence WebAPI (UploadRepo)
- The repository ZIP file is stored in ASoC and can be scanned. When the scan is done, the results are viewed and analyzed in ASoC. The results contain links to the GitLab Self-Managed server or Cloud instance, referencing the relevant lines in the code for triage and remediation. ASoC can open a new tab with the relevant code.