upload

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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

func DetectFormat(filePath string, data []byte) string

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

Jump to

Keyboard shortcuts

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