rails-guarddog 0.1.12 → 0.1.13

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: 97cdcd83511d9b89a1786584d4a21dcf403123b3ea3911e7341a85a3bda88446
4
- data.tar.gz: e6634444d93c30e0ddf147cb51db25ee7f04f6f2ee9a17f09d9c1de7b59d7da0
3
+ metadata.gz: b5176cbe7acb78424e6f30a57cb8c203d5de27d9c2e12627034ee33a723c3095
4
+ data.tar.gz: 22408c90ed568ef535fced6db89e92a96c7b79aec37cc81631abb7a0a5393498
5
5
  SHA512:
6
- metadata.gz: c1e72af9e429215d30599e42276ced36f320f052002274827beb6b4060adfa29f907c42af0a88da4a13eead365ef84e32cbb079994534084112e60151671a09f
7
- data.tar.gz: 2af6a3569f894d95fc2e944ebe14bce13696bc89e0120f13aa5c3cdd9e305e44ecbaba77a6e212dc1911ae1bc2efba267c58093e141bb5c544e59c39979aa3d3
6
+ metadata.gz: fc28d9a40e236b423c809aaddefed91c6de16a6108563e1d47512f8d2d5ef91a0caac2e3113c240e6d55483b272c87603a8dfa190bcdb14213604166bc547eb4
7
+ data.tar.gz: 1d0e968eaf094a70a7854dfe5223c048a02f445f475345b3d5edb0e7a12448c398c960d18b1a5f0d6fa9a9dbbd2f8a1813141739a74cf9a55fcb4281a1fea719
data/README.md CHANGED
@@ -104,7 +104,7 @@ That's it! Scan your entire Rails app for security vulnerabilities.
104
104
  - **DoS/ReDoS** — Unbounded queries, dangerous regex patterns ⭐ ENHANCED in v0.1.8
105
105
  - **Supply Chain** — Typosquatted gems using Levenshtein distance ⭐ IMPROVED in v0.1.8
106
106
 
107
- > **False-positive protection (v0.1.10 - v0.1.12)**
107
+ > **False-positive protection (v0.1.10 - v0.1.13)**
108
108
  > - **Secrets**: Patterns use word boundaries — `no_token:` or `reset_password_instructions:` in locale
109
109
  > files will **not** trigger the secrets checker.
110
110
  > - **Secrets**: Secret values must be space-free (`[^\s'"]{6,}`) — human-readable sentences like
@@ -114,6 +114,7 @@ That's it! Scan your entire Rails app for security vulnerabilities.
114
114
  > `ignored_checks`).
115
115
  > - **DoS**: Smart multiline `.limit()` check detection (v0.1.12) — lookahead up to 3 lines handles chained
116
116
  > `.limit()` calls on subsequent lines or reassignment to the same variable, e.g. `things = Thing.all; things = things.limit(100)` or `.limit(...)` on the next line.
117
+ > - **Ignore File**: Support for `.guarddogignore` (v0.1.13) — allows excluding complete files/directories or ignoring specific checkers for specific files/directories.
117
118
 
118
119
 
119
120
  ## 📊 Example Output
@@ -121,7 +122,7 @@ That's it! Scan your entire Rails app for security vulnerabilities.
121
122
  ### Console Report
122
123
  ```
123
124
  ============================================================
124
- Rails GuardDog Security Report v0.1.12
125
+ Rails GuardDog Security Report v0.1.13
125
126
  ============================================================
126
127
 
127
128
  [CRITICAL] (5 findings)
@@ -225,6 +226,22 @@ GuardDog already silences `secrets` in `spec/` and `test/` by default. To add
225
226
  more suppressions or override the defaults, set `ignored_checks` in your
226
227
  initializer (see example above).
227
228
 
229
+ ### Ignoring findings with `.guarddogignore`
230
+
231
+ You can add a `.guarddogignore` file in the root of your Rails project to exclude entire files/directories or ignore specific checkers for specific files.
232
+
233
+ - To exclude a file or directory completely (silence all checkers), list the path:
234
+ ```
235
+ db/seeds.rb
236
+ vendor/
237
+ ```
238
+
239
+ - To skip only specific checkers for certain files or directories, separate the path and the comma-separated list of checkers with a `:`:
240
+ ```
241
+ db/seeds.rb: secrets
242
+ app/controllers/admin/*: sql_injection, csrf
243
+ ```
244
+
228
245
  ---
229
246
 
230
247
 
@@ -292,6 +309,6 @@ MIT License - Free to use and modify.
292
309
 
293
310
  ---
294
311
 
295
- **Rails GuardDog v0.1.12 — Production Ready**
312
+ **Rails GuardDog v0.1.13 — Production Ready**
296
313
 
297
314
  *Beyond brakeman. Detect what others miss.* 🐕🔒
@@ -43,9 +43,10 @@ module Rails
43
43
 
44
44
  ignored = @configuration.ignored_checks || {}
45
45
  name = checker_identifier
46
+ rel_file = relative_path(file)
46
47
 
47
48
  ignored.any? do |path_pattern, checker_names|
48
- file.include?(path_pattern.to_s) &&
49
+ rel_file.include?(path_pattern.to_s) &&
49
50
  checker_names.map(&:to_s).include?(name)
50
51
  end
51
52
  end
@@ -63,9 +64,24 @@ module Rails
63
64
  def glob_files(pattern)
64
65
  excluded = @configuration&.excluded_paths || []
65
66
  Dir.glob(File.join(@root, pattern)).reject do |file|
66
- excluded.any? { |path| file.include?(path) }
67
+ rel_file = relative_path(file)
68
+ excluded.any? { |path| rel_file.include?(path) }
67
69
  end
68
70
  end
71
+
72
+ private
73
+
74
+ def relative_path(file)
75
+ file_normalized = file.to_s.gsub('\\', '/')
76
+ root_normalized = @root.to_s.gsub('\\', '/')
77
+
78
+ if file_normalized.start_with?(root_normalized)
79
+ file_normalized.sub(/\A#{Regexp.escape(root_normalized)}\/?/, '')
80
+ else
81
+ file_normalized
82
+ end
83
+ end
84
+
69
85
  end
70
86
  end
71
87
  end
@@ -4,11 +4,12 @@ module Rails
4
4
  attr_accessor :configuration, :findings
5
5
 
6
6
  def initialize(config = nil)
7
- @configuration = config || Configuration.new
7
+ @configuration = config || default_configuration
8
8
  @findings = []
9
9
  end
10
10
 
11
11
  def run
12
+ load_ignore_file
12
13
  load_checkers.each do |checker_class|
13
14
  checker = checker_class.new(@configuration)
14
15
  checker.run
@@ -19,6 +20,41 @@ module Rails
19
20
 
20
21
  private
21
22
 
23
+ def default_configuration
24
+ if defined?(Rails) && Rails.application && Rails.application.config.respond_to?(:guarddog)
25
+ Rails.application.config.guarddog
26
+ else
27
+ Configuration.new
28
+ end
29
+ end
30
+
31
+ def load_ignore_file
32
+ ignore_file_path = File.join(@configuration.root, '.guarddogignore')
33
+ return unless File.exist?(ignore_file_path)
34
+
35
+ @configuration.ignored_checks ||= {}
36
+ @configuration.excluded_paths ||= []
37
+
38
+ File.foreach(ignore_file_path).each_with_index do |line, idx|
39
+ line = line.strip
40
+ next if line.empty? || line.start_with?('#')
41
+
42
+ if line.include?(':')
43
+ path_pattern, checkers_str = line.split(':', 2)
44
+ path_pattern = path_pattern.strip.gsub('\\', '/')
45
+ checkers = checkers_str.split(',').map { |c| c.strip.downcase }
46
+
47
+ @configuration.ignored_checks[path_pattern] ||= []
48
+ @configuration.ignored_checks[path_pattern].concat(checkers)
49
+ @configuration.ignored_checks[path_pattern].uniq!
50
+ else
51
+ path_pattern = line.gsub('\\', '/')
52
+ @configuration.excluded_paths << path_pattern
53
+ @configuration.excluded_paths.uniq!
54
+ end
55
+ end
56
+ end
57
+
22
58
  def load_checkers
23
59
  checker_map = {
24
60
  'sql_injection' => Checkers::SqlInjectionChecker,
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Guarddog
3
- VERSION = "0.1.12"
3
+ VERSION = "0.1.13"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-guarddog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Security Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-13 00:00:00.000000000 Z
11
+ date: 2026-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties