diff --git a/third_party/binary/BUILD b/third_party/binary/BUILD index 1faf791..78f66e9 100644 --- a/third_party/binary/BUILD +++ b/third_party/binary/BUILD @@ -1,8 +1,8 @@ remote_file( name = "gosec_download", - hashes = ["226bd8825b7aed3d454446d1ec094f817f37859dded4211a5b707d0f36c5fdb7"], + hashes = ["38e596e1ad580666e5efaa159fbaf63bd5873ea1e74beacbdf785b025b52e1db"], test_only = True, - url = ["https://github.com/securego/gosec/releases/download/v2.14.0/gosec_2.14.0_linux_amd64.tar.gz"], + url = ["https://github.com/securego/gosec/releases/download/v2.22.0/gosec_2.22.0_linux_amd64.tar.gz"], ) genrule( @@ -10,7 +10,7 @@ genrule( srcs = [":gosec_download"], outs = ["gosec"], binary = True, - cmd = "$TOOLS x $SRCS -s v2.14.0", + cmd = "$TOOLS x $SRCS -s v2.22.0", test_only = True, tools = [CONFIG.ARCAT_TOOL], visibility = ["//tools/driver/..."], diff --git a/tools/driver/ChangeLog b/tools/driver/ChangeLog index f0c66dc..1bf5e32 100644 --- a/tools/driver/ChangeLog +++ b/tools/driver/ChangeLog @@ -1,3 +1,7 @@ +Version 0.7.0 +------------- + * Use the now-exported types for the request/response (#317) + Version 0.6.0 ------------- * Migrate to `go_repo` and upgrade golang.org/x packages (#316) diff --git a/tools/driver/VERSION b/tools/driver/VERSION index a918a2a..faef31a 100644 --- a/tools/driver/VERSION +++ b/tools/driver/VERSION @@ -1 +1 @@ -0.6.0 +0.7.0 diff --git a/tools/driver/main.go b/tools/driver/main.go index 051d800..86b4e85 100644 --- a/tools/driver/main.go +++ b/tools/driver/main.go @@ -16,7 +16,7 @@ var log = logging.MustGetLogger() var opts = struct { Usage string Verbosity logging.Verbosity `short:"v" long:"verbosity" env:"PLZ_GOPACKAGESDRIVER_VERBOSITY" default:"warning" description:"Verbosity of output (higher number = more output)"` - LogFile string `long:"log_file" env:"PLZ_GOPACKAGESDRIVER_LOG_FILE" description:"Log additionally to this file"` + LogFile string `long:"log_file" env:"PLZ_GOPACKAGESDRIVER_LOG_FILE" description:"Log additionally to this file"` NoInput bool `short:"n" long:"no_input" description:"Assume a default config and don't try to read from stdin"` WorkingDir string `short:"w" long:"working_dir" description:"Change to this working directory before running"` OutputFile string `short:"o" long:"output_file" env:"PLZ_GOPACKAGESDRIVER_OUTPUT_FILE" description:"File to write output to (in addition to stdout)"` @@ -48,7 +48,7 @@ func main() { } } - req := &packages.DriverRequest{} + req := &xpackages.DriverRequest{} if opts.NoInput { req.Mode = xpackages.NeedExportFile } else { @@ -77,7 +77,7 @@ func main() { } } -func load(req *packages.DriverRequest) (*packages.DriverResponse, error) { +func load(req *xpackages.DriverRequest) (*xpackages.DriverResponse, error) { if opts.SearchDir == "" { return packages.Load(req, opts.Args.Files) } diff --git a/tools/driver/packages/packages.go b/tools/driver/packages/packages.go index a861aae..06b1932 100644 --- a/tools/driver/packages/packages.go +++ b/tools/driver/packages/packages.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "go/build" - "go/types" "io" "io/fs" "os" @@ -24,29 +23,12 @@ import ( var log = logging.MustGetLogger() -// DriverRequest is copied from go/packages; it's the format of config that we get on stdin. -type DriverRequest struct { - Mode packages.LoadMode `json:"mode"` - Env []string `json:"env"` - BuildFlags []string `json:"build_flags"` - Tests bool `json:"tests"` - Overlay map[string][]byte `json:"overlay"` -} - -// DriverResponse is copied from go/packages; it's our response about packages we've loaded. -type DriverResponse struct { - NotHandled bool - Sizes *types.StdSizes - Roots []string `json:",omitempty"` - Packages []*packages.Package -} - // Load reads a set of packages and returns information about them. // Most of the request structure isn't honoured at the moment. -func Load(req *DriverRequest, files []string) (*DriverResponse, error) { +func Load(req *packages.DriverRequest, files []string) (*packages.DriverResponse, error) { // If there are no files provided, do nothing. if len(files) == 0 { - return &DriverResponse{NotHandled: true}, nil + return &packages.DriverResponse{NotHandled: true}, nil } // We need to find the plz repo that we need to be in (we might be invoked from outside it) // For now we're assuming they're all in the same repo (which is probably reasonable) and just @@ -65,7 +47,7 @@ func Load(req *DriverRequest, files []string) (*DriverResponse, error) { } else if len(files) == 0 { // Not obvious that this really is an error case. log.Warning("No Go files found in initial query") - return &DriverResponse{NotHandled: true}, nil + return &packages.DriverResponse{NotHandled: true}, nil } else if err := os.Chdir(filepath.Dir(files[0])); err != nil { return nil, err } @@ -93,7 +75,7 @@ func Load(req *DriverRequest, files []string) (*DriverResponse, error) { // LoadOffline is like Load but rather than querying plz to find the file to load, it just // walks a file tree looking for pkg_info.json files. -func LoadOffline(req *DriverRequest, searchDir string, files []string) (*DriverResponse, error) { +func LoadOffline(req *packages.DriverRequest, searchDir string, files []string) (*packages.DriverResponse, error) { pkgs := []*packages.Package{} if err := filepath.WalkDir(searchDir, func(path string, d fs.DirEntry, err error) error { lpkgs := []*packages.Package{} @@ -127,7 +109,7 @@ func LoadOffline(req *DriverRequest, searchDir string, files []string) (*DriverR return packagesToResponse(searchDir, pkgs, dirs) } -func packagesToResponse(rootpath string, pkgs []*packages.Package, dirs map[string]struct{}) (*DriverResponse, error) { +func packagesToResponse(rootpath string, pkgs []*packages.Package, dirs map[string]struct{}) (*packages.DriverResponse, error) { // Build the set of root packages seenRoots := map[string]struct{}{} roots := []string{} @@ -178,13 +160,8 @@ func packagesToResponse(rootpath string, pkgs []*packages.Package, dirs map[stri } pkgs = append(pkgs, stdlib...) } - log.Debug("Built package set") - return &DriverResponse{ - Sizes: &types.StdSizes{ - // These are obviously hardcoded. To worry about later. - WordSize: 8, - MaxAlign: 8, - }, + log.Debugf("Built package set") + return &packages.DriverResponse{ Packages: pkgs, Roots: roots, }, nil diff --git a/tools/driver/test/BUILD b/tools/driver/test/BUILD index f3bd219..0bd8a88 100644 --- a/tools/driver/test/BUILD +++ b/tools/driver/test/BUILD @@ -7,15 +7,16 @@ gentest( cmd = [ 'export PLZ_GOPACKAGESDRIVER_SEARCHDIR="$TMP_DIR"', 'export GOPACKAGESDRIVER="$TOOLS_DRIVER"', - '"$TOOLS_GOSEC" --exclude G104,G304,G307 tools/driver/packages', + '"$TOOLS_GOSEC" --exclude G104,G304,G307 tools/driver/packages/... | tee $OUT', ], + outs = ["gosec_test.txt"], needs_transitive_deps = True, no_test_output = True, requires = [ "go", "go_src", ], - test_cmd = "true", + test_cmd = "cat $TEST", tools = { "driver": ["//tools/driver:plz-gopackagesdriver"], "gosec": ["//third_party/binary:gosec"],