Skip to main content

GitHub

GitHub is a version control and collaboration platform that allows developers to host their own source code. It provides features such as issue tracking, code review, and integration with various tools and services. You can bring code and code repository data from GitHub into Brinqa to enhance your organization's security and risk management capabilities.

This document details the information you must provide for the connector to authenticate with GitHub and how to obtain that information from GitHub. See create a data integration for step-by-step instructions on setting up the integration.

Required connection settings

When setting up a data integration, select GitHub from the Connector drop-down. If you cannot find the connector in the drop-down, make sure that you have installed it first. You must provide the following information to authenticate GitHub with Brinqa:

  • API URL: The GitHub API URL. The default URL is https://api.github.com.

  • App ID: The GitHub App identifier. The app ID is associated with the GitHub App used to access the GitHub API. The app ID is a six-number string such as 123456.

  • Private key: The private key associated with the GitHub App, which must have permissions to log in to the API server and return data.

Generate GitHub authentication credentials

You must register a new GitHub App for the connector to authenticate and access the GitHub API. To create a new GitHub App and generate a private key, follow these steps:

  1. Sign in to your GitHub account.

  2. Click the profile photo in the upper-right corner of the page, and then click Settings.

    • If you want to limit the GitHub connector's access to a specific organization rather than a personal account, click Your organizations in the drop-down instead of Settings. Then, to the right of the organization, click Settings. Follow the same steps outlined below for further configuration.
  3. In the navigation menu, select Developer settings.

  4. Click GitHub Apps, then New GitHub App, and complete the following fields. The fields not mentioned can be left as is.

    • GitHub App name: The name of your GitHub App.

    • Homepage URL: The full URL to your app's website. For example, https://www.example.com/github-app. www.example.com represents the domain of your company or developer who created the GitHub App, and /github-app is a specific page within your website dedicated to providing information about the app.

      • If you lack a specific URL and your application's source code is located in a public repository, you may use the repository URL. Alternatively, you can use the URL belonging to the organization or individual who owns the application. For example, https://github.com/yourusername/your-github-app. yourusername represents the GitHub username of the person or organization who created the app, and your-github-app is the name of the repository containing the app's source code and documentation.
    • Permissions: Add the following permissions required by the connector:

      • Repository:

        • Code scanning alerts: Read-only
        • Contents: Read-only
        • Dependabot alerts: Read-only
        • Issues: Read-only
        • Metadata: Read-only
        • Packages: Read-only
        • Secret scanning alerts: Read-only
      • Organization: None.

      • Account: None.

  5. Click Create GitHub App.

If the registration is successful, the page reloads and displays information about your new GitHub App. You can find the App ID under the "About" section at the top of the page. This six-digit string, along with the private key, is required to authenticate the GitHub connector with Brinqa.

  1. Scroll down to Private keys and click Generate a private key.

GitHub generates a new private key and downloads it to your local storage as a .pem file. Copy the private key and save the .pem file in a secure location.

  1. In the navigation menu, click Install App.

  2. Click Install next to the account where you want to install the GitHub App on. You are presented with two options:

    • All repositories: The GitHub App has access to all existing and any future repositories that are owned by the account. This includes public repositories, but the app can only read their contents, not make changes.

    • Only select repositories: Click the "Select repositories" drop-down and select the repositories you want to install the GitHub App to. This also includes read-only public repositories.

  3. Review the permissions and click Install.

note

For additional information, see GitHub documentation about Creating GitHub Apps, Install your own GitHub App, and Managing private keys.

Additional settings

The GitHub connector contains an additional option for specific configuration:

  • Code Repository custom properties: A comma-separated list of custom property names used by the Code Repository object on Github. These names are case-insensitive and will be created as attributes in the source data model.

  • Page size: The maximum number of records to get per API request. The default setting is 100. It is not recommended to go over 100.

Types of data to retrieve

The GitHub connector can retrieve the following types of data from the GitHub API:

Table 1: Data retrieved from GitHub

Connector ObjectRequiredMaps to Data Model
Code RepositoryYesCode Repository
Open Source FindingYesOpen Source Finding
Open Source Finding DefinitionYesOpen Source Finding Definition
PackageNoPackage
Secret Scanning AlertYesStatic Code Finding
Secret Scanning Alert DefinitionYesStatic Code Finding Definition
Static Code FindingYesStatic Code Finding
Static Code Finding DefinitionYesStatic Code Finding Definition
info

The GitHub connector does not currently support operation options for the types of data it retrieves.

For detailed steps on how to view the data retrieved from GitHub in the Brinqa Platform, see How to view your data.

Attribute mappings

Click the tabs below to view the mappings between the source and the Brinqa data model attributes.

Table 2: Repository attribute mappings

Source Field NameMaps to Attribute
AUTO_MERGE_ALLOWEDLocal variable
Created atfirstSeen
DESCRIPTIONdescription
HOME_PAGE_URLLocal variable
Is archivedLocal variable
Is disabledLocal variable
Is emptyLocal variable
Is forkLocal variable
Is in organizationLocal variable
Is lockedLocal variable
Is mirrorLocal variable
Is privateLocal variable
Is security policy enabledLocal variable
Is templateLocal variable
Issues enabledLocal variable
LanguagesLocal variable
Last pushedLocal variable
LATEST_RELEASELocal variable
LOCK_REASONLocal variable
Merge commit allowedLocal variable
Namename
Organization IDLocal variable
Organization nameLocal variable
Ownerowners
ParentLocal variable
Projects enabledLocal variable
Rebase merge allowedLocal variable
SSH urlLocal variable
STARGAZER_COUNTLocal variable
Squash merge allowedLocal variable
Sys IDuid
TopicsLocal variable
Updated atlastSeen
UrlLocal variable
info

Local variable indicates that the field is processed within a specific context, such as a particular workflow or calculation. Unlike other attributes, local variables aren't mapped to the unified data models. They only exist on the source data model.

Use CVSS calculator indicates that the CVSS (Common Vulnerability Scoring System) vectors and scores aren't directly mapped to a specific attribute on the UDM. Instead, a specialized library calculates the CVSS scores from the provided CVSS vector strings.

APIs

The GitHub connector uses both GitHub REST API endpoints and the GitHub GraphQL API, providing a flexible approach to retrieve your GitHub data.

GitHub REST API

The GitHub connector uses the GitHub REST API. Specifically, it uses the following endpoints:

Table 7: GitHub REST API Endpoints

Connector ObjectAPI Endpoint
Static Code FindingGET https://api.github.com/repos/OWNER/REPO/code-scanning/alerts
Static Code Finding DefinitionGET https://api.github.com/repos/OWNER/REPO/code-scanning/alerts
Secret Scanning AlertGET https://api.github.com/repos/OWNER/REPO/secret-scanning/alerts

GitHub GraphQL API

The GitHub connector also uses the GitHub GraphQL API. Specifically, it uses the https://api.github.com/graphql endpoint and the following queries:

Table 8: GitHub GraphQL API queries

Connector ObjectGraphQL Query
Code RepositoryCode Repository GraphQL queries
Open Source FindingOpen Source Finding GraphQL query
Open Source Finding DefinitionOpen Source Finding Definition GraphQL query
PackagePackage GraphQL query

Code repository GraphQL queries

The following GraphQL query retrieves details about your organization, such as repositories, metadata, languages uses, repository topics, and more:

   query {
organization(login: "organization-login") {
id
name
repositories(first: 100, after: null) {
nodes {
id
name
description
url
homepageUrl
sshUrl
stargazerCount
hasIssuesEnabled
hasProjectsEnabled
isArchived
isDisabled
isEmpty
isInOrganization
isLocked
lockReason
isMirror
isPrivate
isFork
isSecurityPolicyEnabled
isTemplate
mergeCommitAllowed
squashMergeAllowed
rebaseMergeAllowed
owner {
id
login
}
parent {
id
name
url
}
latestRelease {
id
name
isLatest
publishedAt
tag {
id
name
}
author {
id
login
}
}
licenseInfo {
id
key
}
languages(first: 100) {
nodes {
id
name
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
totalCount
}
repositoryTopics(first: 100) {
nodes {
id
topic {
id
name
}
}
}
pushedAt
createdAt
updatedAt
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
totalCount
}
}
}

The following GraphQL query retrieves information about your organization and its packages. It retrieves the first 100 packages, along with their details such as ID, name, package type, latest version, and associated repository. The pageInfo and totalCount fields provide pagination information and the total number of packages in the organization:

query {
organization(login: "organization-login") {
id
name
packages(first: 100, after: null) {
nodes {
id
name
packageType
latestVersion {
version
}
repository {
id
name
}
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
totalCount
}
}
}

Open source finding GraphQL query

The following GraphQL query retrieves information about a specific repository and its vulnerability alerts. It retrieves the first two vulnerability alerts, along with their details such as ID, number, creation timestamp, dependency scope, dismiss reason, and other related information about the security vulnerability and its state. The pageInfo and totalCount fields provide pagination information and the total number of vulnerability alerts in the repository:

query {
repository(name: "repository-name", owner: "organization-name") {
id
name
vulnerabilityAlerts(first: 2, after: null) {
nodes {
id
number
createdAt
dependencyScope
dismissReason
dismissedAt
dismisser {
id
login
}
fixedAt
securityAdvisory {
id
ghsaId
}
securityVulnerability {
firstPatchedVersion {
identifier
}
package {
name
}
severity
updatedAt
vulnerableVersionRange
}
state
vulnerableManifestFilename
vulnerableManifestPath
vulnerableRequirements
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
totalCount
}
}
}

Open source finding definition GraphQL query

The following query retrieves a list of security advisories updated since "2022-09-22T18:21:40Z". It retrieves the first 100 security advisories, along with their details such as CVSS score, CWEs, description, identifiers, origin, references, severity, summary, and related timestamps. The pageInfo and totalCount fields provide pagination information and the total number of security advisories:

query {
securityAdvisories(updatedSince: "2022-09-22T18:21:40Z", first: 100, after: null) {
nodes {
cvss {
score
vectorString
}
cwes(first: 100) {
nodes {
id
cweId
}
}
description
ghsaId
id
identifiers {
type
value
}
origin
publishedAt
references {
url
}
severity
summary
notificationsPermalink
permalink
updatedAt
withdrawnAt
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
totalCount
}
}

Package GraphQL query

The following query retrieves details about your organization, such as its unique identifier, name, and associated packages, along with information about their latest versions and related repositories:

query {
organization(login: "organization-name") {
id
name
packages(first: 100, after: null) {
nodes {
id
name
packageType
latestVersion {
version
}
repository {
id
name
}
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
totalCount
}
}
}

Changelog

The GitHub connector has undergone the following changes:

3.0.10

3.0.9

  • Made the Package object optional.

3.0.8

  • Fixed an issue where Code Repository records weren't getting synced.

3.0.7

  • Updated dependencies.

3.0.6

  • Fixed a data integration failure when attempting to sync Secret Scanning Alert, Static Code Finding, or Static Code Finding Definition objects.

3.0.5

  • Added a VALIDITY attribute to the Secret Scanning Alert object.

3.0.4

  • Changed the 'AUTO_DISMISSED' status to 'Fixed' in the Open Source Finding and Static Code Finding objects.

3.0.3

  • Enhanced to retrieve all statuses of the Open Source Finding object.

3.0.2

  • Fixed an issue on the CATEGORIES attribute that caused data integration to fail.

3.0.1

  • Removed the use of ImmutableSet.

3.0.0