api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasResults

func HasResults(data []byte) (bool, string, int)

Types

type BatchStatus

type BatchStatus struct {
	Status   string // "scanning", "completed", "failed"
	Progress int    // 0-100
	Results  string // Only available if Status == "completed"
}

BatchStatus represents the status of a batch scan

type BatchStrategy

type BatchStrategy struct{}

BatchStrategy implements the strategy for batch mode (asynchronous) In this mode, multiple chunks are sent with the same Session-Id and results are retrieved later via polling

func (*BatchStrategy) GetEndpoint

func (s *BatchStrategy) GetEndpoint(baseURL string) string

GetEndpoint returns the endpoint for batch mode

func (*BatchStrategy) NeedsSessionID

func (s *BatchStrategy) NeedsSessionID() bool

NeedsSessionID indicates that batch mode requires session tracking

func (*BatchStrategy) PrepareHeaders

func (s *BatchStrategy) PrepareHeaders(opts SendOptions) map[string]string

PrepareHeaders prepares batch protocol-specific headers

type Client

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

Client handles communications with the SCANOSS API

func NewClient

func NewClient(apiURL, apiKey string) *Client

NewClient creates a new API client with DirectStrategy by default

func NewClientWithMode

func NewClientWithMode(apiURL, apiKey string, batchMode bool) *Client

NewClientWithMode creates a new API client with specific mode (legacy) Deprecated: Use NewClientWithStrategy instead

func NewClientWithStrategy

func NewClientWithStrategy(apiURL, apiKey string, strategy SendStrategy) *Client

NewClientWithStrategy creates a new API client with custom strategy

func (*Client) GetBatchResults

func (c *Client) GetBatchResults(sessionID string) (string, string, int, error)

GetBatchResults retrieves results from a batch scan using session ID

func (*Client) GetBatchStatus

func (c *Client) GetBatchStatus(sessionID string) (*BatchStatus, error)

GetBatchStatus implements ScanClient.GetBatchStatus

func (*Client) SendBatch

func (c *Client) SendBatch(wfpContent string) (string, error)

SendBatch sends a batch of combined fingerprints to the API (legacy)

func (*Client) SendBatchWithContext

func (c *Client) SendBatchWithContext(wfpContent string, sessionID string, isFinalChunk bool, sbomContext string) (string, error)

SendBatchWithContext sends a batch with session tracking and BOM context

func (*Client) SendBatchWithSBOM

func (c *Client) SendBatchWithSBOM(wfpContent string, sessionID string, isFinalChunk bool, sbom *SBOMContext) (string, error)

SendBatchWithSBOM sends a batch with session tracking and SBOM context (new format)

func (*Client) SendBatchWithSession

func (c *Client) SendBatchWithSession(wfpContent string, sessionID string, isFinalChunk bool) (string, error)

SendBatchWithSession sends a batch with session tracking (legacy)

func (*Client) SendFingerprint

func (c *Client) SendFingerprint(fp *models.FileFingerprint) (string, error)

SendFingerprint sends a single fingerprint to the API (legacy)

func (*Client) SendFingerprints

func (c *Client) SendFingerprints(wfp string, opts SendOptions) (*SendResponse, error)

SendFingerprints implements ScanClient.SendFingerprints

func (*Client) SetInsecureTLS

func (c *Client) SetInsecureTLS(insecure bool)

SetInsecureTLS disables TLS certificate verification when insecure is true. For self-signed or internal endpoints only — insecure, avoid in production.

type DirectStrategy

type DirectStrategy struct{}

DirectStrategy implements the strategy for direct mode (synchronous) In this mode, each request gets an immediate response

func (*DirectStrategy) GetEndpoint

func (s *DirectStrategy) GetEndpoint(baseURL string) string

GetEndpoint returns the endpoint for direct mode

func (*DirectStrategy) NeedsSessionID

func (s *DirectStrategy) NeedsSessionID() bool

NeedsSessionID indicates that direct mode does not need session tracking

func (*DirectStrategy) PrepareHeaders

func (s *DirectStrategy) PrepareHeaders(opts SendOptions) map[string]string

PrepareHeaders does not add special headers in direct mode

type SBOMContext

type SBOMContext struct {
	Assets string // JSON-serialized SBOM: {"components": [{"purl": "pkg:..."}, ...]}
	Type   string // "identify" or "blacklist"
}

SBOMContext represents SBOM data to be sent with the scan request

type ScanClient

type ScanClient interface {
	// SendFingerprints sends fingerprints to the server
	SendFingerprints(wfp string, opts SendOptions) (*SendResponse, error)

	// GetBatchStatus retrieves the status of a batch scan
	GetBatchStatus(sessionID string) (*BatchStatus, error)
}

ScanClient abstracts SCANOSS API operations

type ScanStatus

type ScanStatus struct {
	Started  int64  `json:"started"`
	Status   string `json:"status"`
	Progress int    `json:"progress"`
}

type SendOptions

type SendOptions struct {
	SessionID    string
	IsFinalChunk bool
	Metadata     map[string]string // Extensible for future custom headers
	SBOMContext  string            // BOM context (SBOM entries) to include in the request
}

SendOptions encapsulates sending options

type SendResponse

type SendResponse struct {
	Data       string
	StatusCode int
	Immediate  bool // true if immediate response, false if async (batch)
}

SendResponse represents the response from sending fingerprints

type SendStrategy

type SendStrategy interface {
	// GetEndpoint returns the specific endpoint for this mode
	GetEndpoint(baseURL string) string

	// PrepareHeaders prepares mode-specific headers
	PrepareHeaders(opts SendOptions) map[string]string

	// NeedsSessionID indicates if this strategy requires a Session ID
	NeedsSessionID() bool
}

SendStrategy defines how to send fingerprints based on operation mode

Jump to

Keyboard shortcuts

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