spektr 1.0.1 → 1.0.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: 8a830f6b6b9be5ac380e1cbf4a755b9171b77f9835d9e3f62c5f62c411ba529e
4
- data.tar.gz: 97a48a8cdaf9d5ab568dcc7d201daf1433b07c1a6043901c300147185ef99dec
3
+ metadata.gz: e3ad6c1899df739d3af4a37a6e4494b6fc5daed76a1004130182e89222ce1c46
4
+ data.tar.gz: f4fb6570bfc3da7bb3c762ac5d2cc6278606410e7731489a287aea968a4bd5b8
5
5
  SHA512:
6
- metadata.gz: 162e450e6584062cf616d010401090d8e367041042aca79b3b1a6268948e3a99185bbe08ee4fa1928a13a3a45b9cdd5a05f165a282c4abec47f52e23c059b363
7
- data.tar.gz: d61db3f6438d1ddcd64564815096beb67007539a543c90a0768423d41ede3bf571ea8acd7d167339ee4dde5074677d49719d0fb14fcebabe9fe9d22bc30b2ac9
6
+ metadata.gz: 32f425fb5c3d6c856f852936f5e138f1e9bff68984bcc681a4fe49a80099d3b8401f965b89d4ba64e69e5d92838f0543e9b80a5ce7bd96eea8cb3605a2e654d7
7
+ data.tar.gz: ac96dc9367cf88ea33b9994428ab3c089d70cd090b3d894e00d27c4cccae110ae79b0cca901b2e0eb1b37df67c46e97e5305df64fb4332c56d245959fe0610b8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.2
6
+
7
+ * Remove an accidental `byebug` require that caused scans to fail when development dependencies were not installed
8
+ * Avoid false-positive XSS findings for route helpers in block-form `link_to` calls
9
+ * Preserve dots in reported paths and stable warning fingerprints when scanning with `.` as the root
10
+ * Require `tty-table` 0.10 or newer
11
+
5
12
  ## 1.0.1
6
13
 
7
14
  * various nil handling fixes
@@ -27,7 +27,7 @@ module Spektr
27
27
 
28
28
  def warn!(target, check, location, message, confidence = :high)
29
29
  full_path = target.is_a?(String) ? target : target.path
30
- path = full_path.gsub(@app.root, "")
30
+ path = full_path.delete_prefix(@app.root)
31
31
  return if target.respond_to?(:ignored_at?) && target.ignored_at?(location&.start_line, check)
32
32
  return if dupe?(path, location, message)
33
33
 
@@ -1,6 +1,10 @@
1
1
  module Spektr
2
2
  class Checks
3
3
  class LinkToHref < Base
4
+ # Route helpers build the href themselves and escape any interpolated
5
+ # values, so user input reaching one is not an XSS sink.
6
+ ROUTE_HELPER = /_url$|_path$/
7
+
4
8
  def initialize(app, target)
5
9
  super
6
10
  @name = "XSS in href param of link_to"
@@ -14,9 +18,11 @@ module Spektr
14
18
  block_locations = []
15
19
  @target.find_calls_with_block(:link_to).each do |call|
16
20
  block_locations << call.location
17
- next unless call.arguments.arguments.first
18
- ::Spektr.logger.debug "#{@target.path} #{call.location.start_line} #{call.arguments.arguments.first.inspect}"
19
- if user_input? call.arguments.arguments.first
21
+ href = call.arguments.arguments.first
22
+ next unless href
23
+ ::Spektr.logger.debug "#{@target.path} #{call.location.start_line} #{href.inspect}"
24
+ next if route_helper?(href)
25
+ if user_input? href
20
26
  warn! @target, self, call.location, "Cross-Site Scripting: Unsafe user supplied value in link_to"
21
27
  end
22
28
  end
@@ -24,18 +30,21 @@ module Spektr
24
30
  @target.find_calls(:link_to).each do |call|
25
31
  next if block_locations.include? call.location
26
32
  next unless call.arguments
27
- ::Spektr.logger.debug "#{@target.path} #{call.location.start_line} #{call.arguments.arguments[1].inspect}"
28
- next unless call.arguments.arguments[1]
29
- require 'byebug'
30
- if call.arguments.arguments[1] && call.arguments.arguments[1].respond_to?(:name)
31
- name = call.arguments.arguments[1].name
32
- end
33
- next if name && name =~ /_url$|_path$/
34
- if user_input? call.arguments.arguments[1]
33
+ href = call.arguments.arguments[1]
34
+ ::Spektr.logger.debug "#{@target.path} #{call.location.start_line} #{href.inspect}"
35
+ next unless href
36
+ next if route_helper?(href)
37
+ if user_input? href
35
38
  warn! @target, self, call.location, "Cross-Site Scripting: Unsafe user supplied value in link_to"
36
39
  end
37
40
  end
38
41
  end
42
+
43
+ private
44
+
45
+ def route_helper?(node)
46
+ node.respond_to?(:name) && node.name.to_s =~ ROUTE_HELPER
47
+ end
39
48
  end
40
49
  end
41
50
  end
@@ -1,3 +1,3 @@
1
1
  module Spektr
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
data/spektr.gemspec CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency 'tty-color'
37
37
  spec.add_dependency 'tty-option'
38
38
  spec.add_dependency 'tty-spinner'
39
- spec.add_dependency 'tty-table'
39
+ spec.add_dependency 'tty-table', '>= 0.10'
40
40
  spec.add_dependency 'zeitwerk', '>= 2.6'
41
41
 
42
42
  spec.add_development_dependency 'byebug'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spektr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Molnar
@@ -141,14 +141,14 @@ dependencies:
141
141
  requirements:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
- version: '0'
144
+ version: '0.10'
145
145
  type: :runtime
146
146
  prerelease: false
147
147
  version_requirements: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: '0'
151
+ version: '0.10'
152
152
  - !ruby/object:Gem::Dependency
153
153
  name: zeitwerk
154
154
  requirement: !ruby/object:Gem::Requirement