Documentation
¶
Index ¶
- Constants
- func DetectFormat(filePath string, data []byte) string
- type ChunkResponse
- type Client
- func (c *Client) ChunkedUpload(fileName string, data []byte, contentType, format string) (*FinalizeResponse, error)
- func (c *Client) FinalizeUpload(sessionID string) (*FinalizeResponse, error)
- func (c *Client) InitiateSession(fileName string, fileSize int, contentType string, totalChunks, chunkSize int) (*InitiateResponse, error)
- func (c *Client) SimpleUpload(fileName string, data []byte, contentType, format string) (*FinalizeResponse, error)
- func (c *Client) UploadChunk(sessionID string, chunkNumber int, data []byte) (*ChunkResponse, error)
- func (c *Client) UploadFile(filePath string, formatOverride string) (*FinalizeResponse, error)
- func (c *Client) VerifyAuth() (*VerifyResponse, error)
- type FinalizeResponse
- type GitHubActionsContext
- type InitiateResponse
- type PipelineRecord
- type VerifyResponse
Constants ¶
const ( DefaultBaseURL = "https://app.vulnetix.com/api" // ChunkThreshold is the file size above which chunked upload is used ChunkThreshold = 10 * 1024 * 1024 // 10 MB // DefaultChunkSize is the size of each chunk for large files DefaultChunkSize = 5 * 1024 * 1024 // 5 MB )
Variables ¶
This section is empty.
Functions ¶
func DetectFormat ¶
DetectFormat inspects file extension and content to determine the artifact format
Types ¶
type ChunkResponse ¶
type ChunkResponse struct {
OK bool `json:"ok"`
ChunkNumber int `json:"chunkNumber"`
Received int `json:"received"`
TotalChunks int `json:"totalChunks"`
Error string `json:"error,omitempty"`
}
ChunkResponse is returned after uploading a chunk
type Client ¶
type Client struct {
BaseURL string
Creds *auth.Credentials
HTTPClient *http.Client
GitHubContext *GitHubActionsContext
}
Client handles file uploads to the Vulnetix API
func NewClient ¶
func NewClient(baseURL string, creds *auth.Credentials) *Client
NewClient creates a new upload client
func (*Client) ChunkedUpload ¶
func (c *Client) ChunkedUpload(fileName string, data []byte, contentType, format string) (*FinalizeResponse, error)
ChunkedUpload handles large file uploads by splitting into chunks
func (*Client) FinalizeUpload ¶
func (c *Client) FinalizeUpload(sessionID string) (*FinalizeResponse, error)
FinalizeUpload completes the upload session
func (*Client) InitiateSession ¶
func (c *Client) InitiateSession(fileName string, fileSize int, contentType string, totalChunks, chunkSize int) (*InitiateResponse, error)
InitiateSession starts a new upload session
func (*Client) SimpleUpload ¶
func (c *Client) SimpleUpload(fileName string, data []byte, contentType, format string) (*FinalizeResponse, error)
SimpleUpload performs a single-request upload for small files
func (*Client) UploadChunk ¶
func (c *Client) UploadChunk(sessionID string, chunkNumber int, data []byte) (*ChunkResponse, error)
UploadChunk uploads a single chunk of data
func (*Client) UploadFile ¶
func (c *Client) UploadFile(filePath string, formatOverride string) (*FinalizeResponse, error)
UploadFile uploads a file to Vulnetix, choosing simple or chunked based on size
func (*Client) VerifyAuth ¶
func (c *Client) VerifyAuth() (*VerifyResponse, error)
VerifyAuth checks that the provided credentials are valid
type FinalizeResponse ¶
type FinalizeResponse struct {
OK bool `json:"ok"`
PipelineRecord *PipelineRecord `json:"pipelineRecord,omitempty"`
IsDuplicate bool `json:"isDuplicate,omitempty"`
Error string `json:"error,omitempty"`
}
FinalizeResponse is returned after finalizing an upload
type GitHubActionsContext ¶
type GitHubActionsContext struct {
Repository string `json:"repository"`
RepositoryOwner string `json:"repositoryOwner"`
RunID string `json:"runId"`
RunNumber string `json:"runNumber"`
WorkflowName string `json:"workflowName"`
JobName string `json:"jobName"`
SHA string `json:"sha"`
RefName string `json:"refName"`
RefType string `json:"refType"`
EventName string `json:"eventName"`
Actor string `json:"actor"`
ServerURL string `json:"serverUrl"`
APIURL string `json:"apiUrl"`
ExtraEnvVars map[string]string `json:"extraEnvVars,omitempty"`
}
GitHubActionsContext contains GitHub Actions environment metadata sent with uploads
type InitiateResponse ¶
type InitiateResponse struct {
OK bool `json:"ok"`
UploadSessionID string `json:"uploadSessionId"`
ExpiresAt int64 `json:"expiresAt,omitempty"`
Error string `json:"error,omitempty"`
}
InitiateResponse is returned when starting an upload session
type PipelineRecord ¶
type PipelineRecord struct {
UUID string `json:"uuid"`
DetectedType string `json:"detectedType"`
ProcessingState string `json:"processingState"`
OriginalFileName string `json:"originalFileName"`
SHA256 string `json:"sha256,omitempty"`
}
PipelineRecord represents the artifact pipeline record from the SaaS
type VerifyResponse ¶
type VerifyResponse struct {
OK bool `json:"ok"`
OrgID string `json:"orgId,omitempty"`
Error string `json:"error,omitempty"`
}
VerifyResponse is returned by the /api/cli/verify endpoint