Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image Removed

Info
titleControlled WhiteSource Integration Release

This is a controlled WhiteSource integration release. For more information, please contact support@whitesourcesoftware.com

Table of Contents

Introduction

Info
titleSupported Bitbucket Products

This integration only supports Bitbucket Server and Bitbucket Data Center instances. It does not currently support Bitbucket Cloud instances.

WhiteSource for Bitbucket Server is a Bitbucket Server app, scanning your repositories, as part of your WhiteSource account.

It is an integrated product within Bitbucket Server that shows a high-level security overview in the Bitbucket repository, detects all open source components and displays all vulnerabilities for these components.

It generates comprehensive up-to-date reports on the Bitbucket Server ‘WhiteSource integration’ tab of the scanned repository. In addition, you will be able to view the scanned repositories in the WhiteSource portal.

WhiteSource for Bitbucket Server is part of WhiteSource for Developers and includes continuous automated dependency updates with WhiteSource Remediate, using fix Pull Requests.

Prerequisites

The following requirements must be accommodated before installing the WhiteSource server software.

  • Access to a working WhiteSource Application and a user with Admin privileges.
  • Admin privileges on the Bitbucket instance
  • The deployment includes two environments:
    • Build environment where the image is built.
    • Deployment environment where the image is deployed.

Build Environment

This build environment can be the same one as the deployment environment on which the WhiteSource Docker image is deployed. It requires the following:

Hardware Requirements

  • CPU: Dual-Core, 2Ghz or higher (Intel or AMD)
  • RAM: 16GB
  • Storage: 16 GB

Environment Requirements

  • An internet connection for the entire duration of the build procedure.
  • When using a Container Orchestration Platform (i.e Kubernetes, ECS, Rancher etc.), please make sure you have logs collection in place: ELK, Splunk or similar. If you are not using an Orchestration platform for the containers, the logs will be collected in designated folders. 
  • A user with admin privileges: If the operating system is Windows, then you must have administrative privileges. If the operating system is Linux, then you must have root privileges.
  • Docker server version 18 and above. You can verify the Docker version by entering the following:
Code Block
docker –version
  • Software and files delivered by WhiteSource:
    • WhiteSource Docker distribution artifacts that are delivered as a tar.gz or zip file (For example, agent-4-bitbucket-19.2.1.tar.gz  or agent-4-bitbucket-19.2.1.zip).
    • You can obtain these files from WhiteSource Support

Target Environment

The image is installed on the target environment. This environment requires the following:

Hardware Requirements

  • CPU: Dual Core, 2Ghz or higher (Intel or AMD)

  • RAM: 16GB

  • Storage: 16 GB

Environment Requirements

  • A user with admin privileges: If the operating system is Windows, then you must have administrative privileges. If the operating system is Linux, then you must have root privileges.

  • Docker server version 18 and above. You can verify the Docker version by entering the following:
Code Block
docker –version
  • Port 5678 must be open at all times. This port will be used to receive webhooks from the Bitbucket add-on.
  • Access to the WhiteSource Application is required at times for the operation of the WhiteSource for Bitbucket Server.
Info

The access to the app can be checked by issuing an HTTP GET request using a web browser or a utility (e.g., cURL, wget):
https://<your-base-url>/healthCheck
(e.g., https://saas.whitesourcesoftware.com/healthCheck)

It is recommended to verify that the returned status is 200 (OK).
This is only a validation URL. Access must be open for all paths and endpoints under the app’s subdomain.

  • If a proxy server is available, then the following proxy settings need to be obtained:
    • URL
    • Port number
    • Username and password (for authenticated access)
  • A valid SSL certificate and KeyStore containing the certificate.

User Steps on Build Machine

Prepare for Installation

Download the ‘tar.gz’ file (‘agent-4-bitbucket-<version>.tar.gz’) for Linux or 'zip' file Windows (‘agent-4-bitbucket-<version>.zip’)

Installation and Configuration

In Windows, extract ‘agent-4-bitbucket-<version>.zip’ to an empty folder. In Linux, extract ‘agent-4-bitbucket-<version>.tar.gz’ to an empty folder.  
The extraction creates the following items:

  • ‘wss-bb-add-on’: Includes the jar of the add-on that will be uploaded to your Bitbucket server.
  • ‘wss-bb-app’: WhiteSource BitBucket server application. This application is responsible for communication between WhiteSource application and WhiteSource Bitbucket add-on. (located in the path 'wss-bb-app/docker/Dockerfile')
  • ‘wss-config’: UI Configuration tool and related configuration file template.
  • 'wss-deployment': Deployment template (for example, deploying the integration using Helm charts)
  • 'wss-remediate': WhiteSource Remediate worker
  • ‘wss-scanner’: WhiteSource BitBucket repository-scanner. wss-scanner is responsible for scanning Bitbucket repositories. (located in the path 'wss-scanner/docker/Dockerfile')
  • ‘build.sh’/'build.bat’ (Linux/Windows): The build script

Modifying the Scanner Dockerfile

See here for more information on which package managers are part of the scanner image as well as how to add additional package managers.

Installing the WhiteSource App in Bitbucket Server

There are two ways to install the WhiteSource App in Bitbucket Server - by installing the app via the Atlassian marketplace for Bitbucket, or by uploading the JAR file directly from the extracted WhiteSource for Bitbucket folder.

Installing via the Atlassian Marketplace

Navigate to the Administration page (<your/bitbucket-server/url>:<port>/admin) and then click Find new apps under the ADD-ONS menu.

  1. In the search field, enter whitesource and press Enter. The WhiteSource App is displayed.
  2. Click Install.

Uploading the WhiteSource App JAR file

Navigate to the Administration page (<your/bitbucket-server/url>:<port>/admin) and then click Manage apps under the ADD-ONS menu.

  1. Click Upload app and select the JAR file located in the wss-bb-add-on folder.
  2. Click Upload.

Creating a Bitbucket WhiteSource user and generating a WhiteSource Activation Key

...

The displayed fields are the following:

    1. Bitbucket Server URL: Your Bitbucket server URL. For example: https://bitbucketdev.com.
    2. Bitbucket Username: Your Bitbucket username. The user has to be an admin in Bitbucket. (The user that was created in step 3). Notice: it must be a username, please do not insert an email.
    3. Bitbucket Personal Access Token: Your Bitbucket personal access token with admin privileges. See also an explanation about retrieving a personal access token in Bitbucket documentation. (Link in Bitbucket server: <your/bitbucket-server/url>:<port>/plugins/servlet/access-tokens/manage)
    4. Bitbucket Webhook URL:  Enter the webhook URL in the following format: http://<docker-wss-bb-app-destinationURL>:5678/payload.
  1. When clicking on ‘Get Activation Key’, your activation key will be generated. A new Service user will also be created for this integration inside the WhiteSource Application with a WS prefixNOTE: Do not remove this Service user and ensure this user remains part of the Admin group. 

Running the UI configuration tool from the ‘wss-configuration’ Directory

This editor enables you to configure the deployment file according to your specific configuration requirements. 

...

          Please copy the Activation key that was generated in WhiteSource application and paste it to 'Activation Key' property in the editor.

...

Details on Attributes of the Configuration file

...

The ability to globally enable/disable Issues creation across all of your organization's repositories. Default value: true 

(NOTE: Supported from version 20.5.1.3 only)

...

The ability to globally enable/disable build statuses across all of your organization's repositories. Default value: true 

(NOTE: Supported from version 20.5.1.3 only)

Info

You can export the JSON file at any time, even if you did not finish editing it in order to save your configurations and to enable assigning the configuration of a specific section to the appropriate professional in your organization (e.g., datasource section may be assigned to the DBA of your organization).

...

Optional step: If you want to pull the images from another machine and run them as a container, push them to your Docker registry.  

Building and Tagging the Docker Images

There are three different ways of building the Docker images.

Info

A total of 3 images will be built: wss-bb-app, wss-scanner, and wss-remediate.

1. Using an Executable Script File (Recommended)

Run the build.bat or build.sh executable script file (Windows/Linux).
Both files are located in the root of the extracted agent-4-bitbucket-<version>.zip or agent-4-bitbucket-<version>.tar.gz files.

For Windows:

Run build.bat file which is located in the main folder where you extracted the agent-4-bitbucket zip file.

In order to ensure that the build succeeded, run the command docker images and check if  wss-bb-app and wss-scanner and wss-remediate images were created.

For Linux:

Run build.sh file which is located in the main folder where you extracted the agent-4-bitbucket tar.gz file.

In order to ensure that the build succeeded, run the command docker images and check if  wss-bb-app and wss-scanner and wss-remediate images were created.

2. Manually Build the Images

To run the steps of the build file manually, run the following commands directly:

NOTE: If you have already run the build file, skip these steps and continue to Target machine: Running the Containers step.

Code Block
docker build -t wss-bb-app:<version> wss-bb-app/docker
docker build -t wss-scanner:<version> wss-scanner/docker 
docker build -t wss-remediate:<version> wss-remediate/docker

# For example:
docker build -t wss-bb-app:19.9.1.1 wss-bb-app/docker
docker build -t wss-scanner:19.9.1.1 wss-scanner/docker
docker build -t wss-remediate:19.8.1 wss-remediate/docker

3. Using a Docker Registry

If you are using a private Docker Registry, run the following commands to push the images into your registry:

Code Block
docker push <registry>/wss-bb-app:<version>
docker push <registry>/wss-scanner:<version>
docker push <registry>/wss-remediate:<version>

# For example:
docker push my-registry/wss-bb-app:19.9.1.1
docker push my-registry/wss-scanner:19.9.1.1
docker push my-registry/wss-remediate:19.8.1

After executing the commands, you should be able to view the images in your registry.

Target Machine: Run the Containers

Deploying Using Docker

On the target environment, create a directory (e.g., ‘<path/to/config/dir>’) and add to it the configuration properties JSON file (prop.json) that you previously edited and exported using the Configuration Editor.
Then, you will need to create a network bridge and run the following Docker containers by using Docker or Kubernetes.

Create a network bridge (this will create a private network between the different containers, since all containers need to run within the same network):

Code Block
docker network create -d bridge my_bridge

...

Code Block
docker run --name remediate-server --network my_bridge -e LOG_LEVEL=debug -p 8080:8080 -v <path/to/config/directory>/prop.json:/etc/usr/local/whitesource/conf/prop.json -v /tmp:/tmp wss-remediate:<version>

# For example:
docker run --name remediate-server --network my_bridge -e LOG_LEVEL=debug -p 8080:8080 -v c:/tmp/bb/prop.json:/etc/usr/local/whitesource/conf/prop.json -v /tmp:/tmp wss-remediate:19.5.1
Info
titleChanging Remediate Server Port

If port 8080 is not available, you can use a different port by modifying only the second port in the 'docker run' command. For example:

docker run --name remediate-server --network my_bridge -e LOG_LEVEL=debug -p 8082:8080 -v c:/tmp/bb/prop.json:/etc/usr/local/whitesource/conf/prop.json -v /tmp:/tmp wss-remediate:19.5.1

Run the 'wss-bb-app' app container:

Code Block
docker run --name wss-bb-app --network my_bridge -p 9494:9494 -p 5678:5678 -v <path/to/config/directory>:/etc/usr/local/whitesource/conf wss-bb-app:<version>

# For example:
docker run --name wss-bb-app --network my_bridge -p 9494:9494 -p 5678:5678 -v c:/tmp/bb/:/etc/usr/local/whitesource/conf/ wss-bb-app:19.5.1.1

Run the ‘wss-scanner’ scanner container:

Code Block
docker run --name wss-scanner-bb --restart=always --network my_bridge -p 9393:9393 -v <path/to/config/directory>:/etc/usr/local/whitesource/conf/ wss-scanner:<version>

# For example:
docker run --name wss-scanner-bb --restart=always --network my_bridge -p 9393:9393 -v c:/tmp/bb/:/etc/usr/local/whitesource/conf/ wss-scanner:19.5.1.1

Deploying Using Helm Charts

The wss-deployment folder consists of the following structure:

  • helm
    • configs
    • templates
      • config.yaml
      • wssScmIntegration.yaml
    • Chart.yaml
    • values.yaml

Copy the helm folder from wss-deployment to your target environment. Inside the helm/configs folder, add the configuration properties JSON file (prop.json) that you previously edited and exported using the Configuration Editor.

Chart.yaml

This file contains information about the chart.

NOTE: Do not edit this file.

Values.yaml

This file represents the WhiteSource integration image names and versions.

...

For each image declaration (wssscanner, wsscontroller, wssremediate), replace {image} and {version} with the actual built image name and version.  NOTE: For wsscontroller, use the name and version of the wss-bb-app image.

An optional parameter, imagePullSecrets, can be added to this file in case Docker repository authentication is required.

configs/prop.json

In the helm folder, create a new folder named configsand add to it the configuration properties JSON file (prop.json) that you previously edited and exported using the Configuration Editor.

templates/config.yaml

This is a configuration file pointing to the configs/prop.json file.

NOTE: Do not edit this file.

templates/wssScmIntegration.yaml

This is a configuration file containing all the parameters for deploying the integration.

NOTE: In this file, there are 3 dashes ("- - - ") that separate the services  Do not remove them.

In order for the webhook URL to be accessible publicly by the integration, a load balancer service must be added to the file. An example of such a service is provided below:

apiVersion: v1
kind: Service
metadata:
  name: lb1
  namespace: acme
  annotations:
    external-dns.alpha.kubernetes.io/hostname: helm.acme.io
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
    service.beta.kubernetes.io/aws-load-balancer-ssl-negotiation-policy: "ELBSecurityPolicy-TLS-1-2-2017-01"
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-7:834027593108:certificate/4720e07a-a231-4fd5-9c4a-12ab1450567d
spec:
  type: LoadBalancer
  ports:
  - port: 443
    name: https
    targetPort: 5678
  selector:
    app: wss-controller

Activating the WhiteSource Integration

...

Remediation

WhiteSource Remediate provides continuous automated dependency updates, saving time and reducing your security risks. To read more and configure automated Pull Requests, see WhiteSource Remediate

Initiating a Scan

A WhiteSource scan is initiated via a valid Bitbucket push command. A valid push command meets at least one of the following requirements:

  • One of the commits in the push command added/removed a source file(s) that has an extension supported by WhiteSource.
    Refer to the WhiteSource Languages page in order to find out whether or not a specific language and its extensions are supported. 

  • One of the commits in the push command includes an addition/modification of the package manager dependency file(s).
    Refer to the list of supported dependency files to find out whether your dependency files are supported.

NOTE: a push command may consist of multiple commits.

Viewing Details of the Scan

Results can be viewed in the following places:

  • The Issues tab within the GitHub project
  • The WhiteSource Security/License Check within the Bitbucket repo Commits tab.
  • The WhiteSource UI.
  • Via email notifications.

Viewing Details of an Issue

See here for more information.

Viewing WhiteSource Security Checks

In the Commits tab you can view the status and results of each scan. Click a specific build icon in order to view the Builds page.

Types of Indicators

The following build status indicators are available as feedback on the head commits:

  • In progress: The WhiteSource scan is in progress.
  • Success: The WhiteSource scan completed successfully and no vulnerabilities were detected. 
  • Failed: The WhiteSource scan did not complete successfully, this is the default for all completed scans. NOTE: a failed status may be shown due to security vulnerabilities, or due to an error that occurred during the scan.

Samples of Status Check Indicators

In Progress

The following is a sample of a In Progress status, which indicates that the security check is currently scanning the head commit.

Image Removed

Success

When no vulnerabilities are found and no errors occurred during the scan, WhiteSource will display the following status check, and a security report indicating that no vulnerabilities were detected:

Image Removed

Failed

...

  • Click on the ‘WhiteSource Security Check’ link to view the security report on all vulnerabilities that were found for the specific commit’s scan. It includes the following columns:

    • CVE: A link to the related CVE page for the vulnerability. Displayed in a collapsible format (click the arrow to expand/collapse for more information regarding the vulnerability).
    • Severity: Overall score of the severity (High, Medium or Low).
    • CVSS Score
    • Vulnerable Library
    • Suggested Fix 
    • Issue - A link to the relevant issue generated by WhiteSource (when available)

...

Viewing WhiteSource License Checks 

In the Commits tab you can view the status and results of each scan. Click a specific build icon in order to view the Builds page.

Types of Indicators

The following build status indicators are available as feedback on the head commits:

  • Success: No license policy violations were detected. 
  • Failed: One or more license policy violations were detected during the WhiteSource scan.

Viewing Details in the WhiteSource UI

  • WhiteSource projects will have the same name as the corresponding Bitbucket repository, with a "BB_" prefix, unless otherwise specified in the .whitesource file using a project token.
  • The name of the WhiteSource product will be the same as that of the Bitbucket project preceded by a "BB_" prefix if the Bitbucket repository is under a Project. Otherwise, the name will be your Bitbucket username preceded by "BB_".

Accessing Scan Statistics via API

See here for more information.

Health Check APIs

See here for more information.

The .whitesource File

A WhiteSource configuration file (.whitesource) is a JSON file added to each repository that is enabled for a scan. It provides configurable parameters for the WhiteSource scan.

The .whitesource file is only added in the default branch of the repository (unless modified, it is the master branch).
Code Block
languagejs
title.whitesource file
{
  "scanSettings": {
    "configMode": "AUTO",
	"configExternalURL": "",
    "projectToken": "",
	"baseBranches": []
  },
  "buildSettings": {
    "displayMode": "diff",
	"failBuilds": true
  },
  "issueSettings": {
    "minSeverityLevel": "LOW"
  }
}

Parameters

Global Settings

...

When the global configuration is enabled, this parameter will specify the location of the whitesource-config repository from which it will inherit its configuration. It must contain the Bitbucket user name, repository name and branch (optional) of the repo-config.json file location. The default branch is 'master', but can be modified according to the location of the repo-config.json file in the whitesource-config repo. 

NOTE: You can override specific parameters that are relevant only in the specific repository by adding these after this parameter.

Examples:

Using only values defined in the global configuration:

Code Block
languagejs
"settingsInheritedFrom": "whitesource/whitesource-config@master"

Using values defined in the global configuration and overriding the scan settings parameters:

Code Block
languagejs
"settingsInheritedFrom": "whitesource/whitesource-config@master", 
"scanSettings": {
  "projectToken": "12345",
  "baseBranches": ["master","integration"]
}

...

Scan Settings (scanSettings)

...

Parameter 

...

Type

...

Description

...

Required 

...

Default

...

The configuration mode to be used for each scan. There are three options:

  • AUTO - Automatic mode. This will use the default WhiteSource configuration. 

  • LOCAL - Local mode. This will look for a local 'whitesource.config' file to be provided in the root folder of the current repository. The configuration file should be in the same format as the Unified Agent configuration file.  NOTE: Not supported in the Global Configuration.

  • EXTERNAL - External mode. This will look for a configuration file specified according to the configExternalURL parameter. 

...

The URL of the external configuration file (you can choose any filename). The configuration file content should be in the same format as the Unified Agent configuration file.

The following protocols are supported: 'ftp://', 'http://', 'https://'.

...

Adds the ability to map a Bitbucket repository to a WhiteSource project. The parameter used needs to be the WhiteSource project token.

NOTE: Not supported in the Global Configuration.

...

Adds the ability to specify one or more base branches for which scanning results will be sent to a new WhiteSource project.

Example usage: ["master", “integration"]

This will set both master and integration branches as base branches.

Note the following:

  • An Issue will only be created for the specified branch names.
  • Repositories which do not contain the baseBranches parameter will have issues generated for all branches.
  • For each specified branch, a WhiteSource project will be created. The name of the project will contain a suffix "_branchname". For example, MyApp_dev. This suffix will not apply to the default branch.

NOTE: This parameter is available only from version 20.7.1.

...

No

...

Empty 

In this case, the base branch only consists of the default branch.

...

When enabled, a new WhiteSource License Check will be generated for each valid push.

NOTES:

  • This parameter is available only from version 20.11.2.

  • You must have it least one policy of match type By License Group defined with a Reject action in the WhiteSource UI.
  • The policy name in the WhiteSource UI must start with a "[License] " prefix.
    For example, "[License] PolicyName".

...

Build Settings (buildSettings)

...

Parameter 

...

Type

...

Description

...

Required 

...

Default

...

How to display WhiteSource security information for a scan performed on a non-base branch:
  • When set to diff - Only the diff of detected vulnerabilities between the current commit and its base branch commit will be displayed. NOTE: This value is only supported when using the baseBranches configuration.
  • When set to baseline - A summary of all detected vulnerabilities in the full repository inventory will be displayed.

...

The app provides checks in commits and pull requests on any repository branch. This parameter defines the conclusion status for when a WhiteSource Security Check is completed

When the parameter is set to false, the conclusion status of a WhiteSource Security Check will always be 'Success', even if the check fails. This way, any repository member is able to merge a pull request, even if a WhiteSource Security Check found security vulnerabilities.

When the parameter is set to true (default)the conclusion status of a WhiteSource Security Check will be 'Failure' in cases where WhiteSource Security Check found security vulnerabilities or an error occurred during the scan. When this configuration is defined, a policy for approving a pull request is enforced. In this setting, only the administrator of the repository can approve the merging of a pull request that contains one or more checks with a 'Failure' status.

...

The app provides checks in commits and pull requests on any repository branch. This parameter defines the conclusion status for when a WhiteSource License Check is completed

When the parameter is set to false, the conclusion status of a WhiteSource License Check will always be 'Success', even if the check fails. This way, any repository member is able to merge a pull request, even if a WhiteSource License Check found license policy violations.

When the parameter is set to true (default)the conclusion status of a WhiteSource License Check will be 'Failure' in cases where WhiteSource License Check found license policy violations or an error occurred during the scan. When this configuration is defined, a policy for approving a pull request is enforced. In this setting, only the administrator of the repository can approve the merging of a pull request that contains one or more checks with a 'Failure' status.

...

Whether to show additional WhiteSource information such as the project token inside the WhiteSource Build Status (after the scan token).

WhiteSource information is only displayed if the commit originated from a base branch.
If the commit exists in multiple branches, the WhiteSource information displayed will only represent the origin base branch (i.e. where the baseBranches parameter was defined).

The following hidden JSON object will also be added inside the Build Status when this parameter is enabled:

Code Block
<!-- <INFO>{"projectToken":"8cd2d2a8651145c087609e0a43f783e95f7008cb908541498348fed529572e01"}</INFO> -->

...

Issue Settings (issueSettings)

...

Enables users to decide whether to open a new Issue only if a certain severity level is available on a detected vulnerability.

Available values for minSeverityLevel:

  • NONE - No Issues will be generated.

  • LOW - Any Low/Medium/High vulnerabilities found will generate an Issue.

  • MEDIUM - Any Medium/High vulnerabilities found will generate an Issue.

  • HIGH - Any High vulnerabilities found will generate an Issue.

NOTE: The WhiteSource Security Check summary is also affected by this parameter.

...

Whether to generate an Issue for every detected license policy violation.

NOTE: This parameter is relevant only if enableLicenseViolations (scanSettings) is set to true.

...

true

(only if enableLicenseViolations (scanSettings) is set to true)

Providing a Global Configuration File

NOTE: Supported from version 20.5.1.3 only.

You can provide a custom .whitesource configuration file as part of the wss-bb-app container, in order to apply it globally to all of your organization's repositories. Doing so will apply the file to all onboarding pull requests for newly-selected repos. Repos which were already selected and activated before this change will not be affected by this global configuration. Only newly onboarded repos will be affected. 

To apply this global change, do as follows:

  1. Stop the wss-bb-app container.
  2. In the "wss-bb-app/conf" folder, add your custom “.whitesource” file (where the prop.json file is located).
  3. Start the  wss-bb-app container.

Upgrading to the Latest Docker Images

...

  • wss-bb-app
  • wss-scanner
  • remediate-server

Stop currently-running Docker containers from the previous version:

Code Block
docker stop <wss-bb-app> <wss-scanner> <remediate-server>

Remove the Docker containers from the previous version:

Code Block
docker rm <wss-bb-app> <wss-scanner> <remediate-server>

...

Uninstalling

You can easily uninstall this add-on by doing the following:

...

This page is available at: https://docs.mend.io/bundle/integrations/page/mend_for_bitbucket_server_and_data_center.html