paraxial 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa19e78278421371d0e25cd1e387383676df44a7d09ec936520e6e2e9a4fa70f
4
- data.tar.gz: 807b6b4401164502c8b38ea4b6ff861c667b0aee5fcd124d68a5f98c19ed5e38
3
+ metadata.gz: ae07951f0f8acaa36743cf6262075828235520ddc3ffb2ff7f4a29643ddd6e1d
4
+ data.tar.gz: a865ff890ed5e9a802b9462e236a8efaa4b494d5b5973cf13720446c76174444
5
5
  SHA512:
6
- metadata.gz: f99fc3adc1dab0e302e45b26b2a245055b2b03eac517e5640b7f18828de1a78d64362a37811be9221b4f5c560feff727324b171d1c9493609b513de43579780a
7
- data.tar.gz: fbe25d2549601ab95b67934deda8dd1e070d7ced5cb0abf570f85b8650acc9700d35c4274f3460a25d434a6f09c67ad80b85927564da3ba78a1b1dfa9b9ed2d0
6
+ metadata.gz: 4cfda9292ce733e777a2198b97e30443a68d8348dd822ff60f680da43af6b47aa18c2318bcf01565689ba8961bc695a71fccf31814a46092c256f52ce7893810
7
+ data.tar.gz: e10ef61a321f57660a35d706cdab3b000852c68ca66c89299fe54a95daa785e008446ffa06d9ede8bca8a7ed6bd9e1a9e7c6e11ddaa78f79a8d25b5539edd48b
data/lib/paraxial/cli.rb CHANGED
@@ -18,6 +18,15 @@ module Paraxial
18
18
 
19
19
  def scan
20
20
  puts '[Paraxial] Scan starting...'
21
+ if check_rubocop_configuration
22
+ puts '[Paraxial] .rubocop.yml is valid.'
23
+ else
24
+ puts '[Paraxial] .rubocop.yml is missing rubocop-erb. To scan embedded Ruby files for security problems, add:'
25
+ puts '.rubocop.yml'
26
+ puts 'require:'
27
+ puts '- rubocop-erb'
28
+ end
29
+
21
30
 
22
31
  if Paraxial::Helpers.get_api_key.nil?
23
32
  puts '[Paraxial] Environment variable PARAXIAL_API_KEY not found'
@@ -40,7 +49,7 @@ module Paraxial
40
49
  m = JSON.parse(response.body)
41
50
  findings = m['ok']['findings']
42
51
  puts
43
- puts "[Paraxial] Scan count #{findings.length}"
52
+ puts "[Paraxial] Scan count: #{findings.length}"
44
53
  puts
45
54
  findings.each do |finding|
46
55
  puts finding
@@ -89,5 +98,21 @@ module Paraxial
89
98
  end
90
99
  end
91
100
 
101
+ private
102
+
103
+ def check_rubocop_configuration
104
+ rubocop_file = File.join(Dir.pwd, '.rubocop.yml')
105
+
106
+ return false unless File.exist?(rubocop_file)
107
+
108
+ config = YAML.load_file(rubocop_file)
109
+ required_key = 'require'
110
+
111
+ if config.is_a?(Hash) && config[required_key].is_a?(Array)
112
+ config[required_key].include?('rubocop-erb')
113
+ else
114
+ false
115
+ end
116
+ end
92
117
  end
93
118
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paraxial
4
- VERSION = '0.5.0'
4
+ VERSION = '0.7.0'
5
5
  end
data/lib/paraxial.rb CHANGED
@@ -8,6 +8,7 @@ require_relative 'rubocop/cop/paraxial/system'
8
8
  require_relative 'rubocop/cop/paraxial/send'
9
9
  require_relative 'rubocop/cop/paraxial/constantize'
10
10
  require_relative 'rubocop/cop/paraxial/html_safe'
11
+ require_relative 'rubocop/cop/paraxial/raw'
11
12
  require_relative 'rubocop/cop/paraxial/sql'
12
13
  require_relative 'paraxial/version'
13
14
  require_relative 'paraxial/cli'
@@ -2,7 +2,7 @@ module RuboCop
2
2
  module Cop
3
3
  module Paraxial
4
4
  class HTMLSafe < Base
5
- MSG = '`html_safe` leads to XSS when called on user input'
5
+ MSG = '`html_safe` leads to XSS when called on user input.'
6
6
 
7
7
  def on_send(node)
8
8
  method_name = node.method_name
@@ -0,0 +1,22 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Paraxial
4
+ class Raw < Base
5
+ MSG = '`raw` leads to XSS when called on user input.'
6
+
7
+ def on_send(node)
8
+ method_name = node.method_name
9
+ return unless send_methods.include?(method_name)
10
+
11
+ add_offense(node, message: format(MSG, method: method_name))
12
+ end
13
+
14
+ private
15
+
16
+ def send_methods
17
+ [:raw]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paraxial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lubas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-30 00:00:00.000000000 Z
11
+ date: 2024-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-erb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - michael@paraxial.io
@@ -90,6 +104,7 @@ files:
90
104
  - lib/rubocop/cop/paraxial/constantize.rb
91
105
  - lib/rubocop/cop/paraxial/csrf.rb
92
106
  - lib/rubocop/cop/paraxial/html_safe.rb
107
+ - lib/rubocop/cop/paraxial/raw.rb
93
108
  - lib/rubocop/cop/paraxial/send.rb
94
109
  - lib/rubocop/cop/paraxial/sql.rb
95
110
  - lib/rubocop/cop/paraxial/system.rb