roku_builder 4.25.6 → 4.26.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roku_builder/plugins/analyzer.rb +14 -9
- data/lib/roku_builder/plugins/line_inspector.rb +27 -6
- data/lib/roku_builder/plugins/loader.rb +6 -4
- data/lib/roku_builder/plugins/sca-cmd/bin/sca-cmd +1 -1
- data/lib/roku_builder/plugins/sca-cmd/bin/sca-cmd.bat +1 -1
- data/lib/roku_builder/plugins/sca-cmd/lib/sca-cmd.jar +0 -0
- data/lib/roku_builder/version.rb +1 -1
- data/test/roku_builder/plugins/test_analyzer.rb +19 -0
- data/test/roku_builder/plugins/test_loader.rb +1 -1
- data/test/roku_builder/test_files/analyzer_test/dont_use_hello_world.json +11 -0
- data/test/roku_builder/test_files/analyzer_test/linter_positive_match.json +13 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f9b82cc8cd8d2da493f330d4b41d35eb26a1efb89a3e5546e427a9c1381cb36
|
4
|
+
data.tar.gz: 66cc47ae8975cb4dcfc5271d2d1cdb12e5813c37297679e96e64bedb64707108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41712b6228bf1fca02ededce8d0baee62cdec83ec8c0d39abbd4a6e187c496d62d723e67a1918cea8a01b55b15f0e16f295dfae0a725783d68c052cb37b34a02
|
7
|
+
data.tar.gz: 803f81014a8319163a9b95445f5902a4b027299194f8df53cda8fb6d52bfd4a770601f305c6b9ee277d4498c993975cce05cdbe1132151c09d748ec84a661a84
|
@@ -40,7 +40,7 @@ module RokuBuilder
|
|
40
40
|
loader = Loader.new(config: @config)
|
41
41
|
Dir.mktmpdir do |dir|
|
42
42
|
loader.copy(options: options, path: dir)
|
43
|
-
run_sca_tool(path: dir,
|
43
|
+
run_sca_tool(path: dir, linter_config: linter_config)
|
44
44
|
libraries = @config.project[:libraries]
|
45
45
|
libraries ||= []
|
46
46
|
Dir.glob(File.join(dir, "**", "*")).each do |file_path|
|
@@ -63,7 +63,7 @@ module RokuBuilder
|
|
63
63
|
|
64
64
|
private
|
65
65
|
|
66
|
-
def run_sca_tool(path:,
|
66
|
+
def run_sca_tool(path:, linter_config:)
|
67
67
|
if OS.unix?
|
68
68
|
command = File.join(File.dirname(__FILE__), "sca-cmd", "bin", "sca-cmd")
|
69
69
|
stderr = "/dev/null"
|
@@ -73,20 +73,20 @@ module RokuBuilder
|
|
73
73
|
end
|
74
74
|
@logger.debug("Command: '#{command}'")
|
75
75
|
results = `#{command} #{path} 2>#{stderr}`.split("\n")
|
76
|
-
process_sca_results(results,
|
76
|
+
process_sca_results(results, linter_config)
|
77
77
|
end
|
78
78
|
|
79
|
-
def process_sca_results(results,
|
79
|
+
def process_sca_results(results, linter_config)
|
80
80
|
results.each do |result_line|
|
81
81
|
if /-----+/.match(result_line) or /\*\*\*\*\*+/.match(result_line)
|
82
|
-
@warnings.push(@sca_warning) if add_warning?(
|
82
|
+
@warnings.push(@sca_warning) if add_warning?(linter_config)
|
83
83
|
@sca_warning = {}
|
84
84
|
elsif data = /^(\[WARNING\]|\[INFO\]|\[ERROR\])(.*)$/.match(result_line)
|
85
|
-
@warnings.push(@sca_warning) if add_warning?(
|
85
|
+
@warnings.push(@sca_warning) if add_warning?(linter_config)
|
86
86
|
@sca_warning = {}
|
87
87
|
@sca_warning[:severity] = data[1].gsub(/(\[|\])/, "").downcase
|
88
88
|
@sca_warning[:message] = data[2]
|
89
|
-
elsif data = /^\
|
89
|
+
elsif data = /^\s*Path: ([^ ]*) Line: (\d*)./.match(result_line)
|
90
90
|
@sca_warning[:path] = data[1]+":"+data[2]
|
91
91
|
elsif @sca_warning and @sca_warning[:message]
|
92
92
|
@sca_warning[:message] += " " + result_line
|
@@ -94,9 +94,9 @@ module RokuBuilder
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
def add_warning?(
|
97
|
+
def add_warning?(linter_config)
|
98
98
|
if @sca_warning and @sca_warning[:severity]
|
99
|
-
if ssai and /SetAdUrl\(\) method is missing/.match(@sca_warning[:message])
|
99
|
+
if linter_config[:ssai] and /SetAdUrl\(\) method is missing/.match(@sca_warning[:message])
|
100
100
|
return false
|
101
101
|
end
|
102
102
|
libraries = @config.project[:libraries]
|
@@ -104,6 +104,11 @@ module RokuBuilder
|
|
104
104
|
if @sca_warning[:path] and libraries.any_is_start?(@sca_warning[:path].gsub(/pkg:/, "")) and not @options[:include_libraries]
|
105
105
|
return false
|
106
106
|
end
|
107
|
+
if linter_config[:ignore_warnings]
|
108
|
+
linter_config[:ignore_warnings].each do |regexp|
|
109
|
+
return false if @sca_warning[:message] =~ /#{regexp}/
|
110
|
+
end
|
111
|
+
end
|
107
112
|
return true
|
108
113
|
end
|
109
114
|
return false
|
@@ -47,17 +47,38 @@ module RokuBuilder
|
|
47
47
|
match = nil
|
48
48
|
start = 0
|
49
49
|
loop do
|
50
|
+
stop = to_check.length-1
|
51
|
+
pass_match = nil
|
52
|
+
if line_inspector[:pass_if_match]
|
53
|
+
if line_inspector[:case_sensitive]
|
54
|
+
pass_match = /#{line_inspector[:pass_test_regexp]}/.match(to_check[start..stop])
|
55
|
+
else
|
56
|
+
pass_match = /#{line_inspector[:pass_test_regexp]}/i.match(to_check[start..stop])
|
57
|
+
end
|
58
|
+
break unless pass_match
|
59
|
+
stop = to_check.index("\n", start)
|
60
|
+
stop ||= to_check.length-1
|
61
|
+
end
|
50
62
|
if line_inspector[:case_sensitive]
|
51
|
-
match = /#{line_inspector[:regex]}/.match(to_check
|
63
|
+
match = /#{line_inspector[:regex]}/.match(to_check[start..stop])
|
52
64
|
else
|
53
|
-
match = /#{line_inspector[:regex]}/i.match(to_check
|
65
|
+
match = /#{line_inspector[:regex]}/i.match(to_check[start..stop])
|
54
66
|
end
|
55
|
-
if match
|
56
|
-
|
57
|
-
|
67
|
+
if (not line_inspector[:pass_if_match] and match) or (line_inspector[:pass_if_match] and not match)
|
68
|
+
error_match = match
|
69
|
+
if match
|
70
|
+
line_number = to_check[0..match.begin(0)+start].split("\n", -1).count - 1
|
71
|
+
start = match.end(0) + start
|
72
|
+
else
|
73
|
+
error_match = pass_match
|
74
|
+
line_number = to_check[0..start].split("\n", -1).count - 1
|
75
|
+
start = stop
|
76
|
+
end
|
58
77
|
unless lines_to_ignore.include?(line_number)
|
59
|
-
add_warning(inspector: line_inspector, file: file_path, line: line_number, match:
|
78
|
+
add_warning(inspector: line_inspector, file: file_path, line: line_number, match: error_match)
|
60
79
|
end
|
80
|
+
elsif line_inspector[:pass_if_match]
|
81
|
+
start = stop +1
|
61
82
|
else
|
62
83
|
break
|
63
84
|
end
|
@@ -103,7 +103,7 @@ module RokuBuilder
|
|
103
103
|
multipart_connection(device: device) do |conn|
|
104
104
|
response = conn.post "/plugin_install", payload
|
105
105
|
end
|
106
|
-
unless response.status == 200 and response.body =~ /
|
106
|
+
unless response.status == 200 and response.body =~ /squashfs file in internal memory/ or ignoreFailure
|
107
107
|
raise ExecutionError, "Failed Converting to Squashfs"
|
108
108
|
end
|
109
109
|
end
|
@@ -160,11 +160,13 @@ module RokuBuilder
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def build_zip(content)
|
163
|
-
|
164
|
-
File.
|
165
|
-
io = Zip::File.open(path, Zip::File::CREATE)
|
163
|
+
tmp_path = File.join(build_dir, SecureRandom.uuid+".zip")
|
164
|
+
io = Zip::File.open(tmp_path, Zip::File::CREATE)
|
166
165
|
writeEntries(build_dir, content[:source_files], "", content[:excludes], io)
|
167
166
|
io.close()
|
167
|
+
path = file_path(:out)
|
168
|
+
File.delete(path) if File.exist?(path)
|
169
|
+
FileUtils.mv(tmp_path, path)
|
168
170
|
end
|
169
171
|
|
170
172
|
# Recursively write directory contents to a zip archive
|
@@ -114,7 +114,7 @@ case "$( uname )" in #(
|
|
114
114
|
NONSTOP* ) nonstop=true ;;
|
115
115
|
esac
|
116
116
|
|
117
|
-
CLASSPATH=$APP_HOME/lib/sca-cmd.jar:$APP_HOME/lib/sca-library.jar:$APP_HOME/lib/utils-
|
117
|
+
CLASSPATH=$APP_HOME/lib/sca-cmd.jar:$APP_HOME/lib/sca-library.jar:$APP_HOME/lib/utils-4.0.0.jar:$APP_HOME/lib/configuration-4.0.0.jar:$APP_HOME/lib/compress-4.0.0.jar:$APP_HOME/lib/io-4.0.0.jar:$APP_HOME/lib/imaging-4.0.0.jar:$APP_HOME/lib/manifest-4.0.0.jar:$APP_HOME/lib/commons-cli-1.5.0.jar:$APP_HOME/lib/jackson-databind-2.13.3.jar:$APP_HOME/lib/jackson-core-2.13.3.jar:$APP_HOME/lib/jackson-annotations-2.13.3.jar:$APP_HOME/lib/jackson-dataformat-xml-2.13.3.jar:$APP_HOME/lib/commons-lang3-3.12.0.jar:$APP_HOME/lib/woodstox-core-6.2.7.jar:$APP_HOME/lib/stax2-api-4.2.1.jar:$APP_HOME/lib/commons-compress-1.21.jar:$APP_HOME/lib/commons-io-2.11.0.jar
|
118
118
|
|
119
119
|
|
120
120
|
# Determine the Java command to use to start the JVM.
|
@@ -67,7 +67,7 @@ goto fail
|
|
67
67
|
:execute
|
68
68
|
@rem Setup the command line
|
69
69
|
|
70
|
-
set CLASSPATH=%APP_HOME%\lib\sca-cmd.jar;%APP_HOME%\lib\sca-library.jar;%APP_HOME%\lib\utils-
|
70
|
+
set CLASSPATH=%APP_HOME%\lib\sca-cmd.jar;%APP_HOME%\lib\sca-library.jar;%APP_HOME%\lib\utils-4.0.0.jar;%APP_HOME%\lib\configuration-4.0.0.jar;%APP_HOME%\lib\compress-4.0.0.jar;%APP_HOME%\lib\io-4.0.0.jar;%APP_HOME%\lib\imaging-4.0.0.jar;%APP_HOME%\lib\manifest-4.0.0.jar;%APP_HOME%\lib\commons-cli-1.5.0.jar;%APP_HOME%\lib\jackson-databind-2.13.3.jar;%APP_HOME%\lib\jackson-core-2.13.3.jar;%APP_HOME%\lib\jackson-annotations-2.13.3.jar;%APP_HOME%\lib\jackson-dataformat-xml-2.13.3.jar;%APP_HOME%\lib\commons-lang3-3.12.0.jar;%APP_HOME%\lib\woodstox-core-6.2.7.jar;%APP_HOME%\lib\stax2-api-4.2.1.jar;%APP_HOME%\lib\commons-compress-1.21.jar;%APP_HOME%\lib\commons-io-2.11.0.jar
|
71
71
|
|
72
72
|
|
73
73
|
@rem Execute sca-cmd
|
Binary file
|
data/lib/roku_builder/version.rb
CHANGED
@@ -26,6 +26,8 @@ module RokuBuilder
|
|
26
26
|
def teardown
|
27
27
|
manifest = File.join(@root_dir, "manifest")
|
28
28
|
FileUtils.rm(manifest) if File.exist?(manifest)
|
29
|
+
linter_config = File.join(@root_dir, ".roku_builder_linter.json")
|
30
|
+
FileUtils.rm(linter_config) if File.exist?(linter_config)
|
29
31
|
@request_stubs.each {|req| remove_request_stub(req)}
|
30
32
|
end
|
31
33
|
def test_analyzer_parse_commands
|
@@ -100,10 +102,27 @@ module RokuBuilder
|
|
100
102
|
warnings = test_file(text: "For each button in buttons\n ? button\nEND FOR")
|
101
103
|
assert_equal 0, warnings.count
|
102
104
|
end
|
105
|
+
def test_linter_checks
|
106
|
+
set_linter_config("dont_use_hello_world.json")
|
107
|
+
warnings = test_file(text: "hello world")
|
108
|
+
assert_equal 1, warnings.count
|
109
|
+
end
|
110
|
+
def test_linter_positive_match
|
111
|
+
set_linter_config("linter_positive_match.json")
|
112
|
+
warnings = test_file(text: "hello world\nhello moon")
|
113
|
+
assert_equal 1, warnings.count
|
114
|
+
assert_equal 1, warnings.first[:line]
|
115
|
+
end
|
103
116
|
|
104
117
|
|
105
118
|
private
|
106
119
|
|
120
|
+
def set_linter_config(config_file = nil)
|
121
|
+
if config_file
|
122
|
+
FileUtils.cp(File.join(@root_dir, config_file), File.join(@root_dir, ".roku_builder_linter.json"))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
107
126
|
def test_manifest(manifest_file = nil)
|
108
127
|
if manifest_file
|
109
128
|
use_manifest(manifest_file)
|
@@ -136,7 +136,7 @@ module RokuBuilder
|
|
136
136
|
end
|
137
137
|
def test_loader_squash
|
138
138
|
@request_stubs.push(stub_request(:post, "http://#{@device_config[:ip]}/plugin_install").
|
139
|
-
to_return(status: 200, body: "
|
139
|
+
to_return(status: 200, body: "squashfs file in internal memory", headers: {}))
|
140
140
|
@device_manager.expect(:reserve_device, @device, no_lock: false)
|
141
141
|
@device_manager.expect(:release_device, nil, [@device])
|
142
142
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roku_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.26.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- greeneca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -543,6 +543,7 @@ files:
|
|
543
543
|
- test/roku_builder/test_config_validator.rb
|
544
544
|
- test/roku_builder/test_device_manager.rb
|
545
545
|
- test/roku_builder/test_files/analyzer_test/analyzer_config.json
|
546
|
+
- test/roku_builder/test_files/analyzer_test/dont_use_hello_world.json
|
546
547
|
- test/roku_builder/test_files/analyzer_test/images/focus.png
|
547
548
|
- test/roku_builder/test_files/analyzer_test/images/focus_hd.png
|
548
549
|
- test/roku_builder/test_files/analyzer_test/images/focus_sd.png
|
@@ -550,6 +551,7 @@ files:
|
|
550
551
|
- test/roku_builder/test_files/analyzer_test/images/splash_hd.png
|
551
552
|
- test/roku_builder/test_files/analyzer_test/images/splash_sd.png
|
552
553
|
- test/roku_builder/test_files/analyzer_test/images/too_small.png
|
554
|
+
- test/roku_builder/test_files/analyzer_test/linter_positive_match.json
|
553
555
|
- test/roku_builder/test_files/analyzer_test/manifest_depricated_attribute
|
554
556
|
- test/roku_builder/test_files/analyzer_test/manifest_duplicate_attribute
|
555
557
|
- test/roku_builder/test_files/analyzer_test/manifest_empty_value
|
@@ -672,6 +674,7 @@ test_files:
|
|
672
674
|
- test/roku_builder/test_config_validator.rb
|
673
675
|
- test/roku_builder/test_device_manager.rb
|
674
676
|
- test/roku_builder/test_files/analyzer_test/analyzer_config.json
|
677
|
+
- test/roku_builder/test_files/analyzer_test/dont_use_hello_world.json
|
675
678
|
- test/roku_builder/test_files/analyzer_test/images/focus.png
|
676
679
|
- test/roku_builder/test_files/analyzer_test/images/focus_hd.png
|
677
680
|
- test/roku_builder/test_files/analyzer_test/images/focus_sd.png
|
@@ -679,6 +682,7 @@ test_files:
|
|
679
682
|
- test/roku_builder/test_files/analyzer_test/images/splash_hd.png
|
680
683
|
- test/roku_builder/test_files/analyzer_test/images/splash_sd.png
|
681
684
|
- test/roku_builder/test_files/analyzer_test/images/too_small.png
|
685
|
+
- test/roku_builder/test_files/analyzer_test/linter_positive_match.json
|
682
686
|
- test/roku_builder/test_files/analyzer_test/manifest_depricated_attribute
|
683
687
|
- test/roku_builder/test_files/analyzer_test/manifest_duplicate_attribute
|
684
688
|
- test/roku_builder/test_files/analyzer_test/manifest_empty_value
|