Fortify Software Security Center (SSC) RESTFul API Python Client

3.1.25 · active · verified Thu Apr 16

fortifyapi is a Python library designed to interact with the Fortify Software Security Center (SSC) RESTful API. It provides a programmatic interface to manage applications, versions, issues, and other SSC entities. The library is currently in Beta status (Development Status :: 4 - Beta) and is actively maintained, with the latest release being 3.1.25. While primarily a wrapper for the SSC API, users should be aware of underlying SSC API changes and deprecations that can affect its usage.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate with Fortify SSC using username/password to obtain an API token, then use that token to list all available project versions. Remember to configure your Fortify SSC host, username, and password, preferably via environment variables, and handle SSL verification appropriately for your environment.

import os
from fortifyapi.fortify import FortifyApi

# Set environment variables for connection
FORTIFY_SSC_HOST = os.environ.get('FORTIFY_SSC_HOST', 'https://localhost:8443/ssc')
FORTIFY_SSC_USER = os.environ.get('FORTIFY_SSC_USER', 'your_ssc_username')
FORTIFY_SSC_PASSWORD = os.environ.get('FORTIFY_SSC_PASSWORD', 'your_ssc_password')

def get_ssc_token():
    """Authenticates with SSC and retrieves an API token."""
    # Bypass SSL verification if you have issues with self-signed certs (NOT recommended for production)
    ssc_client = FortifyApi(host=FORTIFY_SSC_HOST, username=FORTIFY_SSC_USER, 
                            password=FORTIFY_SSC_PASSWORD, verify_ssl=False)
    response = ssc_client.get_token(description='fortifyapi_client_token')
    if response.data and 'data' in response.data and 'token' in response.data['data']:
        return response.data['data']['token']
    raise Exception("Failed to retrieve Fortify SSC API token.")

def list_project_versions():
    """Lists all project versions in Fortify SSC."""
    try:
        token = get_ssc_token()
        ssc_client = FortifyApi(host=FORTIFY_SSC_HOST, token=token, verify_ssl=False)
        response = ssc_client.get_all_project_versions()
        if response.data and 'data' in response.data:
            print("Fortify SSC Project Versions:")
            for version in response.data['data']:
                print(f"  ID: {version['id']}, Project: {version['project']['name']}, Version: {version['name']}")
        else:
            print("No project versions found or API response was empty.")
    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == '__main__':
    # Make sure to set FORTIFY_SSC_HOST, FORTIFY_SSC_USER, FORTIFY_SSC_PASSWORD
    # environment variables or replace placeholders for actual usage.
    list_project_versions()

view raw JSON →