roku_builder 4.25.6 → 4.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b926c96062054e546bb423d2031bc48446a3c716c2488c6756882a6218d22e2
4
- data.tar.gz: 6748df137a4374f34b2c91aebac0a4e1c77129753c835f86d1ac61c9b3999f9b
3
+ metadata.gz: 0f9b82cc8cd8d2da493f330d4b41d35eb26a1efb89a3e5546e427a9c1381cb36
4
+ data.tar.gz: 66cc47ae8975cb4dcfc5271d2d1cdb12e5813c37297679e96e64bedb64707108
5
5
  SHA512:
6
- metadata.gz: 42ff1860aded5097863dd4bd6b721d78f24e1e99888b365cb2a84dd98878c74599efc4be91c56d6b6f50b706d2eb3ce73bc75ab25ded7829a4a3325ece71a023
7
- data.tar.gz: 7b531741d6cab2f47739892edb54aeae709fe53fa44b18dcaa97a22dc112767bd323644289be3041eac1de56b12f002b562e06714a5d116b6c45510cdd1a62ce
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, ssai: linter_config[:is_ssai])
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:, ssai:)
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, ssai)
76
+ process_sca_results(results, linter_config)
77
77
  end
78
78
 
79
- def process_sca_results(results, ssai)
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?(ssai)
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?(ssai)
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 = /^\sPath: ([^ ]*) Line: (\d*)./.match(result_line)
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?(ssai)
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, start)
63
+ match = /#{line_inspector[:regex]}/.match(to_check[start..stop])
52
64
  else
53
- match = /#{line_inspector[:regex]}/i.match(to_check, start)
65
+ match = /#{line_inspector[:regex]}/i.match(to_check[start..stop])
54
66
  end
55
- if match
56
- start = match.end(0)
57
- line_number = to_check[0..match.begin(0)].split("\n", -1).count - 1
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: 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 =~ /Conversion succeeded/ or ignoreFailure
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
- path = file_path(:out)
164
- File.delete(path) if File.exist?(path)
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-2.3.0.jar:$APP_HOME/lib/configuration-2.0.0.jar:$APP_HOME/lib/compress-2.3.1.jar:$APP_HOME/lib/io-2.4.0.jar:$APP_HOME/lib/imaging-2.0.0.jar:$APP_HOME/lib/manifest-2.3.0.jar:$APP_HOME/lib/commons-cli-1.5.0.jar:$APP_HOME/lib/jackson-databind-2.13.1.jar:$APP_HOME/lib/jackson-core-2.13.1.jar:$APP_HOME/lib/jackson-annotations-2.13.1.jar:$APP_HOME/lib/jackson-dataformat-xml-2.13.1.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
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-2.3.0.jar;%APP_HOME%\lib\configuration-2.0.0.jar;%APP_HOME%\lib\compress-2.3.1.jar;%APP_HOME%\lib\io-2.4.0.jar;%APP_HOME%\lib\imaging-2.0.0.jar;%APP_HOME%\lib\manifest-2.3.0.jar;%APP_HOME%\lib\commons-cli-1.5.0.jar;%APP_HOME%\lib\jackson-databind-2.13.1.jar;%APP_HOME%\lib\jackson-core-2.13.1.jar;%APP_HOME%\lib\jackson-annotations-2.13.1.jar;%APP_HOME%\lib\jackson-dataformat-xml-2.13.1.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
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "4.25.6"
5
+ VERSION = "4.26.2"
6
6
  end
@@ -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: "Conversion succeeded", headers: {}))
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
 
@@ -0,0 +1,11 @@
1
+ {
2
+ "is_ssai": true,
3
+ "rules": [
4
+ {
5
+ "regex": "hello world",
6
+ "case_sensitive": true,
7
+ "severity": "warning",
8
+ "message": "dont use hello world"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "is_ssai": true,
3
+ "rules": [
4
+ {
5
+ "pass_if_match": true,
6
+ "pass_test_regexp": "hello",
7
+ "regex": "hello world",
8
+ "case_sensitive": true,
9
+ "severity": "warning",
10
+ "message": "only use hello world, no other hello"
11
+ }
12
+ ]
13
+ }
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.25.6
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-07-18 00:00:00.000000000 Z
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