Skip to content

Commit 7cbd7dc

Browse files
authored
Upgrade Go version from 1.17 to 1.19 (#697)
* Upgrade Go version from 1.17 to 1.19 * Revert tamago-go version to 1.17.8 * Revert some version changes in go.mod * go fmt ./... with Go version 1.19 * Explicitly set GOROOT before golangci-lint/issues/3107 is fixed * Fix the golangci-lint pre-compiled binary incompatibility issue * Revert gvisor.dev/gvisor version to v0.0.0-20220920171436-4e7fd140e8d0 * Replace deprecated "io/ioutil" functions with "os" * Replace deprecated "io/ioutil" functions with "os" * Replace deprecated "io/ioutil" functions with "os" * Replace deprecated "io/ioutil" functions with "os" * Replace deprecated "io/ioutil" functions with "os"
1 parent f93e854 commit 7cbd7dc

File tree

74 files changed

+256
-1315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+256
-1315
lines changed

binary_transparency/firmware/cmd/emulator/dummy/dummy_emu.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
// successful validation has taken place.
2424
//
2525
// Usage:
26-
// go run ./cmd/emulator/dummy --logtostderr --dummy_storage_dir=/tmp/dummy_device
26+
//
27+
// go run ./cmd/emulator/dummy --logtostderr --dummy_storage_dir=/tmp/dummy_device
2728
package main
2829

2930
import (

binary_transparency/firmware/cmd/flash_tool/flash_tool.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
// Currently, the only device is a dummy device, which simply sorts the firmware+metadata on local disk.
1818
//
1919
// Usage:
20-
// go run ./cmd/flash_tool/ --logtostderr --dummy_storage_dir=/path/to/dir --update_file=/path/to/update.json
20+
//
21+
// go run ./cmd/flash_tool/ --logtostderr --dummy_storage_dir=/path/to/dir --update_file=/path/to/update.json
2122
//
2223
// The first time you use this tool there will be no prior firmware metadata
2324
// stored on the device and the tool will fail. In this case, use the --force

binary_transparency/firmware/cmd/ft_monitor/impl/ft_monitor.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"encoding/json"
2828
"errors"
2929
"fmt"
30-
"io/ioutil"
3130
"net/url"
3231
"os"
3332
"regexp"
@@ -79,7 +78,7 @@ func Main(ctx context.Context, opts MonitorOpts) error {
7978

8079
// Initialize the checkpoint from persisted state.
8180
var latestCP api.LogCheckpoint
82-
if state, err := ioutil.ReadFile(opts.StateFile); err != nil {
81+
if state, err := os.ReadFile(opts.StateFile); err != nil {
8382
if !errors.Is(err, os.ErrNotExist) {
8483
return fmt.Errorf("failed to read state: %w", err)
8584
}
@@ -119,7 +118,7 @@ func Main(ctx context.Context, opts MonitorOpts) error {
119118
if entry.Index == entry.Root.Size-1 {
120119
// If we have processed all leaves in the current checkpoint, then persist this checkpoint
121120
// so that we don't repeat work on startup.
122-
ioutil.WriteFile(opts.StateFile, entry.Root.Envelope, 0o755)
121+
os.WriteFile(opts.StateFile, entry.Root.Envelope, 0o755)
123122
}
124123
}
125124
}

binary_transparency/firmware/cmd/ft_personality/internal/http/server.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"encoding/base64"
2323
"encoding/json"
2424
"fmt"
25-
"io/ioutil"
25+
"io"
2626
"mime"
2727
"mime/multipart"
2828
"net/http"
@@ -161,7 +161,7 @@ func parseAddFirmwareRequest(r *http.Request) ([]byte, []byte, error) {
161161
if err != nil {
162162
return nil, nil, fmt.Errorf("failed to find firmware statement in request body: %v", err)
163163
}
164-
rawJSON, err := ioutil.ReadAll(p)
164+
rawJSON, err := io.ReadAll(p)
165165
if err != nil {
166166
return nil, nil, fmt.Errorf("failed to read body of firmware statement: %v", err)
167167
}
@@ -171,7 +171,7 @@ func parseAddFirmwareRequest(r *http.Request) ([]byte, []byte, error) {
171171
if err != nil {
172172
return nil, nil, fmt.Errorf("failed to find firmware image in request body: %v", err)
173173
}
174-
image, err := ioutil.ReadAll(p)
174+
image, err := io.ReadAll(p)
175175
if err != nil {
176176
return nil, nil, fmt.Errorf("failed to read body of firmware image: %v", err)
177177
}
@@ -358,7 +358,7 @@ func (s *Server) addAnnotationMalware(w http.ResponseWriter, r *http.Request) {
358358
ss := api.SignedStatement{}
359359

360360
// Store the original bytes as statement to avoid a round-trip (de)serialization.
361-
rawStmt, err := ioutil.ReadAll(r.Body)
361+
rawStmt, err := io.ReadAll(r.Body)
362362
if err != nil {
363363
http.Error(w, err.Error(), http.StatusBadRequest)
364364
return

binary_transparency/firmware/cmd/ft_personality/internal/http/server_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"encoding/json"
2020
"errors"
2121
"fmt"
22-
"io/ioutil"
22+
"io"
2323
"net/http"
2424
"net/http/httptest"
2525
"strings"
@@ -73,7 +73,7 @@ func TestRoot(t *testing.T) {
7373
if resp.StatusCode != http.StatusOK {
7474
t.Errorf("status code not OK: %v", resp.StatusCode)
7575
}
76-
body, err := ioutil.ReadAll(resp.Body)
76+
body, err := io.ReadAll(resp.Body)
7777
if err != nil {
7878
t.Errorf("failed to read body: %v", err)
7979
}
@@ -197,7 +197,7 @@ func TestAddFirmware(t *testing.T) {
197197
t.Errorf("error response: %v", err)
198198
}
199199
if got, want := resp.StatusCode, test.wantStatus; got != want {
200-
body, _ := ioutil.ReadAll(resp.Body)
200+
body, _ := io.ReadAll(resp.Body)
201201
t.Errorf("status code got != want (%d, %d): %q", got, want, body)
202202
}
203203
})
@@ -272,7 +272,7 @@ func TestGetConsistency(t *testing.T) {
272272
t.Errorf("status code got != want (%d, %d)", got, want)
273273
}
274274
if len(test.wantBody) > 0 {
275-
body, err := ioutil.ReadAll(resp.Body)
275+
body, err := io.ReadAll(resp.Body)
276276
if err != nil {
277277
t.Errorf("failed to read body: %v", err)
278278
}
@@ -361,7 +361,7 @@ func TestGetManifestEntries(t *testing.T) {
361361
t.Errorf("status code got != want (%d, %d)", got, want)
362362
}
363363
if len(test.wantBody) > 0 {
364-
body, err := ioutil.ReadAll(resp.Body)
364+
body, err := io.ReadAll(resp.Body)
365365
if err != nil {
366366
t.Errorf("failed to read body: %v", err)
367367
}
@@ -440,7 +440,7 @@ func TestGetInclusionProofByHash(t *testing.T) {
440440
}
441441
if test.wantStatus == http.StatusOK {
442442
// If we're expecting a good response then check that all values got passed through ok
443-
body, err := ioutil.ReadAll(resp.Body)
443+
body, err := io.ReadAll(resp.Body)
444444
if err != nil {
445445
t.Fatalf("failed to read body: %v", err)
446446
}

binary_transparency/firmware/cmd/ft_witness/internal/http/witness_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package http
1616

1717
import (
1818
"fmt"
19-
"io/ioutil"
19+
"io"
2020
"net/http"
2121
"net/http/httptest"
2222
"testing"
@@ -65,7 +65,7 @@ func TestGetWitnessCheckpoint(t *testing.T) {
6565
if resp.StatusCode != http.StatusOK {
6666
t.Errorf("status code not OK: %v", resp.StatusCode)
6767
}
68-
body, err := ioutil.ReadAll(resp.Body)
68+
body, err := io.ReadAll(resp.Body)
6969
if err != nil {
7070
t.Errorf("failed to read body: %v", err)
7171
}

binary_transparency/firmware/cmd/ft_witness/internal/ws/store.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package ws
1717

1818
import (
1919
"fmt"
20-
"io/ioutil"
2120
"os"
2221
"sync"
2322
)
@@ -84,5 +83,5 @@ func (ws *Storage) RetrieveCP() ([]byte, error) {
8483

8584
ws.storeLock.Lock()
8685
defer ws.storeLock.Unlock()
87-
return ioutil.ReadFile(ws.fp)
86+
return os.ReadFile(ws.fp)
8887
}

binary_transparency/firmware/cmd/ftmapserver/impl/ftmapserver_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package impl
1717
import (
1818
"encoding/base64"
1919
"fmt"
20-
"io/ioutil"
20+
"io"
2121
"net/http"
2222
"net/http/httptest"
2323
"testing"
@@ -76,7 +76,7 @@ func TestRoot(t *testing.T) {
7676
if resp.StatusCode != http.StatusOK {
7777
t.Errorf("status code not OK: %v", resp.StatusCode)
7878
}
79-
body, err := ioutil.ReadAll(resp.Body)
79+
body, err := io.ReadAll(resp.Body)
8080
if err != nil {
8181
t.Errorf("failed to read body: %v", err)
8282
}
@@ -134,7 +134,7 @@ func TestTile(t *testing.T) {
134134
if resp.StatusCode != http.StatusOK {
135135
t.Errorf("status code not OK: %v (%s)", resp.StatusCode, url)
136136
}
137-
body, err := ioutil.ReadAll(resp.Body)
137+
body, err := io.ReadAll(resp.Body)
138138
if err != nil {
139139
t.Errorf("failed to read body: %v", err)
140140
}
@@ -189,7 +189,7 @@ func TestAggregation(t *testing.T) {
189189
if resp.StatusCode != http.StatusOK {
190190
t.Errorf("status code not OK: %v (%s)", resp.StatusCode, url)
191191
}
192-
body, err := ioutil.ReadAll(resp.Body)
192+
body, err := io.ReadAll(resp.Body)
193193
if err != nil {
194194
t.Errorf("failed to read body: %v", err)
195195
}

binary_transparency/firmware/cmd/hacker/modify_bundle/impl/modify_bundle.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"encoding/json"
2525
"errors"
2626
"fmt"
27-
"io/ioutil"
27+
"os"
2828

2929
"github.com/google/trillian-examples/binary_transparency/firmware/api"
3030
dummy_common "github.com/google/trillian-examples/binary_transparency/firmware/devices/dummy/common"
@@ -47,7 +47,7 @@ func Main(opts ModifyBundleOpts) error {
4747
return errors.New("must specify BinaryPath")
4848
}
4949

50-
bundleRaw, err := ioutil.ReadFile(opts.Input)
50+
bundleRaw, err := os.ReadFile(opts.Input)
5151
if err != nil {
5252
return fmt.Errorf("failed to read transparency bundle %q: %w", opts.Input, err)
5353
}
@@ -74,7 +74,7 @@ func Main(opts ModifyBundleOpts) error {
7474
return fmt.Errorf("DeviceID must be one of: 'dummy', 'armory'")
7575
}
7676

77-
fw, err := ioutil.ReadFile(opts.BinaryPath)
77+
fw, err := os.ReadFile(opts.BinaryPath)
7878
if err != nil {
7979
return fmt.Errorf("failed to read %q: %w", opts.BinaryPath, err)
8080
}
@@ -116,7 +116,7 @@ func Main(opts ModifyBundleOpts) error {
116116
return fmt.Errorf("failed to marshal ProofBundle: %w", err)
117117
}
118118

119-
if err := ioutil.WriteFile(opts.Output, rawPB, 0x644); err != nil {
119+
if err := os.WriteFile(opts.Output, rawPB, 0x644); err != nil {
120120
return fmt.Errorf("failed to write modified bundle to %q: %w", opts.Output, err)
121121
}
122122

binary_transparency/firmware/cmd/hacker/modify_bundle/modify_bundle.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
// to the specified output file.
2020
//
2121
// Usage:
22-
// go run ./cmd/hacker/modify_bundle/ \
23-
// --logtostderr \
24-
// --device=[dummy,usbarmory] \
25-
// --binary=/path/to/new/firmware/image \
26-
// --input=/path/to/bundle.json \
27-
// --output=/path/to/bundle.json
22+
//
23+
// go run ./cmd/hacker/modify_bundle/ \
24+
// --logtostderr \
25+
// --device=[dummy,usbarmory] \
26+
// --binary=/path/to/new/firmware/image \
27+
// --input=/path/to/bundle.json \
28+
// --output=/path/to/bundle.json
2829
package main
2930

3031
import (

binary_transparency/firmware/cmd/publisher/impl/publish.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/json"
2222
"errors"
2323
"fmt"
24-
"io/ioutil"
2524
"net/url"
2625
"os"
2726
"time"
@@ -136,7 +135,7 @@ func createManifest(opts PublishOpts) (api.FirmwareMetadata, []byte, error) {
136135
return api.FirmwareMetadata{}, nil, errors.New("DeviceID must be one of: 'dummy', 'armory'")
137136
}
138137

139-
fw, err := ioutil.ReadFile(opts.BinaryPath)
138+
fw, err := os.ReadFile(opts.BinaryPath)
140139
if err != nil {
141140
return api.FirmwareMetadata{}, nil, fmt.Errorf("failed to read %q: %w", opts.BinaryPath, err)
142141
}

binary_transparency/firmware/devices/dummy/flash.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package dummy
1818
import (
1919
"encoding/json"
2020
"fmt"
21-
"io/ioutil"
2221
"os"
2322
"path/filepath"
2423

@@ -82,12 +81,12 @@ func (d Device) ApplyUpdate(u api.UpdatePackage) error {
8281
fwFile := filepath.Join(d.storage, firmwarePath)
8382
bundleFile := filepath.Join(d.storage, bundlePath)
8483

85-
if err := ioutil.WriteFile(bundleFile, u.ProofBundle, os.ModePerm); err != nil {
84+
if err := os.WriteFile(bundleFile, u.ProofBundle, os.ModePerm); err != nil {
8685
return fmt.Errorf("failed to write proof bundle to %q: %q", bundleFile, err)
8786
}
8887

8988
fw := u.FirmwareImage
90-
if err := ioutil.WriteFile(fwFile, fw, os.ModePerm); err != nil {
89+
if err := os.WriteFile(fwFile, fw, os.ModePerm); err != nil {
9190
return fmt.Errorf("failed to write firmware image to %q: %q", fwFile, err)
9291
}
9392

binary_transparency/firmware/devices/dummy/rom/rom.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package rom
1616

1717
import (
1818
"fmt"
19-
"io/ioutil"
19+
"os"
2020
"path/filepath"
2121

2222
"github.com/golang/glog"
@@ -55,12 +55,12 @@ func Reset(storagePath string) (Chain, error) {
5555
fwFile := filepath.Clean(filepath.Join(storagePath, firmwarePath))
5656
bundleFile := filepath.Clean(filepath.Join(storagePath, bundlePath))
5757

58-
bundleRaw, err := ioutil.ReadFile(bundleFile)
58+
bundleRaw, err := os.ReadFile(bundleFile)
5959
if err != nil {
6060
return nil, fmt.Errorf("failed to read transparency bundle: %w", err)
6161
}
6262

63-
fw, err := ioutil.ReadFile(fwFile)
63+
fw, err := os.ReadFile(fwFile)
6464
if err != nil {
6565
return nil, fmt.Errorf("failed to read firmware: %w", err)
6666
}

binary_transparency/firmware/devices/usbarmory/bootloader/ext4.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"errors"
1616
"fmt"
1717
"io"
18-
"io/ioutil"
1918
"strings"
2019

2120
"github.com/dsoprea/go-ext4"
@@ -173,5 +172,5 @@ func (d *Partition) ReadAll(fullPath string) (buf []byte, err error) {
173172
en := ext4.NewExtentNavigatorWithReadSeeker(d, inode)
174173
r := ext4.NewInodeReader(en)
175174

176-
return ioutil.ReadAll(r)
175+
return io.ReadAll(r)
177176
}

binary_transparency/firmware/devices/usbarmory/flash/flash.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"encoding/json"
2020
"errors"
2121
"fmt"
22-
"io/ioutil"
2322
"os"
2423
"path/filepath"
2524
"strings"
@@ -95,12 +94,12 @@ func (d Device) DeviceCheckpoint() ([]byte, error) {
9594
//
9695
// TODO(al): see what can be done to make this easier to use.
9796
func (d Device) ApplyUpdate(u api.UpdatePackage) error {
98-
if err := ioutil.WriteFile(d.bundlePath, u.ProofBundle, os.ModePerm); err != nil {
97+
if err := os.WriteFile(d.bundlePath, u.ProofBundle, os.ModePerm); err != nil {
9998
return fmt.Errorf("failed to write proof bundle to %q: %w", d.bundlePath, err)
10099
}
101100

102101
fw := u.FirmwareImage
103-
if err := ioutil.WriteFile(d.fwDevPath, fw, os.ModePerm); err != nil {
102+
if err := os.WriteFile(d.fwDevPath, fw, os.ModePerm); err != nil {
104103
return fmt.Errorf("failed to write firmware image to %q: %w", d.fwDevPath, err)
105104
}
106105

binary_transparency/firmware/integration/ft_integration_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"context"
2020
"flag"
2121
"fmt"
22-
"io/ioutil"
2322
"net/http"
2423
"os"
2524
"path/filepath"
@@ -420,10 +419,10 @@ func runMonitor(ctx context.Context, t *testing.T, serverAddr string, pattern st
420419
}
421420

422421
func copyFile(from, to string) error {
423-
i, err := ioutil.ReadFile(from)
422+
i, err := os.ReadFile(from)
424423
if err != nil {
425424
return err
426425
}
427426

428-
return ioutil.WriteFile(to, i, 0644)
427+
return os.WriteFile(to, i, 0644)
429428
}

0 commit comments

Comments
 (0)