Skip to content

Latest commit

 

History

History
 
 

docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Fortify API Documentation

The fortify-api module contains a class that wraps the Fortify RESTful calls in a response object. The class FortifyApi contains a set of prepared GET and POST calls.

Table of Contents

Constructor

Response Object

Methods

Constructor

The constructor requires only one value - the host address of the Fortify API. All others are optional.

Required parameters

host - The address of the Fortify API

Optional parameters

username - If the API is configured for basic auth, both username and password must be provided.
password - If the API is configured for basic auth, both username and password must be provided.
token - If an auth token is available (typically having previously called the get_token() method) the token can be used instead of username / password verify_ssl - Defaults to false. To enable verification of an HTTPS connection to the API, set to True.
user_agent - User agent for requests.
timeout - Time in seconds to wait for a response from the Fortify API.


Response object

All calls in this module return an object having the following properties and methods.

Properties

success - a boolean indicating if the call was successful or not. True indicates a successful call, while False indicates an unsuccessful call.
response_code - the actual HTTP response code from the call to the Fortify server.
message - if the call was successful, message is 'OK'. If the call was not successful, message is descriptive text of the failure. e.g. An SSL error occurred, etc.
data - the data (if any) returned from the Fortify API.

Methods

data_json() - Returns object data as JSON. An optional boolean parameter (pretty), if set to True, will return pretty-formatted JSON.

Below is an example of constructing a FortifyAPI class, calling a method, and exploring the response.

>>> from fortifyapi import fortify

>>> api = FortifyApi('https://fortify.example.com', verify_ssl=True, token=token)

>>> response = api.get_projects()

>>> response.success
True

>>> response.response_code
200

>>> response.message
'OK'

>>> print response.data_json(pretty=True)
[
TODO: PUT EXAMPLE HERE
    ...

Add Project Version Attribute:

Add the specified attribute to the specified project, using the specified value/values

Parameters

project_version_id
param attribute_definition_id
guid
value
values


Commit Project Version:

Convenience function to set the 'committed' project version attribute to True

Parameters

project_version_id:


Create Application Version:

Create a new application (formerly project) version under the specified project

Parameters

application_name
param application_template
param version_name
param application_id (optional)
param issue_template_id (optional)


Create New Project and Version:

Create a new project and new version under that project

Parameters

project_name
param project_template
param version_name


Download Artifact:

Download the specified artifact. The returned data is a binary blob of artifact content and file name of the artifact.

Parameters

artifact_id

Example

            api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
            response, file_name = api.download_artifact_scan("my-id")
            if response.success:
                file_content = response.data
                with open('/path/to/some/folder/' + file_name, 'wb') as f:
                    f.write(file_content)
            else:
                print response.message

Download Artifact Scan:

Download the specified scan. The returned data is a binary blob of scan content and file name of the scan.

Parameters

artifact_id

Example

            api = FortifyApi("https://my-fortify-server:my-port", token=get_token())
            response, file_name = api.download_artifact_scan("my-id")
            if response.success:
                file_content = response.data
                with open('/path/to/some/folder/' + file_name, 'wb') as f:
                    f.write(file_content)
            else:
                print response.message

Get Artifact Scans:

Download a list of scans for the specified artifact.

Parameters

parent_id


Get Attribute Definition:

Get attribute definitions matching the specified search

Parameters

search_expression A Fortify-formatted search expression, e.g. name:"Development Phase"


Get Attribute Definitions:

Get all attribute definitions.

Parameters

none


Get File Token:

Get a token for use in upload or download of a file. Typically for internal use only, but here if needed.

Parameters

purpose specify if the token is for file 'UPLOAD' or 'DOWNLOAD'


Get Issue Template:

Retrieve the specified project/issue template

Parameters

project_template_id The project/issue template to retrieve.


Get Project Version Artifacts

Get all artifacts for the specified project version.

Parameters

parent_id the id of the project version


Get Project Version Attributes

Get all attributes for the specified project version.

Parameters

project_version_id the id of the project version


Get Project Versions

Get all project versions

Parameters

none


Get Projects

Get all projects

Parameters

none


Get Token

Get auth token for use in subsequent API calls

Parameters

token_type(optional)
ttl


Post Attribute Definition

Post the provided attribute definition

Parameters

attribute_definition


Upload Artifact Scan

Upload the provided scan to the project version

Parameters

file_path Full path to the file to upload project_version_id Project version id for the project version to which the scan should be uploaded