rails-guarddog 0.1.6 → 0.1.8

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: 7dea85a7698050fcc823251f4acc49373742804ae43daadc1c4a378f9ce04b01
4
- data.tar.gz: 35f0fdca94c23a451631ab027711b10fae077aefe4d4653f70a432a45089d465
3
+ metadata.gz: 2214ac72da2f5e00107d39f0a22a48279d260fdc7d8c29ac20db5cf392436e8a
4
+ data.tar.gz: 286b44e6837ea09fcd2225b7078cb97e7dcd5cd84a41fc6effec47a279508eee
5
5
  SHA512:
6
- metadata.gz: 40b498fc485ed0217c8e96c3214ae8c74c9dd748cca4907956242ebd65d55366fb978e9fb926b28255bd2d7231982e226d3d3985bf7e28fbe65fee5bbd578c3a
7
- data.tar.gz: 2ada4498720b9dbdd6e2e11d664e8a68da5a136026570a647df717734c2c5d05d448d11c45e6ac96e1b801a1fb8d1cb2eee4b5f54bb644b8ec2c512701d82018
6
+ metadata.gz: f3e990671a743b74bc4e27debe6b20555f69680859f61afda97fd1908e1dcc4138920a7a54a55e04aba3beca88819b9e2a682506e02b5541939b537c9a8c6aad
7
+ data.tar.gz: b18391be117c2be514e7d00f32cf8d90407c1aa12201718fb4ec4572845cf910620ae71fd14f8005d5e4f404e6dd5077d5028dbc205c30dd944fb0cdaafd5928
@@ -1,26 +1,44 @@
1
- module Rails
2
- module Guarddog
3
- module Checkers
4
- class XssChecker < BaseChecker
5
- def run
6
- glob_files('app/views/**/*.erb').each do |file|
7
- content = File.read(file)
8
- content.each_line.with_index do |line, idx|
9
- if line.include?('<%=') && (line.include?('params') || line.include?('@')) && !line.include?('sanitize') && !line.include?('h(')
10
- add_finding(
11
- severity: :high,
12
- message: "Potential XSS vulnerability: unsanitized user input in view",
13
- file: file,
14
- line: idx + 1,
15
- snippet: line.strip,
16
- remediation: "Use <%= h() %> or sanitize() helper"
17
- )
18
- end
19
- end
20
- end
21
- findings
22
- end
23
- end
24
- end
25
- end
26
- end
1
+ module Rails
2
+ module Guarddog
3
+ module Checkers
4
+ class XssChecker < BaseChecker
5
+ def run
6
+ glob_files('app/views/**/*.erb').each do |file|
7
+ content = File.read(file)
8
+ content.each_line.with_index do |line, idx|
9
+ if xss_vulnerable?(line)
10
+ add_finding(
11
+ severity: :high,
12
+ message: "Potential XSS vulnerability: unescaped output detected",
13
+ file: file,
14
+ line: idx + 1,
15
+ snippet: line.strip,
16
+ remediation: "Use <%= h() %> or sanitize() instead of raw/html_safe"
17
+ )
18
+ end
19
+ end
20
+ end
21
+ findings
22
+ end
23
+
24
+ private
25
+
26
+ def xss_vulnerable?(line)
27
+ # <%== is Rails' raw output (alias for raw())
28
+ return true if line.match?(/<%==/)
29
+
30
+ # raw() helper explicitly disables escaping
31
+ return true if line.match?(/<%=.*\braw\s*\(/)
32
+
33
+ # .html_safe bypasses escaping
34
+ return true if line.match?(/<%=.*\.html_safe/)
35
+
36
+ # concat with raw content
37
+ return true if line.match?(/<%=.*content_tag.*html_safe/)
38
+
39
+ false
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Guarddog
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-guarddog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Security Team
@@ -88,7 +88,7 @@ files:
88
88
  - lib/rails/guarddog/scanner.rb
89
89
  - lib/rails/guarddog/version.rb
90
90
  - lib/tasks/guarddog.rake
91
- homepage: https://github.com/example/rails-guarddog
91
+ homepage: https://github.com/sghani001/rails-guarddog
92
92
  licenses:
93
93
  - MIT
94
94
  metadata: {}