If you are using JFrog Pipelines for development automation, you can integrate it with NeuraLegion to run security scans on every new build as part of your SDLC.
For this example, we use a sample vulnerable application in a public GitHub repository. The repository also contains the corresponding JFrog Pipeline YAML file. You can use this application for a test project.

Prerequisites

YAML File Breakdown

Resources and pipelines configuration

The YAML file contains configuration for security scanning and the pipeline itself (called nexploit), with details of the repository and execution steps.

resources:
  - name: jfrognexploit
    type: GitRepo
    configuration:
      gitProvider: GH
      path: NeuraLegion/jfrog-example

pipelines:
  - name: nexploit
    steps:
      - name: nexploit
        type: Bash
        configuration:
          integrations:
            - name: Nexploit
          inputResources:
            - name: jfrognexploit

A Git repository is given as a JFrog resource, so you can use this repository for any events, such as pushing a new commit or as a trigger to run a security scan.

Execution steps

The execution steps are the following:

  1. Setting up the environment (NodeJS).
  2. Installing the NeuraLegion CLI utility. Using the NeuraLegion CLI commands, you can run, poll status and stop scans directly from your pipeline.
execution:
          onExecute:
            - sudo apt update
            - sudo chmod 1777 /tmp
            - sudo apt update
            - sudo apt install nodejs npm
            - sudo apt install --fix-broken
            - sudo npm install -g @neuralegion/nexploit-cli --unsafe-perm=true
            - |

Scan setup

The scan setup includes the following details:

  1. A crawler will be used on the target to define the attack surface and optimize the security tests.
  2. NEURALEGION_TOKEN (API key) is required to use the NeuraLegion CLI.
  3. Interval of polling the scan results (detected issues).
  4. The length of the scan (timeout).
  5. When polling the scan results, it is recommended to follow the fail-fast principle by using the breakpoint command. The scan stops automatically once a high severity issue is detected. See the NeuraLegion CLI command list for a full list of commands you can use for a scan.
 SCAN_ID=$(nexploit-cli scan:run                                                \
                  --name "💎 Broken Crystals for a #${res_jfrognexploit_commitSha} #${run_id}" \
                  --crawler https://brokencrystals.com                                         \
                  --token $int_Nexploit_NEURALEGION_TOKEN)
            - printf "Scan was started with ID https://app.neuralegion.com/scans/$SCAN_ID"
            - |
              nexploit-cli scan:polling               \
                --interval 30s                        \
                --timeout 12m                         \
                --token $int_Nexploit_NEURALEGION_TOKEN  \
                --breakpoint high_issue $SCAN_ID
          onComplete:
            - nexploit-cli scan:stop --token $int_Nexploit_NEURALEGION_TOKEN $SCAN_ID

Step-by-Step Guide

Step 1 : Set up an Automatic Scan in JGrog

On the Node Pools page, click Add Node Pool and configure.

Step 2: Integrate GitHub with JFrog

  1. Get a GitHub token. In GitHub, select Settings > Developer Settings > Personal Access Tokens > Generate New Token.
  2. Copy the generated token.
  3. In JFrog, select Integrations > Add an integration.
  1. Give the integration a name, select the type and paste the token.

Step 3: Integrate NeuraLegion with JFrog

  1. Generate an API key (NEURALEGION_TOKEN) in the NeuraLegion App. Go to User Settings > Create New API Key > Select All > create and copy the token.
  2. In JFrog, select Integrations > Add an integration.
  3. Give the integration a name, select the type and paste the token.

Step 4: Add YAML Pipeline Source

  1. In JFrog, select Pipeline Sources > Add Pipeline Source > From YAML.
  2. Select your GitHub integration for SCM provider integration, enter the repository name with JFrog configuration and the branch.
  3. Select Create Source.

You are now ready to build and run a new scan!

Step 5: Run a new scan

In JFrog, select Pipelines > nexploit > nexploit > Trigger this step.

You will then get a view of your current CI process.

In the image above, you can see the security scan has started and the results are being polled.

You can now view the security scan status and results in the dashboard in the NeuraLegion App. .

On detection of a high severity issue, the build is failed and the scan is stopped automatically.

The scanner is set to automatically scan every time there is a change committed in the repository, enabling developers to run an automated, comprehensive and accurate security scan on every commit.


Did this page help you?