Documentation
¶
Index ¶
- func HasResults(data []byte) (bool, string, int)
- type BatchStatus
- type BatchStrategy
- type Client
- func (c *Client) GetBatchResults(sessionID string) (string, string, int, error)
- func (c *Client) GetBatchStatus(sessionID string) (*BatchStatus, error)
- func (c *Client) SendBatch(wfpContent string) (string, error)
- func (c *Client) SendBatchWithContext(wfpContent string, sessionID string, isFinalChunk bool, sbomContext string) (string, error)
- func (c *Client) SendBatchWithSBOM(wfpContent string, sessionID string, isFinalChunk bool, sbom *SBOMContext) (string, error)
- func (c *Client) SendBatchWithSession(wfpContent string, sessionID string, isFinalChunk bool) (string, error)
- func (c *Client) SendFingerprint(fp *fingerprint.FileFingerprint) (string, error)
- func (c *Client) SendFingerprints(wfp string, opts SendOptions) (*SendResponse, error)
- func (c *Client) SetHTTPClient(client *http.Client)
- func (c *Client) SetInsecureTLS(insecure bool)
- type DirectStrategy
- type SBOMContext
- type ScanClient
- type ScanStatus
- type SendOptions
- type SendResponse
- type SendStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 NewClientWithMode ¶
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 ¶
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) 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 *fingerprint.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) SetHTTPClient ¶ added in v0.4.0
SetHTTPClient replaces the HTTP client used for API calls, so a caller can supply one configured for a proxy or an internal CA. A nil client is ignored.
This is the injection point for the C/Python/Node bindings, which reach the API through this package rather than through pkg/scanoss.
func (*Client) SetInsecureTLS ¶
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 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