diff --git a/internal/output/table.go b/internal/output/table.go index b5ac7d5a00a..da0cf6e760f 100644 --- a/internal/output/table.go +++ b/internal/output/table.go @@ -6,8 +6,8 @@ import ( "path/filepath" "strings" - "github.com/google/osv-scanner/internal/osv" "github.com/google/osv-scanner/pkg/models" + "github.com/google/osv-scanner/pkg/osv" "github.com/jedib0t/go-pretty/v6/table" "github.com/jedib0t/go-pretty/v6/text" diff --git a/internal/osv/osv.go b/pkg/osv/osv.go similarity index 96% rename from internal/osv/osv.go rename to pkg/osv/osv.go index a29cc836214..0e4d85ddb0b 100644 --- a/internal/osv/osv.go +++ b/pkg/osv/osv.go @@ -19,9 +19,9 @@ const ( GetEndpoint = "https://api.osv.dev/v1/vulns" // BaseVulnerabilityURL is the base URL for detailed vulnerability views. BaseVulnerabilityURL = "https://osv.dev/" - // MaxQueriesPerRequest splits up querybatch into multiple requests if + // maxQueriesPerRequest splits up querybatch into multiple requests if // number of queries exceed this number - MaxQueriesPerRequest = 1000 + maxQueriesPerRequest = 1000 ) // Package represents a package identifier for OSV. @@ -121,9 +121,10 @@ func checkResponseError(resp *http.Response) error { return fmt.Errorf("server response error: %s", string(respBuf)) } +// MakeRequest sends a batched query to osv.dev func MakeRequest(request BatchedQuery) (*BatchedResponse, error) { // API has a limit of 1000 bulk query per request - queryChunks := chunkBy(request.Queries, MaxQueriesPerRequest) + queryChunks := chunkBy(request.Queries, maxQueriesPerRequest) var totalOsvResp BatchedResponse for _, queries := range queryChunks { requestBytes, err := json.Marshal(BatchedQuery{Queries: queries}) diff --git a/pkg/osvscanner/osvscanner.go b/pkg/osvscanner/osvscanner.go index aeceefe3e45..4afbb33c94f 100644 --- a/pkg/osvscanner/osvscanner.go +++ b/pkg/osvscanner/osvscanner.go @@ -10,12 +10,12 @@ import ( "path/filepath" "strings" - "github.com/google/osv-scanner/internal/osv" "github.com/google/osv-scanner/internal/output" "github.com/google/osv-scanner/internal/sbom" "github.com/google/osv-scanner/pkg/config" "github.com/google/osv-scanner/pkg/lockfile" "github.com/google/osv-scanner/pkg/models" + "github.com/google/osv-scanner/pkg/osv" ) type ScannerActions struct { diff --git a/pkg/osvscanner/vulnerability_result.go b/pkg/osvscanner/vulnerability_result.go index 1c275730161..7e5a198d658 100644 --- a/pkg/osvscanner/vulnerability_result.go +++ b/pkg/osvscanner/vulnerability_result.go @@ -3,10 +3,10 @@ package osvscanner import ( "fmt" - "github.com/google/osv-scanner/internal/osv" "github.com/google/osv-scanner/internal/output" "github.com/google/osv-scanner/pkg/grouper" "github.com/google/osv-scanner/pkg/models" + "github.com/google/osv-scanner/pkg/osv" ) // groupResponseBySource converts raw OSV API response into structured vulnerability information diff --git a/pkg/osvscanner/vulnerability_result_internal_test.go b/pkg/osvscanner/vulnerability_result_internal_test.go index 81f96af11db..97f5621d007 100644 --- a/pkg/osvscanner/vulnerability_result_internal_test.go +++ b/pkg/osvscanner/vulnerability_result_internal_test.go @@ -4,9 +4,9 @@ import ( "reflect" "testing" - "github.com/google/osv-scanner/internal/osv" "github.com/google/osv-scanner/internal/output" "github.com/google/osv-scanner/pkg/models" + "github.com/google/osv-scanner/pkg/osv" ) func Test_groupResponseBySource(t *testing.T) {