Help us shape the future of Go! Take the 2026 Go Developer Survey

contrast

package
v1.538.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusReported = "REPORTED"
	Critical       = "CRITICAL"
	High           = "HIGH"
	Medium         = "MEDIUM"
	AuditAll       = "Audit All"
	Optional       = "Optional"

	ContentType     = "Content-Type"
	JSONContentType = "application/json"
)

Variables

This section is empty.

Functions

func CreateAndPersistToolRecord

func CreateAndPersistToolRecord(utils piperutils.FileUtils, appInfo *ApplicationInfo, modulePath string, exercisedRoutePercentage *float64) (string, error)

func SaveReportFile added in v1.490.0

func SaveReportFile(utils piperutils.FileUtils, fileName, displayName string, data []byte) ([]piperutils.Path, error)

SaveReportFile saves report data to the contrast reports directory

Types

type ApplicationInfo

type ApplicationInfo struct {
	Url    string
	Id     string
	Name   string
	Server string
}

type ApplicationResponse

type ApplicationResponse struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
	Path        string `json:"path"`
	Language    string `json:"language"`
	Importance  string `json:"importance"`
}

type AsyncReportConfig added in v1.490.0

type AsyncReportConfig struct {
	ReportType         string // "SARIF" or "PDF"
	URLPattern         string // URL pattern for starting async generation
	Payload            map[string]any
	DownloadURLPattern string // Pattern for building download URL
}

AsyncReportConfig contains configuration for async report generation

type Client added in v1.490.0

type Client struct {
	ApiKey     string
	ServiceKey string
	Username   string
	OrgID      string
	BaseURL    string
	AppURL     string
	Auth       string
	HttpClient *http.Client
}

Client is the unified Contrast API client for both sync and async operations

func NewClient added in v1.490.0

func NewClient(apiKey, serviceKey, username, orgID, baseURL, appURL string) *Client

func (*Client) DownloadReport added in v1.490.0

func (c *Client) DownloadReport(downloadUrl, reportType string) ([]byte, error)

DownloadReport downloads a report from the given URL

func (*Client) GeneratePdfReport added in v1.490.0

func (c *Client) GeneratePdfReport(appUuid string) ([]byte, error)

GeneratePdfReport generates a PDF attestation report for the given application (start, poll, download)

func (*Client) GenerateSarifReport added in v1.490.0

func (c *Client) GenerateSarifReport(appUuid string) ([]byte, error)

GenerateSarifReport generates a SARIF report for the given application (start, poll, download)

func (*Client) GetAppInfo added in v1.490.0

func (c *Client) GetAppInfo(appUIUrl, server string) (*ApplicationInfo, error)

GetAppInfo gets application information (synchronous)

func (*Client) GetRouteCoverage added in v1.524.0

func (c *Client) GetRouteCoverage(appID string) (*RouteCoverageResponse, error)

GetRouteCoverage returns route coverage stats for the application. Endpoint: GET /ng/{orgUuid}/applications/{appId}/route

func (*Client) GetRouteCoverageBySession added in v1.534.0

func (c *Client) GetRouteCoverageBySession(appID, agentSessionID string) (*RouteCoverageResponse, error)

GetRouteCoverageBySession fetches route coverage scoped to a specific agent session. Uses POST /ng/{org}/applications/{appId}/route/filter with sessionID in the request body.

func (*Client) GetServers added in v1.524.0

func (c *Client) GetServers(appID string) ([]ServerResource, error)

GetServers returns all servers associated with the application. Endpoint: GET /ng/{orgUuid}/applications/{appId}/servers

func (*Client) GetVulnerabilities added in v1.490.0

func (c *Client) GetVulnerabilities() ([]ContrastFindings, error)

GetVulnerabilities gets vulnerabilities for the application (synchronous)

func (*Client) GetVulnerabilitiesBySession added in v1.534.0

func (c *Client) GetVulnerabilitiesBySession(appID, agentSessionID string) ([]ContrastFindings, error)

GetVulnerabilitiesBySession fetches vulnerabilities scoped to a specific agent session. Uses POST /ng/{org}/traces/{appId}/filter with agentSessionId in the request body. Paginates through all pages and aggregates into the same []ContrastFindings shape as GetVulnerabilities.

func (*Client) PollReportStatus added in v1.490.0

func (c *Client) PollReportStatus(reportUuid, reportType string) (*ReportStatusResponse, error)

PollReportStatus polls for report generation completion and returns the status response

func (*Client) StartAsyncPdfGeneration added in v1.490.0

func (c *Client) StartAsyncPdfGeneration(appUuid string) (string, error)

StartAsyncPdfGeneration initiates async PDF report generation (wrapper for testing compatibility)

func (*Client) StartAsyncSarifGeneration added in v1.490.0

func (c *Client) StartAsyncSarifGeneration(appUuid string) (string, error)

StartAsyncSarifGeneration initiates async SARIF report generation (wrapper for testing compatibility)

func (*Client) ValidateAndResolveSession added in v1.534.0

func (c *Client) ValidateAndResolveSession(appID, userVersion string) (string, error)

ValidateAndResolveSession validates that the user-supplied version exists as a session metadata value for the application, then resolves and returns the agentSessionId for that version.

type Contrast

type Contrast interface {
	GetVulnerabilities() error
	GetAppInfo(appUIUrl, server string)
}

type ContrastAudit

type ContrastAudit struct {
	ToolName             string             `json:"toolName"`
	ApplicationUrl       string             `json:"applicationUrl"`
	ScanResults          []ContrastFindings `json:"findings"`
	RouteDiscoveredCount *int               `json:"routeDiscoveredCount,omitempty"`
	RouteExercisedCount  *int               `json:"routeExercisedCount,omitempty"`
}

type ContrastFindings

type ContrastFindings struct {
	ClassificationName string `json:"classificationName"`
	Total              int    `json:"total"`
	Audited            int    `json:"audited"`
}

type ContrastHttpClient

type ContrastHttpClient interface {
	ExecuteRequest(url string, params map[string]string, dest any) error
}

type ContrastHttpClientInstance

type ContrastHttpClientInstance struct {
	// contains filtered or unexported fields
}

func NewContrastHttpClient

func NewContrastHttpClient(apiKey, auth string) *ContrastHttpClientInstance

func (*ContrastHttpClientInstance) ExecuteRequest

func (c *ContrastHttpClientInstance) ExecuteRequest(url string, params map[string]string, dest any) error

type ReportStatusResponse added in v1.490.0

type ReportStatusResponse struct {
	Messages    []string `json:"messages"`
	Success     bool     `json:"success"`
	Status      string   `json:"status"`
	DownloadUrl string   `json:"downloadUrl,omitempty"`
}

ReportStatusResponse represents the response from the report status endpoint

type RouteCoverageResponse added in v1.524.0

type RouteCoverageResponse struct {
	Success         bool `json:"success"`
	Count           int  `json:"count"`
	DiscoveredCount int  `json:"discovered_count"`
	ExercisedCount  int  `json:"exercised_count"`
}

RouteCoverageResponse is returned by GET /ng/{orgUuid}/applications/{appId}/route

type ServerResource added in v1.524.0

type ServerResource struct {
	ServerID     int64  `json:"server_id"`
	Name         string `json:"name"`
	Hostname     string `json:"hostname"`
	LastActivity int64  `json:"last_activity"`
	Status       string `json:"status"`
}

ServerResource contains per-server detail; LastActivity is a Unix millisecond timestamp

type ServersResponse added in v1.524.0

type ServersResponse struct {
	Count    int64            `json:"count"`
	Messages []string         `json:"messages"`
	Servers  []ServerResource `json:"servers"`
	Success  bool             `json:"success"`
}

ServersResponse is returned by GET /ng/{orgUuid}/applications/{appId}/servers

type TraceFilterResponse added in v1.534.0

type TraceFilterResponse struct {
	Success bool            `json:"success"`
	Count   int64           `json:"count"`
	Traces  []Vulnerability `json:"traces"`
}

type VulnerabilitiesResponse

type VulnerabilitiesResponse struct {
	Size            int             `json:"size"`
	TotalElements   int             `json:"totalElements"`
	TotalPages      int             `json:"totalPages"`
	Empty           bool            `json:"empty"`
	First           bool            `json:"first"`
	Last            bool            `json:"last"`
	Vulnerabilities []Vulnerability `json:"content"`
}

type Vulnerability

type Vulnerability struct {
	Severity string `json:"severity"`
	Status   string `json:"status"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL