pronto-golang 0.0.12 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +6 -6
- data/lib/pronto/golang/tools/base.rb +17 -1
- data/lib/pronto/golang/tools/golangci_lint.rb +4 -0
- data/lib/pronto/golang/tools/gosec.rb +10 -3
- data/lib/pronto/golang/version.rb +1 -1
- data/lib/pronto/golang.rb +69 -17
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd47b694962afba2ab2b70b52c243f9ee1f0deba76f55d9b9ece5f3ed0e1111b
|
4
|
+
data.tar.gz: ebe00aa8879c532f723948a50b75a8a9f99df36c78f1206361e86050cf82e597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d28c4bc9ea6c005cf662f33a3e018b9a87b38af0de82955687cd3f100c01084a8f59745dd83c509e91ee079273660f4f5af04adf1b87dc01434171ad45d3297
|
7
|
+
data.tar.gz: fae491dea1af02da0a056ceabf214a38a25c9f5b898adc5233c75734d9961779e2157bcb028bc21e3179de1f2f5a8baa9815b1551fd6f7fc2440f157f00a5d9a
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# Pronto runner for Golang
|
2
2
|
|
3
|
-
|
3
|
+
![Build Status](https://github.com/viafintech/pronto-golang/actions/workflows/test.yml/badge.svg) [![RubyDoc](https://img.shields.io/badge/ruby-doc-green.svg)](http://rubydoc.info/github/Barzahlen/pronto-golang)
|
4
4
|
|
5
|
-
Pronto runner for [Golang](https://
|
5
|
+
[Pronto](https://github.com/prontolabs/pronto) runner for [Golang](https://go.dev) tools
|
6
6
|
|
7
7
|
## Tools
|
8
8
|
|
9
9
|
| Tool | Install |
|
10
10
|
|----------|----------|
|
11
11
|
| go vet | - |
|
12
|
-
| golint | go
|
13
|
-
| gosec |
|
14
|
-
| staticcheck | go
|
15
|
-
| golangci-lint |
|
12
|
+
| golint | go install golang.org/x/lint/golint@latest |
|
13
|
+
| gosec | go install github.com/securego/gosec/v2/cmd/gosec@v2.14.0 |
|
14
|
+
| staticcheck | go install honnef.co/go/tools/cmd/staticcheck@latest |
|
15
|
+
| golangci-lint | See [Install instructions](https://golangci-lint.run/usage/install/) |
|
16
16
|
|
17
17
|
## Configuring tools
|
18
18
|
|
@@ -14,7 +14,11 @@ module Pronto
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def command(file_path)
|
17
|
-
"#{base_command} #{parameters} #{file_path}"
|
17
|
+
"cd #{directory} && #{base_command} #{parameters} #{file_path}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def directory(default = '.')
|
21
|
+
@config.fetch('execution_directory', default)
|
18
22
|
end
|
19
23
|
|
20
24
|
def parameters
|
@@ -37,9 +41,21 @@ module Pronto
|
|
37
41
|
@config.fetch('enabled', true) # Default to true if the key is not configured
|
38
42
|
end
|
39
43
|
|
44
|
+
# Supported options:
|
45
|
+
# - file
|
46
|
+
# - project
|
47
|
+
def execution_mode
|
48
|
+
'file'
|
49
|
+
end
|
50
|
+
|
40
51
|
def parse_line(line)
|
41
52
|
file_path, line_number, _, message = line.split(':', 4)
|
42
53
|
|
54
|
+
dir = directory('')
|
55
|
+
if dir != ''
|
56
|
+
file_path = File.join(dir, file_path)
|
57
|
+
end
|
58
|
+
|
43
59
|
return file_path, line_number, :warning, message.to_s.strip
|
44
60
|
end
|
45
61
|
end
|
@@ -5,6 +5,13 @@ require_relative '../errors'
|
|
5
5
|
module Pronto
|
6
6
|
module GolangTools
|
7
7
|
class Gosec < Base
|
8
|
+
|
9
|
+
# Accepts lines of the following format:
|
10
|
+
# [path_to_file:<line_number>] -
|
11
|
+
GOSEC_LINE_PATTERN = Regexp.new('^\[(\S+):(\d+)\] - (.+)')
|
12
|
+
|
13
|
+
ANSI_COLOR_CODING_PATTERN = Regexp.new('\e\[\d+(;\d+)?m')
|
14
|
+
|
8
15
|
def self.base_command
|
9
16
|
'gosec'
|
10
17
|
end
|
@@ -14,9 +21,9 @@ module Pronto
|
|
14
21
|
end
|
15
22
|
|
16
23
|
def parse_line(line)
|
17
|
-
|
18
|
-
|
19
|
-
if line
|
24
|
+
line = line.gsub(ANSI_COLOR_CODING_PATTERN, '')
|
25
|
+
|
26
|
+
if !GOSEC_LINE_PATTERN.match(line)
|
20
27
|
raise ::Pronto::GolangSupport::UnprocessableLine.new(line)
|
21
28
|
end
|
22
29
|
|
data/lib/pronto/golang.rb
CHANGED
@@ -17,9 +17,15 @@ module Pronto
|
|
17
17
|
def run
|
18
18
|
return [] unless @patches
|
19
19
|
|
20
|
-
@patches
|
21
|
-
|
22
|
-
|
20
|
+
valid_patches = @patches.select { |patch| valid_patch?(patch) }
|
21
|
+
patch_file_paths = valid_patches.map { |patch| patch_file_path(patch) }
|
22
|
+
|
23
|
+
collected_findings = []
|
24
|
+
collected_findings += run_tools_for_projects
|
25
|
+
collected_findings += run_tools_for_files(patch_file_paths)
|
26
|
+
|
27
|
+
valid_patches
|
28
|
+
.map { |patch| inspect(patch, collected_findings) }
|
23
29
|
.flatten
|
24
30
|
.compact
|
25
31
|
end
|
@@ -28,31 +34,77 @@ module Pronto
|
|
28
34
|
patch.additions > 0 && go_file?(patch.new_file_full_path)
|
29
35
|
end
|
30
36
|
|
31
|
-
def
|
32
|
-
|
37
|
+
def patch_file_path(patch)
|
38
|
+
return Shellwords.escape(patch.new_file_full_path.to_s)
|
39
|
+
end
|
33
40
|
|
34
|
-
|
41
|
+
def run_tools_for_projects
|
42
|
+
collected_findings = []
|
35
43
|
|
36
44
|
available_tools.each do |tool|
|
37
|
-
|
38
|
-
# Note: this defaults to '.*' and therefore matches everything by default
|
39
|
-
if tool.blacklisted_files_regexp.match?(escaped_path)
|
45
|
+
if tool.execution_mode != 'project'
|
40
46
|
next
|
41
47
|
end
|
42
48
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
collected_findings += run_command(tool, tool.command(''))
|
50
|
+
end
|
51
|
+
|
52
|
+
return collected_findings
|
53
|
+
end
|
54
|
+
|
55
|
+
def run_tools_for_files(filepaths)
|
56
|
+
collected_findings = []
|
47
57
|
|
48
|
-
|
49
|
-
|
58
|
+
available_tools.each do |tool|
|
59
|
+
if tool.execution_mode != 'file'
|
60
|
+
next
|
61
|
+
end
|
62
|
+
|
63
|
+
filepaths.each do |filepath|
|
64
|
+
# Skip the patch if the filepath is blacklisted in the 'blacklisted_files' config
|
65
|
+
# Note: this defaults to '.*' and therefore matches everything by default
|
66
|
+
if tool.blacklisted_files_regexp.match?(filepath)
|
67
|
+
next
|
50
68
|
end
|
51
69
|
|
52
|
-
|
53
|
-
|
70
|
+
collected_findings += run_command(tool, tool.command(filepath))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
return collected_findings
|
75
|
+
end
|
76
|
+
|
77
|
+
def run_command(tool, command)
|
78
|
+
collected_findings = []
|
79
|
+
|
80
|
+
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
81
|
+
[stdout, stderr].each do |result_text|
|
82
|
+
while output_line = result_text.gets
|
83
|
+
next if output_line.strip == 'exit status 1'
|
84
|
+
|
85
|
+
collected_findings << {
|
86
|
+
line: output_line,
|
87
|
+
tool: tool,
|
88
|
+
}
|
54
89
|
end
|
55
90
|
end
|
91
|
+
|
92
|
+
while output_line = stderr.gets
|
93
|
+
collected_findings << {
|
94
|
+
line: output_line,
|
95
|
+
tool: tool,
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
return collected_findings
|
101
|
+
end
|
102
|
+
|
103
|
+
def inspect(patch, findings)
|
104
|
+
messages = []
|
105
|
+
|
106
|
+
findings.each do |finding|
|
107
|
+
messages << process_line(patch, finding[:tool], finding[:line])
|
56
108
|
end
|
57
109
|
|
58
110
|
return messages
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto-golang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Schoknecht
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pronto
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 0.9.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.11.
|
22
|
+
version: 0.11.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,37 +29,37 @@ dependencies:
|
|
29
29
|
version: 0.9.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.11.
|
32
|
+
version: 0.11.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '13.0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '13.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '3.
|
53
|
+
version: '3.12'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '3.
|
61
|
-
description:
|
62
|
-
email: tobias.schoknecht@
|
60
|
+
version: '3.12'
|
61
|
+
description:
|
62
|
+
email: tobias.schoknecht@viafintech.com
|
63
63
|
executables: []
|
64
64
|
extensions: []
|
65
65
|
extra_rdoc_files:
|
@@ -79,11 +79,11 @@ files:
|
|
79
79
|
- lib/pronto/golang/tools/govet.rb
|
80
80
|
- lib/pronto/golang/tools/staticcheck.rb
|
81
81
|
- lib/pronto/golang/version.rb
|
82
|
-
homepage: https://github.com/
|
82
|
+
homepage: https://github.com/viafintech/pronto-golang
|
83
83
|
licenses:
|
84
84
|
- MIT
|
85
85
|
metadata: {}
|
86
|
-
post_install_message:
|
86
|
+
post_install_message:
|
87
87
|
rdoc_options: []
|
88
88
|
require_paths:
|
89
89
|
- lib
|
@@ -98,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
-
signing_key:
|
101
|
+
rubygems_version: 3.1.6
|
102
|
+
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Pronto runner for golang tools
|
105
105
|
test_files: []
|