Skip to main content
Skip table of contents

Ruby (Gems) with JFrog Artifactory - Host Rule Implementation

This article details the instructions to successfully configure our repo integrations with your Ruby private registries that are hosted in JFrog Artifactory. Ruby private registries can be accessed by authentication via a password or token. This will allow our repo integrations to scan your private Ruby packages for vulnerabilities and compliance.

Option 1: Generating a JFrog token

  1. Within the JFrog platform Artifactory, navigate to your Administration > User Management > Access Tokens setting:

  2. Click + Generate Token:

  3. In the Generate Token window, select the Scoped Token option and fill in the settings as seen here:

    1. Description: can be any value

    2. Token scope: Admin

    3. User name: can be any value

    4. Service: All

    5. Expiration time: Never

  4. Click on Generate. Copy the Username you defined and the token that is generated:

Option 2: Using your JFrog password

  1. Within the JFrog platform Artifactory, navigate to the repository where your Ruby packages are located

  2. Click on Set Me Up in the top-right corner of the page:

  3. Make sure the correct repository is selected within the Set Up a Gems Client window

  4. Enter your password and click on Insert:

  5. In the first command provided within the Configure tab, copy the value after the: and before the @ symbols. The command will look similar to the following syntax: gem source -a https://<emailaddress>:<COPYTHISVALUE>@<JFrog_Instance>/artifactory/api/gems/<JFrog_Repo_Name>/

Encrypting the JFrog token or password

For Mend-Hosted repo integrations (GitHub.com, Bitbucket Cloud, and Azure Repos)

  1. Navigate to our Mend's Repository Integration Secrets Encryption page

  2. Each secret you encrypt must be scoped to a GitHub org, Bitbucket Cloud Workspace, or Azure project, and its use will be restricted to those within the app. There are the following fields on the encryption page:

    1. Organization\Group - required; your GitHub org, Bitbucket Cloud Workspace, or your Azure project to which secrets are to be scoped

    2. Repository - optional; your GitHub or Azure repository to which secrets are to be scoped

    3. Raw value - required; your JFrog token that was created earlier in Option 1, or your JFrog password from Option 2

  3. Click on Encrypt. This will create an encrypted value, which is the result of the encryption to be used in the integration

  4. Copy this encrypted value

For Self-Hosted repo integrations (GitHub Enterprise, Bitbucket Server and Data Center, and GitLab)

Follow the steps outlined below to generate encryption for each of the Self-Hosted repo integrations:

  1. When generating a secret, there are the following fields on the encryption page:

    1. Organization\Group - required; your GitHub org, GitLab group, or Bitbucket group to which secrets are to be scoped

    2. Repository - optional; your repository to which secrets are to be scoped

    3. Raw value - required; your JFrog token that was created earlier in Option 1, or your JFrog password from Option 2

  2. Click on Encrypt. This will create an encrypted value, which is the result of the encryption to be used in the integration

  3. Copy this encrypted value

Where can I find the matchHost URL for Ruby?

The URL that is to be used for the matchHost setting in the hostRules can be found by following these steps:

  1. Within the JFrog platform Artifactory, navigate to the repository where your Ruby packages are located

  2. Click on Set Me Up in the top-right corner of the page:

  3. Make sure the correct repository is selected within the Set Up a Gems client window

  4. Go to the Resolve tab

  5. Your matchHost setting will be the --source value in the second provided command, typically using the following syntax: https://<JFrog_Instance>/artifactory/api/gems/<JFrog_Repo_Name>

NOTE: To accommodate different packaging format clients, for several repository types, when accessing the repository through Artifactory, the repository URL must be prefixed with api/<type> in the path. For more information on this Artifactory requirement, please see Artifactory’s documentation here.

Applying the hostRules

Within your repo-config.json (if you have a global setup) or, in your .whitesource file (if you are configuring at the repo level), include the following required hostRules settings:

  • matchHost - The URL of the JFrog repository where your Ruby packages are located. NOTE: You should have one rule for each JFrog repository where your Ruby packages are located - meaning there can be multiple hostRules.

  • hostType - ruby

  • userName -

    • When using a token (Option 1), this will be the Username value that was set when you created the JFrog token

    • When using a password (Option 2), this will be the email address of your JFrog account

  • token or password - The encrypted value that was generated

hostRules Examples

token Example:

CODE
{
  "hostRules": [
    {
      "matchHost": "https://<JFrog_Instance>/artifactory/api/gems/<JFrog_Repo_Name>",
      "hostType": "ruby",
      "userName": "hostrules",
      "encrypted": {
        "token": "3f832f2983yf89hsd98ahadsjfasdfjaslf............"
      }
    }
  ]
}

password Example:

CODE
{
  "hostRules": [
    {
      "matchHost": "https://<JFrog_Instance>/artifactory/api/gems/<JFrog_Repo_Name>",
      "hostType": "ruby",
      "userName": "engineers@mend.io",
      "encrypted": {
        "password": "p278djfdsi9832jnfdshufwji2r389fdskj........."
      }
    }
  ]
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.