dependabot-core 0.86.25 → 0.87.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -3
- data/helpers/go/go.mod +2 -3
- data/helpers/go/go.sum +0 -3
- data/helpers/go/importresolver/go.mod +1 -0
- data/helpers/go/main.go +0 -10
- data/lib/dependabot/file_fetchers.rb +1 -3
- data/lib/dependabot/file_parsers.rb +1 -3
- data/lib/dependabot/file_updaters.rb +1 -3
- data/lib/dependabot/metadata_finders.rb +1 -2
- data/lib/dependabot/pull_request_creator/github.rb +17 -6
- data/lib/dependabot/update_checkers.rb +1 -3
- data/lib/dependabot/update_checkers/java_script/npm_and_yarn/requirements_updater.rb +2 -1
- data/lib/dependabot/utils.rb +2 -4
- data/lib/dependabot/version.rb +1 -1
- metadata +2 -12
- data/helpers/go/updatechecker/main.go +0 -107
- data/helpers/go/updater/go.mod +0 -3
- data/helpers/go/updater/go.sum +0 -2
- data/helpers/go/updater/helpers.go +0 -57
- data/helpers/go/updater/main.go +0 -48
- data/lib/dependabot/file_fetchers/go/modules.rb +0 -64
- data/lib/dependabot/file_parsers/go/modules.rb +0 -34
- data/lib/dependabot/file_parsers/go/modules/go_mod_parser.rb +0 -134
- data/lib/dependabot/file_updaters/go/modules.rb +0 -71
- data/lib/dependabot/file_updaters/go/modules/go_mod_updater.rb +0 -81
- data/lib/dependabot/update_checkers/go/modules.rb +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2e46d1583d18b098fe5b5e15f14fd1c7cfd7c777d656cfd9848d30707b295f0
|
4
|
+
data.tar.gz: e004738d88222a5488e489b247184b98914645abb1fb3062f609b27a17111af0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cb1368c7f61de9b26efb85a29e4146c72121fa448801bdef74fd0a64ee4ae2668f83a4779fa032131eaaa7530625f76c85c2ff4f53e6caf1f7cf3e26a356047
|
7
|
+
data.tar.gz: ddb71c7d249b391ba49efbb257293e21ffbfafcd179f8e162ba2128d53be29bd615ac947ba1f8ed25e9467b6a9c9424bdbf2df2164a0c214c3a0dcf766fa517b
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
## v0.87.0, 2 January 2019
|
2
|
+
|
3
|
+
- Go (modules): reorg
|
4
|
+
- JS: Handle requirements with an || when bumping versions
|
5
|
+
|
1
6
|
## v0.86.25, 2 January 2019
|
2
7
|
|
3
8
|
- Raise RepoNotFound errors when creating PRs
|
4
|
-
- Merge pull request #875 from dependabot/dependabot/composer/helpers/php/friendsofphp/php-cs-fixer-2.13.2
|
5
|
-
- Bump friendsofphp/php-cs-fixer from 2.13.1 to 2.13.2 in /helpers/php
|
6
9
|
- Python: Don't treat post-releases as pre-releases
|
7
|
-
- Save a couple of lines
|
8
10
|
|
9
11
|
## v0.86.24, 1 January 2019
|
10
12
|
|
data/helpers/go/go.mod
CHANGED
@@ -2,8 +2,7 @@ module github.com/dependabot/dependabot-core/helpers/go
|
|
2
2
|
|
3
3
|
require (
|
4
4
|
github.com/Masterminds/vcs v1.12.0
|
5
|
-
github.com/dependabot/dependabot-core/helpers/go/
|
6
|
-
github.com/dependabot/gomodules-extracted v0.0.0-20181020215834-1b2f850478a3
|
5
|
+
github.com/dependabot/dependabot-core/helpers/go/importresolver v0.0.0
|
7
6
|
)
|
8
7
|
|
9
|
-
replace github.com/dependabot/dependabot-core/helpers/go/
|
8
|
+
replace github.com/dependabot/dependabot-core/helpers/go/importresolver => ./importresolver
|
data/helpers/go/go.sum
CHANGED
@@ -1,5 +1,2 @@
|
|
1
1
|
github.com/Masterminds/vcs v1.12.0 h1:bt9Hb4XlfmEfLnVA0MVz2NO0GFuMN5vX8iOWW38Xde4=
|
2
2
|
github.com/Masterminds/vcs v1.12.0/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA=
|
3
|
-
github.com/dependabot/dependabot-core v0.74.6 h1:SB2Oyie+Ex9ARXLHbFrnoQSWSixAG4ORHA+s6YEvVag=
|
4
|
-
github.com/dependabot/gomodules-extracted v0.0.0-20181020215834-1b2f850478a3 h1:Xj2leY0FVyZuo+p59vkIWG3dIqo+QtjskT5O1iTiywA=
|
5
|
-
github.com/dependabot/gomodules-extracted v0.0.0-20181020215834-1b2f850478a3/go.mod h1:+dRXSrUymjpT4yzKtn1QmeknT1S/yAHRr35en18dHp8=
|
@@ -0,0 +1 @@
|
|
1
|
+
module github.com/dependabot/dependabot-core/helpers/go/importresolver
|
data/helpers/go/main.go
CHANGED
@@ -7,8 +7,6 @@ import (
|
|
7
7
|
"os"
|
8
8
|
|
9
9
|
"github.com/dependabot/dependabot-core/helpers/go/importresolver"
|
10
|
-
"github.com/dependabot/dependabot-core/helpers/go/updatechecker"
|
11
|
-
"github.com/dependabot/dependabot-core/helpers/go/updater"
|
12
10
|
)
|
13
11
|
|
14
12
|
type HelperParams struct {
|
@@ -33,14 +31,6 @@ func main() {
|
|
33
31
|
funcErr error
|
34
32
|
)
|
35
33
|
switch helperParams.Function {
|
36
|
-
case "getUpdatedVersion":
|
37
|
-
var args updatechecker.Args
|
38
|
-
parseArgs(helperParams.Args, &args)
|
39
|
-
funcOut, funcErr = updatechecker.GetUpdatedVersion(&args)
|
40
|
-
case "updateDependencyFile":
|
41
|
-
var args updater.Args
|
42
|
-
parseArgs(helperParams.Args, &args)
|
43
|
-
funcOut, funcErr = updater.UpdateDependencyFile(&args)
|
44
34
|
case "getVcsRemoteForImport":
|
45
35
|
var args importresolver.Args
|
46
36
|
parseArgs(helperParams.Args, &args)
|
@@ -5,7 +5,6 @@ require "dependabot/file_fetchers/java_script/npm_and_yarn"
|
|
5
5
|
require "dependabot/file_fetchers/php/composer"
|
6
6
|
require "dependabot/file_fetchers/elixir/hex"
|
7
7
|
require "dependabot/file_fetchers/go/dep"
|
8
|
-
require "dependabot/file_fetchers/go/modules"
|
9
8
|
|
10
9
|
module Dependabot
|
11
10
|
module FileFetchers
|
@@ -14,8 +13,7 @@ module Dependabot
|
|
14
13
|
"npm_and_yarn" => FileFetchers::JavaScript::NpmAndYarn,
|
15
14
|
"composer" => FileFetchers::Php::Composer,
|
16
15
|
"hex" => FileFetchers::Elixir::Hex,
|
17
|
-
"dep" => FileFetchers::Go::Dep
|
18
|
-
"go_modules" => FileFetchers::Go::Modules
|
16
|
+
"dep" => FileFetchers::Go::Dep
|
19
17
|
}
|
20
18
|
|
21
19
|
def self.for_package_manager(package_manager)
|
@@ -5,7 +5,6 @@ require "dependabot/file_parsers/java_script/npm_and_yarn"
|
|
5
5
|
require "dependabot/file_parsers/php/composer"
|
6
6
|
require "dependabot/file_parsers/elixir/hex"
|
7
7
|
require "dependabot/file_parsers/go/dep"
|
8
|
-
require "dependabot/file_parsers/go/modules"
|
9
8
|
|
10
9
|
module Dependabot
|
11
10
|
module FileParsers
|
@@ -14,8 +13,7 @@ module Dependabot
|
|
14
13
|
"npm_and_yarn" => FileParsers::JavaScript::NpmAndYarn,
|
15
14
|
"composer" => FileParsers::Php::Composer,
|
16
15
|
"hex" => FileParsers::Elixir::Hex,
|
17
|
-
"dep" => FileParsers::Go::Dep
|
18
|
-
"go_modules" => FileParsers::Go::Modules
|
16
|
+
"dep" => FileParsers::Go::Dep
|
19
17
|
}
|
20
18
|
|
21
19
|
def self.for_package_manager(package_manager)
|
@@ -5,7 +5,6 @@ require "dependabot/file_updaters/java_script/npm_and_yarn"
|
|
5
5
|
require "dependabot/file_updaters/php/composer"
|
6
6
|
require "dependabot/file_updaters/elixir/hex"
|
7
7
|
require "dependabot/file_updaters/go/dep"
|
8
|
-
require "dependabot/file_updaters/go/modules"
|
9
8
|
|
10
9
|
module Dependabot
|
11
10
|
module FileUpdaters
|
@@ -14,8 +13,7 @@ module Dependabot
|
|
14
13
|
"npm_and_yarn" => FileUpdaters::JavaScript::NpmAndYarn,
|
15
14
|
"composer" => FileUpdaters::Php::Composer,
|
16
15
|
"hex" => FileUpdaters::Elixir::Hex,
|
17
|
-
"dep" => FileUpdaters::Go::Dep
|
18
|
-
"go_modules" => FileUpdaters::Go::Modules
|
16
|
+
"dep" => FileUpdaters::Go::Dep
|
19
17
|
}
|
20
18
|
|
21
19
|
def self.for_package_manager(package_manager)
|
@@ -13,8 +13,7 @@ module Dependabot
|
|
13
13
|
"npm_and_yarn" => MetadataFinders::JavaScript::NpmAndYarn,
|
14
14
|
"composer" => MetadataFinders::Php::Composer,
|
15
15
|
"hex" => MetadataFinders::Elixir::Hex,
|
16
|
-
"dep" => MetadataFinders::Go::Dep
|
17
|
-
"go_modules" => MetadataFinders::Go::Dep
|
16
|
+
"dep" => MetadataFinders::Go::Dep
|
18
17
|
}
|
19
18
|
|
20
19
|
def self.for_package_manager(package_manager)
|
@@ -47,12 +47,8 @@ module Dependabot
|
|
47
47
|
annotate_pull_request(pull_request)
|
48
48
|
|
49
49
|
pull_request
|
50
|
-
rescue Octokit::
|
51
|
-
|
52
|
-
raise RepoArchived
|
53
|
-
rescue Octokit::NotFound => error
|
54
|
-
raise if repo_exists?
|
55
|
-
raise RepoNotFound
|
50
|
+
rescue Octokit::Error => error
|
51
|
+
handle_error(error)
|
56
52
|
end
|
57
53
|
|
58
54
|
private
|
@@ -241,6 +237,21 @@ module Dependabot
|
|
241
237
|
signature_key: signature_key
|
242
238
|
).signature
|
243
239
|
end
|
240
|
+
|
241
|
+
def handle_error(error)
|
242
|
+
case error
|
243
|
+
when Octokit::Forbidden
|
244
|
+
raise error unless error.message.include?("Repository was archived")
|
245
|
+
|
246
|
+
raise RepoArchived
|
247
|
+
when Octokit::NotFound
|
248
|
+
raise error if repo_exists?
|
249
|
+
|
250
|
+
raise RepoNotFound
|
251
|
+
else
|
252
|
+
raise error
|
253
|
+
end
|
254
|
+
end
|
244
255
|
end
|
245
256
|
end
|
246
257
|
end
|
@@ -5,7 +5,6 @@ require "dependabot/update_checkers/java_script/npm_and_yarn"
|
|
5
5
|
require "dependabot/update_checkers/php/composer"
|
6
6
|
require "dependabot/update_checkers/elixir/hex"
|
7
7
|
require "dependabot/update_checkers/go/dep"
|
8
|
-
require "dependabot/update_checkers/go/modules"
|
9
8
|
|
10
9
|
module Dependabot
|
11
10
|
module UpdateCheckers
|
@@ -14,8 +13,7 @@ module Dependabot
|
|
14
13
|
"npm_and_yarn" => UpdateCheckers::JavaScript::NpmAndYarn,
|
15
14
|
"composer" => UpdateCheckers::Php::Composer,
|
16
15
|
"hex" => UpdateCheckers::Elixir::Hex,
|
17
|
-
"dep" => UpdateCheckers::Go::Dep
|
18
|
-
"go_modules" => UpdateCheckers::Go::Modules
|
16
|
+
"dep" => UpdateCheckers::Go::Dep
|
19
17
|
}
|
20
18
|
|
21
19
|
def self.for_package_manager(package_manager)
|
@@ -90,7 +90,8 @@ module Dependabot
|
|
90
90
|
return req.merge(requirement: updated_req)
|
91
91
|
end
|
92
92
|
|
93
|
-
|
93
|
+
reqs = current_requirement.strip.split(SEPARATOR).map(&:strip)
|
94
|
+
req.merge(requirement: update_version_string(reqs.first))
|
94
95
|
end
|
95
96
|
|
96
97
|
def update_version_requirement_if_needed(req)
|
data/lib/dependabot/utils.rb
CHANGED
@@ -22,8 +22,7 @@ module Dependabot
|
|
22
22
|
"npm_and_yarn" => Utils::JavaScript::Version,
|
23
23
|
"composer" => Utils::Php::Version,
|
24
24
|
"hex" => Utils::Elixir::Version,
|
25
|
-
"dep" => Utils::Go::Version
|
26
|
-
"go_modules" => Utils::Go::Version
|
25
|
+
"dep" => Utils::Go::Version
|
27
26
|
}
|
28
27
|
|
29
28
|
def self.version_class_for_package_manager(package_manager)
|
@@ -44,8 +43,7 @@ module Dependabot
|
|
44
43
|
"npm_and_yarn" => Utils::JavaScript::Requirement,
|
45
44
|
"composer" => Utils::Php::Requirement,
|
46
45
|
"hex" => Utils::Elixir::Requirement,
|
47
|
-
"dep" => Utils::Go::Requirement
|
48
|
-
"go_modules" => Utils::Go::Requirement
|
46
|
+
"dep" => Utils::Go::Requirement
|
49
47
|
}
|
50
48
|
|
51
49
|
def self.requirement_class_for_package_manager(package_manager)
|
data/lib/dependabot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.87.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
@@ -307,13 +307,9 @@ files:
|
|
307
307
|
- helpers/go/Makefile
|
308
308
|
- helpers/go/go.mod
|
309
309
|
- helpers/go/go.sum
|
310
|
+
- helpers/go/importresolver/go.mod
|
310
311
|
- helpers/go/importresolver/main.go
|
311
312
|
- helpers/go/main.go
|
312
|
-
- helpers/go/updatechecker/main.go
|
313
|
-
- helpers/go/updater/go.mod
|
314
|
-
- helpers/go/updater/go.sum
|
315
|
-
- helpers/go/updater/helpers.go
|
316
|
-
- helpers/go/updater/main.go
|
317
313
|
- helpers/npm/.eslintrc
|
318
314
|
- helpers/npm/bin/run.js
|
319
315
|
- helpers/npm/lib/helpers.js
|
@@ -377,7 +373,6 @@ files:
|
|
377
373
|
- lib/dependabot/file_fetchers/base.rb
|
378
374
|
- lib/dependabot/file_fetchers/elixir/hex.rb
|
379
375
|
- lib/dependabot/file_fetchers/go/dep.rb
|
380
|
-
- lib/dependabot/file_fetchers/go/modules.rb
|
381
376
|
- lib/dependabot/file_fetchers/java_script/npm_and_yarn.rb
|
382
377
|
- lib/dependabot/file_fetchers/java_script/npm_and_yarn/path_dependency_builder.rb
|
383
378
|
- lib/dependabot/file_fetchers/php/composer.rb
|
@@ -391,8 +386,6 @@ files:
|
|
391
386
|
- lib/dependabot/file_parsers/base/dependency_set.rb
|
392
387
|
- lib/dependabot/file_parsers/elixir/hex.rb
|
393
388
|
- lib/dependabot/file_parsers/go/dep.rb
|
394
|
-
- lib/dependabot/file_parsers/go/modules.rb
|
395
|
-
- lib/dependabot/file_parsers/go/modules/go_mod_parser.rb
|
396
389
|
- lib/dependabot/file_parsers/java_script/npm_and_yarn.rb
|
397
390
|
- lib/dependabot/file_parsers/php/composer.rb
|
398
391
|
- lib/dependabot/file_parsers/ruby/bundler.rb
|
@@ -410,8 +403,6 @@ files:
|
|
410
403
|
- lib/dependabot/file_updaters/go/dep.rb
|
411
404
|
- lib/dependabot/file_updaters/go/dep/lockfile_updater.rb
|
412
405
|
- lib/dependabot/file_updaters/go/dep/manifest_updater.rb
|
413
|
-
- lib/dependabot/file_updaters/go/modules.rb
|
414
|
-
- lib/dependabot/file_updaters/go/modules/go_mod_updater.rb
|
415
406
|
- lib/dependabot/file_updaters/java_script/npm_and_yarn.rb
|
416
407
|
- lib/dependabot/file_updaters/java_script/npm_and_yarn/npm_lockfile_updater.rb
|
417
408
|
- lib/dependabot/file_updaters/java_script/npm_and_yarn/npmrc_builder.rb
|
@@ -466,7 +457,6 @@ files:
|
|
466
457
|
- lib/dependabot/update_checkers/go/dep/latest_version_finder.rb
|
467
458
|
- lib/dependabot/update_checkers/go/dep/requirements_updater.rb
|
468
459
|
- lib/dependabot/update_checkers/go/dep/version_resolver.rb
|
469
|
-
- lib/dependabot/update_checkers/go/modules.rb
|
470
460
|
- lib/dependabot/update_checkers/java_script/npm_and_yarn.rb
|
471
461
|
- lib/dependabot/update_checkers/java_script/npm_and_yarn/latest_version_finder.rb
|
472
462
|
- lib/dependabot/update_checkers/java_script/npm_and_yarn/library_detector.rb
|
@@ -1,107 +0,0 @@
|
|
1
|
-
package updatechecker
|
2
|
-
|
3
|
-
import (
|
4
|
-
"errors"
|
5
|
-
"io/ioutil"
|
6
|
-
|
7
|
-
"github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modfetch"
|
8
|
-
"github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modfile"
|
9
|
-
"github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modload"
|
10
|
-
"github.com/dependabot/gomodules-extracted/cmd/go/_internal_/semver"
|
11
|
-
)
|
12
|
-
|
13
|
-
type Dependency struct {
|
14
|
-
Name string `json:"name"`
|
15
|
-
Version string `json:"version"`
|
16
|
-
Indirect bool `json:"indirect"`
|
17
|
-
}
|
18
|
-
|
19
|
-
type IgnoreRange struct {
|
20
|
-
MinVersionInclusive string `json:"min_version_inclusive"`
|
21
|
-
MaxVersionExclusive string `json:"max_version_exclusive"`
|
22
|
-
}
|
23
|
-
|
24
|
-
type Args struct {
|
25
|
-
Dependency *Dependency `json:"dependency"`
|
26
|
-
IgnoreRanges []*IgnoreRange `json:"ignore_ranges"`
|
27
|
-
}
|
28
|
-
|
29
|
-
func GetUpdatedVersion(args *Args) (interface{}, error) {
|
30
|
-
if args.Dependency == nil {
|
31
|
-
return nil, errors.New("Expected args.dependency to not be nil")
|
32
|
-
}
|
33
|
-
|
34
|
-
modload.InitMod()
|
35
|
-
|
36
|
-
repo, err := modfetch.Lookup(args.Dependency.Name)
|
37
|
-
if err != nil {
|
38
|
-
return nil, err
|
39
|
-
}
|
40
|
-
|
41
|
-
versions, err := repo.Versions("")
|
42
|
-
if err != nil {
|
43
|
-
return nil, err
|
44
|
-
}
|
45
|
-
|
46
|
-
excludes, err := goModExcludes(args.Dependency.Name)
|
47
|
-
if err != nil {
|
48
|
-
return nil, err
|
49
|
-
}
|
50
|
-
|
51
|
-
currentVersion := args.Dependency.Version
|
52
|
-
currentMajor := semver.Major(currentVersion)
|
53
|
-
currentPrerelease := semver.Prerelease(currentVersion)
|
54
|
-
latestVersion := args.Dependency.Version
|
55
|
-
|
56
|
-
Outer:
|
57
|
-
for _, v := range versions {
|
58
|
-
if semver.Major(v) != currentMajor {
|
59
|
-
continue
|
60
|
-
}
|
61
|
-
|
62
|
-
if semver.Compare(v, latestVersion) < 1 {
|
63
|
-
continue
|
64
|
-
}
|
65
|
-
|
66
|
-
if currentPrerelease == "" && semver.Prerelease(v) != "" {
|
67
|
-
continue
|
68
|
-
}
|
69
|
-
|
70
|
-
for _, exclude := range excludes {
|
71
|
-
if v == exclude {
|
72
|
-
continue Outer
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
latestVersion = v
|
77
|
-
}
|
78
|
-
|
79
|
-
return latestVersion, nil
|
80
|
-
}
|
81
|
-
|
82
|
-
func goModExcludes(dependency string) ([]string, error) {
|
83
|
-
data, err := ioutil.ReadFile("go.mod")
|
84
|
-
if err != nil {
|
85
|
-
return nil, err
|
86
|
-
}
|
87
|
-
|
88
|
-
var f *modfile.File
|
89
|
-
// TODO library detection - don't consider exclude etc for libraries
|
90
|
-
if "library" == "true" {
|
91
|
-
f, err = modfile.ParseLax("go.mod", data, nil)
|
92
|
-
} else {
|
93
|
-
f, err = modfile.Parse("go.mod", data, nil)
|
94
|
-
}
|
95
|
-
if err != nil {
|
96
|
-
return nil, err
|
97
|
-
}
|
98
|
-
|
99
|
-
var excludes []string
|
100
|
-
for _, e := range f.Exclude {
|
101
|
-
if e.Mod.Path == dependency {
|
102
|
-
excludes = append(excludes, e.Mod.Version)
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
return excludes, nil
|
107
|
-
}
|
data/helpers/go/updater/go.mod
DELETED
data/helpers/go/updater/go.sum
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
package updater
|
2
|
-
|
3
|
-
import (
|
4
|
-
"strings"
|
5
|
-
|
6
|
-
"github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modfile"
|
7
|
-
)
|
8
|
-
|
9
|
-
// Private methods lifted from the `modfile` package
|
10
|
-
|
11
|
-
// setIndirect sets line to have (or not have) a "// indirect" comment.
|
12
|
-
func setIndirect(line *modfile.Line, indirect bool) {
|
13
|
-
if isIndirect(line) == indirect {
|
14
|
-
return
|
15
|
-
}
|
16
|
-
if indirect {
|
17
|
-
// Adding comment.
|
18
|
-
if len(line.Suffix) == 0 {
|
19
|
-
// New comment.
|
20
|
-
line.Suffix = []modfile.Comment{{Token: "// indirect", Suffix: true}}
|
21
|
-
return
|
22
|
-
}
|
23
|
-
// Insert at beginning of existing comment.
|
24
|
-
com := &line.Suffix[0]
|
25
|
-
space := " "
|
26
|
-
if len(com.Token) > 2 && com.Token[2] == ' ' || com.Token[2] == '\t' {
|
27
|
-
space = ""
|
28
|
-
}
|
29
|
-
com.Token = "// indirect;" + space + com.Token[2:]
|
30
|
-
return
|
31
|
-
}
|
32
|
-
|
33
|
-
// Removing comment.
|
34
|
-
f := strings.Fields(line.Suffix[0].Token)
|
35
|
-
if len(f) == 2 {
|
36
|
-
// Remove whole comment.
|
37
|
-
line.Suffix = nil
|
38
|
-
return
|
39
|
-
}
|
40
|
-
|
41
|
-
// Remove comment prefix.
|
42
|
-
com := &line.Suffix[0]
|
43
|
-
i := strings.Index(com.Token, "indirect;")
|
44
|
-
com.Token = "//" + com.Token[i+len("indirect;"):]
|
45
|
-
}
|
46
|
-
|
47
|
-
// isIndirect reports whether line has a "// indirect" comment,
|
48
|
-
// meaning it is in go.mod only for its effect on indirect dependencies,
|
49
|
-
// so that it can be dropped entirely once the effective version of the
|
50
|
-
// indirect dependency reaches the given minimum version.
|
51
|
-
func isIndirect(line *modfile.Line) bool {
|
52
|
-
if len(line.Suffix) == 0 {
|
53
|
-
return false
|
54
|
-
}
|
55
|
-
f := strings.Fields(line.Suffix[0].Token)
|
56
|
-
return (len(f) == 2 && f[1] == "indirect" || len(f) > 2 && f[1] == "indirect;") && f[0] == "//"
|
57
|
-
}
|
data/helpers/go/updater/main.go
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
package updater
|
2
|
-
|
3
|
-
import (
|
4
|
-
"io/ioutil"
|
5
|
-
|
6
|
-
"github.com/dependabot/gomodules-extracted/cmd/go/_internal_/modfile"
|
7
|
-
)
|
8
|
-
|
9
|
-
type Dependency struct {
|
10
|
-
Name string `json:"name"`
|
11
|
-
Version string `json:"version"`
|
12
|
-
Indirect bool `json:"indirect"`
|
13
|
-
}
|
14
|
-
|
15
|
-
type Args struct {
|
16
|
-
Dependencies []Dependency `json:"dependencies"`
|
17
|
-
}
|
18
|
-
|
19
|
-
func UpdateDependencyFile(args *Args) (interface{}, error) {
|
20
|
-
data, err := ioutil.ReadFile("go.mod")
|
21
|
-
if err != nil {
|
22
|
-
return nil, err
|
23
|
-
}
|
24
|
-
|
25
|
-
f, err := modfile.Parse("go.mod", data, nil)
|
26
|
-
if err != nil {
|
27
|
-
return nil, err
|
28
|
-
}
|
29
|
-
|
30
|
-
for _, dep := range args.Dependencies {
|
31
|
-
f.AddRequire(dep.Name, dep.Version)
|
32
|
-
}
|
33
|
-
|
34
|
-
for _, r := range f.Require {
|
35
|
-
for _, dep := range args.Dependencies {
|
36
|
-
if r.Mod.Path == dep.Name {
|
37
|
-
setIndirect(r.Syntax, dep.Indirect)
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
f.SortBlocks()
|
43
|
-
f.Cleanup()
|
44
|
-
|
45
|
-
newModFile, _ := f.Format()
|
46
|
-
|
47
|
-
return string(newModFile), nil
|
48
|
-
}
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dependabot/file_fetchers/base"
|
4
|
-
|
5
|
-
module Dependabot
|
6
|
-
module FileFetchers
|
7
|
-
module Go
|
8
|
-
class Modules < Dependabot::FileFetchers::Base
|
9
|
-
def self.required_files_in?(filenames)
|
10
|
-
filenames.include?("go.mod")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.required_files_message
|
14
|
-
"Repo must contain a go.mod."
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def fetch_files
|
20
|
-
unless go_mod
|
21
|
-
raise(
|
22
|
-
Dependabot::DependencyFileNotFound,
|
23
|
-
File.join(directory, "go.mod")
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
fetched_files = [go_mod]
|
28
|
-
|
29
|
-
# Fetch the (optional) go.sum
|
30
|
-
fetched_files << go_sum if go_sum
|
31
|
-
|
32
|
-
# Fetch the main.go file if present, as this will later identify
|
33
|
-
# this repo as an app.
|
34
|
-
fetched_files << main if main
|
35
|
-
|
36
|
-
fetched_files
|
37
|
-
end
|
38
|
-
|
39
|
-
def go_mod
|
40
|
-
@go_mod ||= fetch_file_if_present("go.mod")
|
41
|
-
end
|
42
|
-
|
43
|
-
def go_sum
|
44
|
-
@go_sum ||= fetch_file_if_present("go.sum")
|
45
|
-
end
|
46
|
-
|
47
|
-
def main
|
48
|
-
return @main if @main
|
49
|
-
|
50
|
-
go_files = repo_contents.select { |f| f.name.end_with?(".go") }
|
51
|
-
|
52
|
-
go_files.each do |go_file|
|
53
|
-
file = fetch_file_from_host(go_file.name, type: "package_main")
|
54
|
-
next unless file.content.match?(/\s*package\s+main/)
|
55
|
-
|
56
|
-
return @main = file.tap { |f| f.support_file = true }
|
57
|
-
end
|
58
|
-
|
59
|
-
nil
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dependabot/file_parsers/base"
|
4
|
-
|
5
|
-
module Dependabot
|
6
|
-
module FileParsers
|
7
|
-
module Go
|
8
|
-
class Modules < Dependabot::FileParsers::Base
|
9
|
-
require_relative "modules/go_mod_parser"
|
10
|
-
|
11
|
-
def parse
|
12
|
-
go_mod_dependencies.dependencies
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def go_mod_dependencies
|
18
|
-
@go_mod_dependencies ||=
|
19
|
-
Modules::GoModParser.
|
20
|
-
new(dependency_files: dependency_files, credentials: credentials).
|
21
|
-
dependency_set
|
22
|
-
end
|
23
|
-
|
24
|
-
def go_mod
|
25
|
-
@go_mod ||= get_original_file("go.mod")
|
26
|
-
end
|
27
|
-
|
28
|
-
def check_required_files
|
29
|
-
raise "No go.mod!" unless go_mod
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "open3"
|
4
|
-
require "dependabot/dependency"
|
5
|
-
require "dependabot/file_parsers/base/dependency_set"
|
6
|
-
require "dependabot/file_parsers/go/modules"
|
7
|
-
require "dependabot/utils/go/path_converter"
|
8
|
-
require "dependabot/errors"
|
9
|
-
|
10
|
-
module Dependabot
|
11
|
-
module FileParsers
|
12
|
-
module Go
|
13
|
-
class Modules
|
14
|
-
class GoModParser
|
15
|
-
GIT_VERSION_REGEX = /^v\d+\.\d+\.\d+-.*-(?<sha>[0-9a-f]{12})$/.freeze
|
16
|
-
|
17
|
-
def initialize(dependency_files:, credentials:)
|
18
|
-
@dependency_files = dependency_files
|
19
|
-
@credentials = credentials
|
20
|
-
end
|
21
|
-
|
22
|
-
def dependency_set
|
23
|
-
dependencies = Dependabot::FileParsers::Base::DependencySet.new
|
24
|
-
|
25
|
-
i = 0
|
26
|
-
chunks = module_info(go_mod).lines.
|
27
|
-
group_by { |line| line == "{\n" ? i += 1 : i }
|
28
|
-
deps = chunks.values.map { |chunk| JSON.parse(chunk.join) }
|
29
|
-
|
30
|
-
deps.each do |dep|
|
31
|
-
# The project itself appears in this list as "Main"
|
32
|
-
next if dep["Main"]
|
33
|
-
|
34
|
-
dependency = dependency_from_details(dep)
|
35
|
-
dependencies << dependency if dependency
|
36
|
-
end
|
37
|
-
|
38
|
-
dependencies
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
attr_reader :dependency_files, :credentials
|
44
|
-
|
45
|
-
def dependency_from_details(details)
|
46
|
-
source =
|
47
|
-
if rev_identifier?(details) then git_source(details)
|
48
|
-
else { type: "default", source: details["Path"] }
|
49
|
-
end
|
50
|
-
|
51
|
-
version = details["Version"]&.sub(/^v?/, "")
|
52
|
-
|
53
|
-
reqs = [{
|
54
|
-
requirement: rev_identifier?(details) ? nil : details["Version"],
|
55
|
-
file: go_mod.name,
|
56
|
-
source: source,
|
57
|
-
groups: []
|
58
|
-
}]
|
59
|
-
|
60
|
-
Dependency.new(
|
61
|
-
name: details["Path"],
|
62
|
-
version: version,
|
63
|
-
requirements: details["Indirect"] ? [] : reqs,
|
64
|
-
package_manager: "dep"
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
def module_info(go_mod)
|
69
|
-
@module_info ||=
|
70
|
-
SharedHelpers.in_a_temporary_directory do |path|
|
71
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
72
|
-
File.write("go.mod", go_mod.content)
|
73
|
-
|
74
|
-
command = "GO111MODULE=on go mod edit -print > /dev/null"
|
75
|
-
command += " && GO111MODULE=on go list -m -json all"
|
76
|
-
stdout, stderr, status = Open3.capture3(command)
|
77
|
-
handle_parser_error(path, stderr) unless status.success?
|
78
|
-
stdout
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def handle_parser_error(path, stderr)
|
84
|
-
case stderr
|
85
|
-
when /go: .*: unknown revision/
|
86
|
-
line = stderr.lines.grep(/unknown revision/).first
|
87
|
-
raise Dependabot::DependencyFileNotResolvable, line.strip
|
88
|
-
when /go: .*: unrecognized import path/
|
89
|
-
line = stderr.lines.grep(/unrecognized import/).first
|
90
|
-
raise Dependabot::DependencyFileNotResolvable, line.strip
|
91
|
-
when /go: errors parsing go.mod/
|
92
|
-
msg = stderr.gsub(path.to_s, "").strip
|
93
|
-
raise Dependabot::DependencyFileNotParseable.new(go_mod.path, msg)
|
94
|
-
else
|
95
|
-
msg = stderr.gsub(path.to_s, "").strip
|
96
|
-
raise Dependabot::DependencyFileNotParseable.new(go_mod.path, msg)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def rev_identifier?(dep)
|
101
|
-
dep["Version"]&.match?(GIT_VERSION_REGEX)
|
102
|
-
end
|
103
|
-
|
104
|
-
def git_source(dep)
|
105
|
-
url = Utils::Go::PathConverter.git_url_for_path(dep["Path"])
|
106
|
-
|
107
|
-
# Currently, we have no way of knowing whether the commit tagged
|
108
|
-
# is being used because a branch is being followed or because a
|
109
|
-
# particular ref is in use. We *assume* that a particular ref is in
|
110
|
-
# use (which means we'll only propose updates when its included in
|
111
|
-
# a release)
|
112
|
-
{
|
113
|
-
type: "git",
|
114
|
-
url: url || dep["Path"],
|
115
|
-
ref: git_revision(dep),
|
116
|
-
branch: nil
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
|
-
def git_revision(dep)
|
121
|
-
raw_version = dep.fetch("Version")
|
122
|
-
return raw_version unless raw_version.match?(GIT_VERSION_REGEX)
|
123
|
-
|
124
|
-
raw_version.match(GIT_VERSION_REGEX).named_captures.fetch("sha")
|
125
|
-
end
|
126
|
-
|
127
|
-
def go_mod
|
128
|
-
@go_mod ||= dependency_files.find { |f| f.name == "go.mod" }
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dependabot/shared_helpers"
|
4
|
-
require "dependabot/file_updaters/base"
|
5
|
-
|
6
|
-
module Dependabot
|
7
|
-
module FileUpdaters
|
8
|
-
module Go
|
9
|
-
class Modules < Dependabot::FileUpdaters::Base
|
10
|
-
require_relative "modules/go_mod_updater"
|
11
|
-
|
12
|
-
def self.updated_files_regex
|
13
|
-
[
|
14
|
-
/^go\.mod$/,
|
15
|
-
/^go\.sum$/
|
16
|
-
]
|
17
|
-
end
|
18
|
-
|
19
|
-
def updated_dependency_files
|
20
|
-
updated_files = []
|
21
|
-
|
22
|
-
if go_mod && file_changed?(go_mod)
|
23
|
-
updated_files <<
|
24
|
-
updated_file(
|
25
|
-
file: go_mod,
|
26
|
-
content: file_updater.updated_go_mod_content
|
27
|
-
)
|
28
|
-
|
29
|
-
if go_sum && go_sum.content != file_updater.updated_go_sum_content
|
30
|
-
updated_files <<
|
31
|
-
updated_file(
|
32
|
-
file: go_sum,
|
33
|
-
content: file_updater.updated_go_sum_content
|
34
|
-
)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
raise "No files changed!" if updated_files.none?
|
39
|
-
|
40
|
-
updated_files
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def check_required_files
|
46
|
-
return if go_mod
|
47
|
-
|
48
|
-
raise "No go.mod!"
|
49
|
-
end
|
50
|
-
|
51
|
-
def go_mod
|
52
|
-
@go_mod ||= get_original_file("go.mod")
|
53
|
-
end
|
54
|
-
|
55
|
-
def go_sum
|
56
|
-
@go_sum ||= get_original_file("go.sum")
|
57
|
-
end
|
58
|
-
|
59
|
-
def file_updater
|
60
|
-
@file_updater ||=
|
61
|
-
Modules::GoModUpdater.new(
|
62
|
-
dependencies: dependencies,
|
63
|
-
go_mod: go_mod,
|
64
|
-
go_sum: go_sum,
|
65
|
-
credentials: credentials
|
66
|
-
)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dependabot/file_updaters/go/modules"
|
4
|
-
require "dependabot/utils/go/shared_helper"
|
5
|
-
|
6
|
-
module Dependabot
|
7
|
-
module FileUpdaters
|
8
|
-
module Go
|
9
|
-
class Modules
|
10
|
-
class GoModUpdater
|
11
|
-
def initialize(dependencies:, go_mod:, go_sum:, credentials:)
|
12
|
-
@dependencies = dependencies
|
13
|
-
@go_mod = go_mod
|
14
|
-
@go_sum = go_sum
|
15
|
-
@credentials = credentials
|
16
|
-
end
|
17
|
-
|
18
|
-
def updated_go_mod_content
|
19
|
-
@updated_go_mod_content ||=
|
20
|
-
SharedHelpers.in_a_temporary_directory do
|
21
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
22
|
-
File.write("go.mod", go_mod.content)
|
23
|
-
|
24
|
-
deps = dependencies.map do |dep|
|
25
|
-
{
|
26
|
-
name: dep.name,
|
27
|
-
version: "v" + dep.version.sub(/^v/i, ""),
|
28
|
-
indirect: dep.requirements.empty?
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
SharedHelpers.run_helper_subprocess(
|
33
|
-
command: Utils::Go::SharedHelper.path,
|
34
|
-
function: "updateDependencyFile",
|
35
|
-
args: { dependencies: deps }
|
36
|
-
)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def updated_go_sum_content
|
42
|
-
return nil unless go_sum
|
43
|
-
|
44
|
-
# This needs to be run separately so we don't nest subprocess calls
|
45
|
-
updated_go_mod_content
|
46
|
-
|
47
|
-
@updated_go_sum_content ||=
|
48
|
-
SharedHelpers.in_a_temporary_directory do
|
49
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
50
|
-
File.write("go.mod", updated_go_mod_content)
|
51
|
-
File.write("go.sum", go_sum.content)
|
52
|
-
File.write("main.go", dummy_main_go)
|
53
|
-
|
54
|
-
`GO111MODULE=on go get -d`
|
55
|
-
unless $CHILD_STATUS.success?
|
56
|
-
raise Dependabot::DependencyFileNotParseable, go_sum.path
|
57
|
-
end
|
58
|
-
|
59
|
-
File.read("go.sum")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def dummy_main_go
|
67
|
-
lines = ["package main", "import ("]
|
68
|
-
dependencies.each do |dep|
|
69
|
-
lines << "_ \"#{dep.name}\""
|
70
|
-
end
|
71
|
-
lines << ")"
|
72
|
-
lines << "func main() {}"
|
73
|
-
lines.join("\n")
|
74
|
-
end
|
75
|
-
|
76
|
-
attr_reader :dependencies, :go_mod, :go_sum, :credentials
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "toml-rb"
|
4
|
-
require "dependabot/update_checkers/base"
|
5
|
-
require "dependabot/shared_helpers"
|
6
|
-
require "dependabot/errors"
|
7
|
-
require "dependabot/utils/go/version"
|
8
|
-
require "dependabot/utils/go/shared_helper"
|
9
|
-
|
10
|
-
module Dependabot
|
11
|
-
module UpdateCheckers
|
12
|
-
module Go
|
13
|
-
class Modules < Dependabot::UpdateCheckers::Base
|
14
|
-
def latest_resolvable_version
|
15
|
-
@latest_resolvable_version ||=
|
16
|
-
version_class.new(find_latest_resolvable_version.gsub(/^v/, ""))
|
17
|
-
end
|
18
|
-
|
19
|
-
# This is currently used to short-circuit latest_resolvable_version,
|
20
|
-
# with the assumption that it'll be quicker than checking
|
21
|
-
# resolvability. As this is quite quick in Go anyway, we just alias.
|
22
|
-
def latest_version
|
23
|
-
latest_resolvable_version
|
24
|
-
end
|
25
|
-
|
26
|
-
def latest_resolvable_version_with_no_unlock
|
27
|
-
# Irrelevant, since Go modules uses a single dependency file
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
|
31
|
-
def updated_requirements
|
32
|
-
dependency.requirements.map do |req|
|
33
|
-
req.merge(requirement: latest_version)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def find_latest_resolvable_version
|
40
|
-
SharedHelpers.in_a_temporary_directory do
|
41
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
42
|
-
File.write("go.mod", go_mod.content)
|
43
|
-
|
44
|
-
SharedHelpers.run_helper_subprocess(
|
45
|
-
command: "GO111MODULE=on #{Utils::Go::SharedHelper.path}",
|
46
|
-
function: "getUpdatedVersion",
|
47
|
-
args: {
|
48
|
-
dependency: {
|
49
|
-
name: dependency.name,
|
50
|
-
version: "v" + dependency.version,
|
51
|
-
indirect: dependency.requirements.empty?
|
52
|
-
}
|
53
|
-
}
|
54
|
-
)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def latest_version_resolvable_with_full_unlock?
|
60
|
-
# Full unlock checks aren't implemented for Go (yet)
|
61
|
-
false
|
62
|
-
end
|
63
|
-
|
64
|
-
def updated_dependencies_after_full_unlock
|
65
|
-
raise NotImplementedError
|
66
|
-
end
|
67
|
-
|
68
|
-
# Override the base class's check for whether this is a git dependency,
|
69
|
-
# since not all dep git dependencies have a SHA version (sometimes their
|
70
|
-
# version is the tag)
|
71
|
-
def existing_version_is_sha?
|
72
|
-
git_dependency?
|
73
|
-
end
|
74
|
-
|
75
|
-
def library?
|
76
|
-
dependency_files.none? { |f| f.type == "package_main" }
|
77
|
-
end
|
78
|
-
|
79
|
-
def version_from_tag(tag)
|
80
|
-
# To compare with the current version we either use the commit SHA
|
81
|
-
# (if that's what the parser picked up) of the tag name.
|
82
|
-
if dependency.version&.match?(/^[0-9a-f]{40}$/)
|
83
|
-
return tag&.fetch(:commit_sha)
|
84
|
-
end
|
85
|
-
|
86
|
-
tag&.fetch(:tag)
|
87
|
-
end
|
88
|
-
|
89
|
-
def git_dependency?
|
90
|
-
git_commit_checker.git_dependency?
|
91
|
-
end
|
92
|
-
|
93
|
-
def default_source
|
94
|
-
{ type: "default", source: dependency.name }
|
95
|
-
end
|
96
|
-
|
97
|
-
def go_mod
|
98
|
-
@go_mod ||= dependency_files.find { |f| f.name == "go.mod" }
|
99
|
-
end
|
100
|
-
|
101
|
-
def git_commit_checker
|
102
|
-
@git_commit_checker ||=
|
103
|
-
GitCommitChecker.new(
|
104
|
-
dependency: dependency,
|
105
|
-
credentials: credentials,
|
106
|
-
ignored_versions: ignored_versions
|
107
|
-
)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|