Skip to content

Commit 03d3858

Browse files
authored
[CORE-797] Update to go v1.18.10 to fix net-package vulnerability (#116)
* Update to go v1.18.10 to fix net-package vulnerability * Update to latest go-commons
1 parent 98349cb commit 03d3858

File tree

8 files changed

+35
-1101
lines changed

8 files changed

+35
-1101
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
defaults: &defaults
22
docker:
3-
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.16-go111module
3+
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.18-tf1.4-tg39.1-pck1.8-ci50.7
44

55
version: 2
66
jobs:

checksum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/sirupsen/logrus"
1414
)
1515

16-
func verifyChecksumOfReleaseAsset(logger *logrus.Logger, assetPath string, checksumMap map[string]bool, algorithm string) *FetchError {
16+
func verifyChecksumOfReleaseAsset(logger *logrus.Entry, assetPath string, checksumMap map[string]bool, algorithm string) *FetchError {
1717
computedChecksum, err := computeChecksum(assetPath, algorithm)
1818
if err != nil {
1919
return newError(errorWhileComputingChecksum, err.Error())

file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// Download the zip file at the given URL to a temporary local directory.
1717
// Returns the absolute path to the downloaded zip file.
1818
// IMPORTANT: You must call "defer os.RemoveAll(dir)" in the calling function when done with the downloaded zip file!
19-
func downloadGithubZipFile(logger *logrus.Logger, gitHubCommit GitHubCommit, gitHubToken string, instance GitHubInstance) (string, *FetchError) {
19+
func downloadGithubZipFile(logger *logrus.Entry, gitHubCommit GitHubCommit, gitHubToken string, instance GitHubInstance) (string, *FetchError) {
2020

2121
var zipFilePath string
2222

github.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type GitHubReleaseAsset struct {
7676
Name string
7777
}
7878

79-
func ParseUrlIntoGithubInstance(logger *logrus.Logger, repoUrl string, apiv string) (GitHubInstance, *FetchError) {
79+
func ParseUrlIntoGithubInstance(logger *logrus.Entry, repoUrl string, apiv string) (GitHubInstance, *FetchError) {
8080
var instance GitHubInstance
8181

8282
u, err := url.Parse(repoUrl)
@@ -216,7 +216,6 @@ var nextLinkRegex = regexp.MustCompile(`<(.+?)>;\s*rel="next"`)
216216
// empty string. The link header is expected to be of the form:
217217
//
218218
// <url>; rel="next", <url>; rel="last"
219-
//
220219
func getNextUrl(links string) string {
221220
if len(links) == 0 {
222221
return ""

go.mod

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
module github.com/gruntwork-io/fetch
22

3-
go 1.14
3+
go 1.18
44

55
require (
6-
github.com/davecgh/go-spew v1.1.1 // indirect
76
github.com/dustin/go-humanize v1.0.0
8-
github.com/gruntwork-io/go-commons v0.9.2
7+
github.com/gruntwork-io/go-commons v0.16.1
98
github.com/hashicorp/go-version v1.3.0
10-
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
11-
github.com/kr/pretty v0.2.1 // indirect
12-
github.com/kr/text v0.2.0 // indirect
13-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
14-
github.com/pmezard/go-difflib v1.0.0 // indirect
159
github.com/sirupsen/logrus v1.8.1
16-
github.com/stretchr/testify v1.7.0
17-
golang.org/x/sys v0.0.0-20210629170331-7dc0b73dc9fb // indirect
18-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
10+
github.com/stretchr/testify v1.8.0
1911
gopkg.in/urfave/cli.v1 v1.20.0
20-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
12+
)
13+
14+
require (
15+
github.com/davecgh/go-spew v1.1.1 // indirect
16+
github.com/pmezard/go-difflib v1.0.0 // indirect
17+
golang.org/x/sys v0.1.0 // indirect
18+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
19+
gopkg.in/yaml.v3 v3.0.1 // indirect
2120
)

go.sum

Lines changed: 11 additions & 1075 deletions
Large diffs are not rendered by default.

logger.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
const DEFAULT_LOG_LEVEL = logrus.InfoLevel
1111

1212
// GetProjectLogger returns a logging instance for this project
13-
func GetProjectLogger() *logrus.Logger {
14-
return logging.GetLogger("fetch")
13+
func GetProjectLogger() *logrus.Entry {
14+
return logging.GetLogger("fetch", "")
1515
}
1616

1717
// GetProjectLoggerWithWriter creates a logger around the given output stream
18-
func GetProjectLoggerWithWriter(writer io.Writer) *logrus.Logger {
18+
func GetProjectLoggerWithWriter(writer io.Writer) *logrus.Entry {
1919
logger := GetProjectLogger()
20-
logger.SetOutput(writer)
20+
logger.Logger.Out = writer
2121
return logger
2222
}

main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type FetchOptions struct {
3636
WithProgress bool
3737

3838
// Project logger
39-
Logger *logrus.Logger
39+
Logger *logrus.Entry
4040
}
4141

4242
type AssetDownloadResult struct {
@@ -176,7 +176,7 @@ func runFetchWrapper(c *cli.Context) {
176176
}
177177

178178
// Run the fetch program
179-
func runFetch(c *cli.Context, logger *logrus.Logger) error {
179+
func runFetch(c *cli.Context, logger *logrus.Entry) error {
180180
options := parseOptions(c, logger)
181181
if err := validateOptions(options); err != nil {
182182
return err
@@ -278,7 +278,7 @@ func runFetch(c *cli.Context, logger *logrus.Logger) error {
278278
return nil
279279
}
280280

281-
func parseOptions(c *cli.Context, logger *logrus.Logger) FetchOptions {
281+
func parseOptions(c *cli.Context, logger *logrus.Entry) FetchOptions {
282282
localDownloadPath := c.Args().First()
283283
sourcePaths := c.StringSlice(optionSourcePath)
284284
assetChecksums := c.StringSlice(optionReleaseAssetChecksum)
@@ -340,7 +340,7 @@ func validateOptions(options FetchOptions) error {
340340
}
341341

342342
// Download the specified source files from the given repo
343-
func downloadSourcePaths(logger *logrus.Logger, sourcePaths []string, destPath string, githubRepo GitHubRepo, latestTag string, branchName string, commitSha string, instance GitHubInstance) error {
343+
func downloadSourcePaths(logger *logrus.Entry, sourcePaths []string, destPath string, githubRepo GitHubRepo, latestTag string, branchName string, commitSha string, instance GitHubInstance) error {
344344
if len(sourcePaths) == 0 {
345345
return nil
346346
}
@@ -406,7 +406,7 @@ func downloadSourcePaths(logger *logrus.Logger, sourcePaths []string, destPath s
406406
// were downloaded. For those that succeeded, the path they were downloaded to will be passed back
407407
// along with the error.
408408
// Returns the paths where the release assets were downloaded.
409-
func downloadReleaseAssets(logger *logrus.Logger, assetRegex string, destPath string, githubRepo GitHubRepo, tag string, withProgress bool) ([]string, error) {
409+
func downloadReleaseAssets(logger *logrus.Entry, assetRegex string, destPath string, githubRepo GitHubRepo, tag string, withProgress bool) ([]string, error) {
410410
var err error
411411
var assetPaths []string
412412

0 commit comments

Comments
 (0)