Skip to content

Commit

Permalink
delete old clients
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkedar committed Jan 16, 2025
1 parent 27718d3 commit 76e3dd2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 217 deletions.
94 changes: 0 additions & 94 deletions internal/resolution/client/osv_client.go

This file was deleted.

107 changes: 0 additions & 107 deletions internal/resolution/client/osv_offline_client.go

This file was deleted.

41 changes: 25 additions & 16 deletions scripts/generate_mock_resolution_universe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"encoding/gob"
"errors"
"fmt"
"net/http"
"os"
"path/filepath"
"slices"
Expand All @@ -23,6 +24,7 @@ import (
"deps.dev/util/resolve"
"deps.dev/util/resolve/dep"
"github.com/google/osv-scanner/internal/clients/clientimpl/osvmatcher"
"github.com/google/osv-scanner/internal/clients/clientinterfaces"
"github.com/google/osv-scanner/internal/depsdev"
"github.com/google/osv-scanner/internal/osvdev"
"github.com/google/osv-scanner/internal/remediation"
Expand Down Expand Up @@ -51,13 +53,26 @@ var remediationOpts = remediation.Options{
UpgradeConfig: upgrade.NewConfig(),
}

const userAgent = "osv-scanner_generate_mock/" + version.OSVVersion

func vulnMatcher() clientinterfaces.VulnerabilityMatcher {
config := osvdev.DefaultConfig()
config.UserAgent = userAgent

return &osvmatcher.CachedOSVMatcher{
Client: osvdev.OSVClient{
HTTPClient: http.DefaultClient,
Config: config,
BaseHostURL: osvdev.DefaultBaseURL,
},
InitialQueryTimeout: 5 * time.Minute,
}
}

func doRelockRelax(ddCl *client.DepsDevClient, rw manifest.ReadWriter, filename string) error {
cl := client.ResolutionClient{
VulnerabilityMatcher: &osvmatcher.CachedOSVMatcher{
Client: *osvdev.DefaultClient(),
InitialQueryTimeout: 5 * time.Minute,
},
DependencyClient: ddCl,
VulnerabilityMatcher: vulnMatcher(),
DependencyClient: ddCl,
}

f, err := lf.OpenLocalDepFile(filename)
Expand All @@ -83,11 +98,8 @@ func doRelockRelax(ddCl *client.DepsDevClient, rw manifest.ReadWriter, filename

func doOverride(ddCl *client.DepsDevClient, rw manifest.ReadWriter, filename string) error {
cl := client.ResolutionClient{
VulnerabilityMatcher: &osvmatcher.CachedOSVMatcher{
Client: *osvdev.DefaultClient(),
InitialQueryTimeout: 5 * time.Minute,
},
DependencyClient: ddCl,
VulnerabilityMatcher: vulnMatcher(),
DependencyClient: ddCl,
}

f, err := lf.OpenLocalDepFile(filename)
Expand All @@ -113,11 +125,8 @@ func doOverride(ddCl *client.DepsDevClient, rw manifest.ReadWriter, filename str

func doInPlace(ddCl *client.DepsDevClient, rw lockfile.ReadWriter, filename string) error {
cl := client.ResolutionClient{
VulnerabilityMatcher: &osvmatcher.CachedOSVMatcher{
Client: *osvdev.DefaultClient(),
InitialQueryTimeout: 5 * time.Minute,
},
DependencyClient: ddCl,
VulnerabilityMatcher: vulnMatcher(),
DependencyClient: ddCl,
}

f, err := lf.OpenLocalDepFile(filename)
Expand Down Expand Up @@ -294,7 +303,7 @@ func typeString(t dep.Type) string {
}

func main() {
cl, err := client.NewDepsDevClient(depsdev.DepsdevAPI, "osv-scanner_generate_mock/"+version.OSVVersion)
cl, err := client.NewDepsDevClient(depsdev.DepsdevAPI, userAgent)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
Expand Down

0 comments on commit 76e3dd2

Please sign in to comment.