JFrog Frogbot Documentation

repository·main·Indexed 18 days ago

https://github.com/jfrog/frogbot

A security-focused Git bot that automates vulnerability scanning (SCA, SAST, IaC), secrets detection, and license compliance. It operates via Pull Request scanning and periodic repository scanning to identify vulnerabilities and automatically create fix pull requests. Available as a CLI tool and a GitHub Action, it integrates with JFrog Xray to provide contextual analysis for Python, JavaScript, and Java.

Tokens
1.8K
Snippets
6
Records
10
Agent score
63%

What's inside JFrog Frogbot

  1. What is JFrog Frogbot?

    main

    JFrog Frogbot is a Git bot designed to scan Git repositories for security vulnerabilities. It operates in two primary modes:

    1. Pull Request Scanning: Scans pull requests immediately after they are opened but before they are merged. This allows you to identify and fix vulnerabilities before they are introduced into your codebase.
    2. Periodic Repository Scanning: Periodically scans the entire Git repository and automatically creates pull requests containing fixes for any detected vulnerabilities.

    Key security capabilities include:

    • Software Composition Analysis (SCA): Scans project dependencies against JFrog's vulnerability database.
    • Dependency License Validation: Ensures dependency licenses comply with your approved list.
    • Static Application Security Testing (SAST): Detects zero-day vulnerabilities in source code operations.
    • CVE Vulnerability Contextual Analysis: Uses code context to reduce false positives and provides comments on relevant code lines (supported for Python, JavaScript, and Java).
    • Secrets Detection: Identifies exposed internal tokens or credentials.
    • Infrastructure as Code (IaC) Scans: Scans Terraform files for cloud and infrastructure misconfigurations.
  2. Get started with JFrog Frogbot

    main

    To begin using JFrog Frogbot, refer to the official documentation for setup and configuration instructions.

    Note on Versions:

    • V3 (main branch): The active development version.
    • V2 (v2_main branch): In sunset mode/maintenance only. It is not accepting new features or general contributions, only critical bug and security fixes.
    https://docs.jfrog.com/security/docs/frogbot-v3
  3. Run the Frogbot CLI

    main

    Frogbot is a command-line interface tool. It is initialized via the main function which sets up the default logger and executes the application logic. The CLI is built using the urfave/cli/v2 framework and exposes various commands through GetCommands(). To run the application, it expects standard command-line arguments provided via os.Args.

    # Example of running the compiled binary
    ./frogbot --help
  4. How the Frogbot command execution lifecycle works

    main

    The Exec function manages the execution of any FrogbotCommand. It performs the following steps automatically:

    1. Initialization: Logs the current Frogbot version and retrieves frogbotDetails (containing configuration, server details, and the VCS client) using utils.GetFrogbotDetails.
    2. Server Configuration: Builds a temporary JFrog server configuration file using utils.BuildServerConfigFile and manages the JFrogHomeDir environment variable.
    3. Releases Repository Setup: If a ReleasesRepo is configured, it sets the RELEASES_REMOTE_ENV environment variable to frogbot/<releases-repo>.
    4. Command Execution: Invokes the command's Run method, passing the repository configuration and the Git client.
    5. Error Reporting: If the command fails, it attempts to report the error to JFrog Xray using xsc.ReportError, providing context like Xray version, server details, and the JFrog project key.
    6. Cleanup: Restores the original JFrogHomeDir and removes temporary directories using defer blocks.
  5. How the Frogbot GitHub Action entrypoint works

    main

    The Frogbot GitHub Action entrypoint automatically determines the appropriate scan or fix action based on the GitHub event that triggered the workflow.

    When the action runs, it performs the following lifecycle steps:

    1. Retrieves the JFrog Platform URL.
    2. Sets up OIDC tokens if required.
    3. Configures the environment and updates the system PATH.
    4. Executes logic based on the eventName:
      • pull_request or pull_request_target: Runs a scan on the pull request (execScanPullRequest).
      • push, schedule, or workflow_dispatch: Attempts to create fix pull requests (execCreateFixPullRequests).
      • Other events: The action fails with an unsupported event error.

    If an unsupported event is received or an error occurs during execution, the action calls core.setFailed to mark the workflow step as failed.

  6. Run Frogbot via GitHub Action

    main

    Frogbot can be executed as a GitHub Action. When triggered, the action automatically determines the JFrog Platform URL, sets up OIDC tokens if required, and configures the environment. The action's behavior changes based on the GitHub event type:

    • pull_request or pull_request_target: Executes a scan on the pull request.
    • push, schedule, or workflow_dispatch: Executes the creation of fix pull requests.
    • Other events: The action will fail with an error indicating the event is not supported.

    This entrypoint is designed to be used within a GitHub Actions workflow file.

    # Example usage in a GitHub Actions workflow
    jobs:
      frogbot:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - name: Run Frogbot
            uses: jfrog/frogbot-action@v3 # Replace with actual action name/version
  7. Add the Frogbot badge to your README

    main

    You can display a badge in your repository's README to indicate that it is being scanned by Frogbot. Copy and paste the following Markdown snippet into your README.md file:

    [![Scanned by Frogbot](https://raw.github.com/jfrog/frogbot/main/images/frogbot-badge.svg)](https://jfrog.com/help/r/jfrog-security-user-guide/shift-left-on-security/frogbot)
  8. View the list of allowed licenses in Frogbot

    main

    Frogbot maintains a comprehensive list of allowed licenses. If you are configuring license policies or troubleshooting why a specific dependency is being flagged, you can refer to this list of supported license identifiers.

    0BSD
    AAL
    Abstyles
    AdaCore-doc
    Adobe-2006
    ...
    ZPL-2.1
  9. Implement the FrogbotCommand interface

    main

    To implement a new command within the Frogbot framework, you must satisfy the FrogbotCommand interface. This interface is used by the Exec function to orchestrate the command lifecycle, including configuration loading and environment setup.

    // The interface definition
    type FrogbotCommand interface {
    	// Run the command
    	Run(config utils.Repository, client vcsclient.VcsClient) error
    }

    When implementing Run, you receive:

    • config: A utils.Repository object containing repository and JFrog project details.
    • client: A vcsclient.VcsClient used to interact with the Version Control System (e.g., Git).
    type FrogbotCommand interface {
    	// Run the command
    	Run(config utils.Repository, client vcsclient.VcsClient) error
    }
  10. Available Frogbot CLI commands

    main

    Frogbot provides two primary commands for security scanning and remediation via the CLI:

    1. Scan Pull Request (scan-pull-request or spr): Scans a specific pull request with JFrog Xray to identify security vulnerabilities.
    2. Scan Repository (scan-repository, cfpr, or create-fix-pull-requests): Scans the current branch and automatically creates pull requests with suggested fixes if vulnerabilities are found.

    These commands are typically invoked through the Frogbot CLI entrypoint.