gem_guard 0.1.6 → 0.1.10

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: '073099f4fd844fee5ffd2b5466fbee6df36a8c5b9d640039efb0cbdb4db89b97'
4
- data.tar.gz: 21ba615adb70721d4f9ede82e3a43361a92e72e683c53530504913250ccd7309
3
+ metadata.gz: 0370d291f988c0082519f85fdfaffc6fd2acfad9150f91e1c0c66e4d913fd2c0
4
+ data.tar.gz: 81378c1f38167cccd7ff0ed7f6fb8399556afe40bb29421d2d50601e5aafed91
5
5
  SHA512:
6
- metadata.gz: d1bc314331a645c4b2d9791f41d852620fc7a977fc7eaf90ea927743f297057f4af93c40da2788422c8c468b11fbb1ad4d80d59f16cb4a0c9c063f37ebed809c
7
- data.tar.gz: 1dc4f927542ae0983fb73a0d285c66f61c93960f1128bde659a313bbda24a7e6625d41acfdc48fcadeb8600f78bdb2f6de2b052e072a553aa78a937ad841b7dc
6
+ metadata.gz: f07731cbc1d4b3dffe6494a4749dfac41cd31849df39e5e712b3735322135131a59f8dd06aaa790c39104d632637d050e3a25e58a9b92c9441accde55a90126e
7
+ data.tar.gz: 5906908cb03aac3227f78b16cc49b5e8a7b78756361b809840c1b8de9a5dfb3bc5d138954a3703f051e2ee62e8eaea11cb047e1073882c5b2bf3f2715a36468e
data/README.md CHANGED
@@ -6,15 +6,41 @@
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
  [![Security](https://img.shields.io/badge/Security-Policy-blue.svg)](SECURITY.md)
8
8
 
9
- Supply chain security and vulnerability management for Ruby gems. GemGuard provides developers with a comprehensive tool to detect, report, and remediate dependency-related security risks.
10
-
11
- ## Features
12
-
13
- - 🔍 **Vulnerability Scanning**: Detect known CVEs in your dependencies
14
- - 📊 **Multiple Output Formats**: Human-readable tables and JSON output
15
- - 🌐 **Multiple Data Sources**: OSV.dev and Ruby Advisory Database
16
- - 🔧 **Fix Recommendations**: Suggested commands to remediate vulnerabilities
17
- - 🚀 **CI/CD Ready**: Exit codes for pipeline integration
9
+ **The comprehensive Ruby dependency security scanner and SBOM generator.**
10
+
11
+ GemGuard is your one-stop solution for Ruby supply chain security. Detect vulnerabilities, identify typosquats, generate SBOMs, and secure your dependencies with enterprise-grade tooling designed for modern DevOps workflows.
12
+
13
+ ## Features
14
+
15
+ ### 🔍 **Vulnerability Scanning**
16
+ - Detect known CVEs from OSV.dev and Ruby Advisory Database
17
+ - Smart deduplication handles platform-specific gems
18
+ - Severity-based filtering and thresholds
19
+ - Actionable fix recommendations with exact commands
20
+
21
+ ### 🎯 **Typosquat Detection**
22
+ - Fuzzy matching against popular Ruby gems
23
+ - Configurable similarity thresholds
24
+ - Risk level classification (Critical/High/Medium/Low)
25
+ - Hardcoded fallback for reliable detection
26
+
27
+ ### 📋 **SBOM Generation**
28
+ - Industry-standard SPDX 2.3 format
29
+ - CycloneDX 1.5 support
30
+ - Complete dependency metadata
31
+ - License and checksum information
32
+
33
+ ### 🚀 **CI/CD Integration**
34
+ - Configurable exit codes for pipeline control
35
+ - JSON output for automated processing
36
+ - Config file support (`.gemguard.yml`)
37
+ - Multiple output formats and file export
38
+
39
+ ### 🎨 **Developer Experience**
40
+ - Beautiful, colorful terminal output
41
+ - Progress indicators and clear error messages
42
+ - Comprehensive help and documentation
43
+ - Zero-config operation with sensible defaults
18
44
 
19
45
  ## Installation
20
46
 
@@ -32,30 +58,47 @@ Or install it yourself as:
32
58
 
33
59
  $ gem install gem_guard
34
60
 
35
- ## Usage
61
+ ## 🚀 Quick Start
62
+
63
+ ```bash
64
+ # Install GemGuard
65
+ gem install gem_guard
66
+
67
+ # Scan for vulnerabilities
68
+ gem_guard scan
69
+
70
+ # Check for typosquats
71
+ gem_guard typosquat
36
72
 
37
- ### Basic Vulnerability Scan
73
+ # Generate SBOM
74
+ gem_guard sbom
75
+ ```
76
+
77
+ ## 📖 Usage
38
78
 
39
- Scan your project's dependencies for known vulnerabilities:
79
+ ### 🔍 Vulnerability Scanning
40
80
 
81
+ **Basic scan:**
41
82
  ```bash
42
83
  gem_guard scan
43
84
  ```
44
85
 
45
- ### Specify Custom Lockfile
46
-
86
+ **Custom lockfile:**
47
87
  ```bash
48
88
  gem_guard scan --lockfile path/to/Gemfile.lock
49
89
  ```
50
90
 
51
- ### JSON Output
52
-
91
+ **JSON output for automation:**
53
92
  ```bash
54
- gem_guard scan --format json
93
+ gem_guard scan --format json --output vulnerabilities.json
55
94
  ```
56
95
 
57
- ### Example Output
96
+ **CI/CD integration with exit codes:**
97
+ ```bash
98
+ gem_guard scan --fail-on-vulnerabilities --severity-threshold high
99
+ ```
58
100
 
101
+ **Example output:**
59
102
  ```
60
103
  🚨 Security Vulnerabilities Found
61
104
  ==================================================
@@ -66,17 +109,208 @@ Summary:
66
109
 
67
110
  Details:
68
111
 
69
- 📦 actionpack (6.1.0)
70
- 🔍 Vulnerability: CVE-2021-22885
71
- ⚠️ Severity: HIGH
72
- 📝 Summary: Possible Information Disclosure / Unintended Method Execution in Action Pack
73
- 🔧 Fix: bundle update actionpack --to 6.1.3.1
112
+ 📦 nokogiri (1.18.8)
113
+ 🔍 Vulnerability: GHSA-353f-x4gh-cqq8
114
+ ⚠️ Severity: UNKNOWN
115
+ 📝 Summary: Nokogiri patches vendored libxml2 to resolve multiple CVEs
116
+ 🔧 Fix: bundle update nokogiri --to 1.18.9
117
+
118
+ 📦 thor (1.3.2)
119
+ 🔍 Vulnerability: GHSA-mqcp-p2hv-vw6x
120
+ ⚠️ Severity: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H
121
+ 📝 Summary: Thor can construct an unsafe shell command from library input.
122
+ 🔧 Fix: bundle update thor --to 1.4.0
123
+ ```
124
+
125
+ ### 🎯 Typosquat Detection
126
+
127
+ **Basic typosquat check:**
128
+ ```bash
129
+ gem_guard typosquat
130
+ ```
131
+
132
+ **Custom similarity threshold:**
133
+ ```bash
134
+ gem_guard typosquat --threshold 0.9
135
+ ```
136
+
137
+ **JSON output:**
138
+ ```bash
139
+ gem_guard typosquat --format json --output typosquats.json
140
+ ```
141
+
142
+ **Example output:**
143
+ ```
144
+ 🎯 Potential Typosquat Dependencies Found
145
+ ==========================================
146
+
147
+ 📦 railz (7.0.0)
148
+ 🚨 Risk Level: CRITICAL
149
+ 📊 Similarity: 80.0% to 'rails'
150
+ ⚠️ This gem name is suspiciously similar to the popular gem 'rails'
151
+ 🔧 Consider: Did you mean 'rails'? Review this dependency carefully.
152
+ ```
153
+
154
+ ### 📋 SBOM Generation
74
155
 
75
- 📦 nokogiri (1.10.0)
76
- 🔍 Vulnerability: CVE-2020-26247
77
- ⚠️ Severity: MEDIUM
78
- 📝 Summary: XML External Entity vulnerability in Nokogiri
79
- 🔧 Fix: bundle update nokogiri --to 1.11.0
156
+ **Generate SPDX SBOM:**
157
+ ```bash
158
+ gem_guard sbom
159
+ ```
160
+
161
+ **Generate CycloneDX SBOM:**
162
+ ```bash
163
+ gem_guard sbom --format cyclone-dx
164
+ ```
165
+
166
+ **Custom project name and output:**
167
+ ```bash
168
+ gem_guard sbom --project my-app --output sbom.json
169
+ ```
170
+
171
+ **Example SPDX output:**
172
+ ```json
173
+ {
174
+ "spdxVersion": "SPDX-2.3",
175
+ "dataLicense": "CC0-1.0",
176
+ "SPDXID": "SPDXRef-DOCUMENT",
177
+ "name": "my-app-sbom",
178
+ "documentNamespace": "https://gem-guard.dev/my-app/2025-01-09T23:55:00Z",
179
+ "creationInfo": {
180
+ "created": "2025-01-09T23:55:00Z",
181
+ "creators": ["Tool: gem_guard-1.0.0"]
182
+ },
183
+ "packages": [...],
184
+ "relationships": [...]
185
+ }
186
+ ```
187
+
188
+ ## ⚙️ Configuration
189
+
190
+ GemGuard supports project-level configuration via `.gemguard.yml`:
191
+
192
+ ```yaml
193
+ # .gemguard.yml
194
+ lockfile_path: "Gemfile.lock"
195
+ output_format: "table" # table, json
196
+ fail_on_vulnerabilities: true
197
+ severity_threshold: "medium" # low, medium, high, critical
198
+ output_file: null
199
+ ignore_vulnerabilities:
200
+ - "CVE-2021-12345" # Ignore specific CVEs
201
+ - "GHSA-xxxx-xxxx-xxxx"
202
+ typosquat:
203
+ similarity_threshold: 0.8
204
+ enabled: true
205
+ sbom:
206
+ format: "spdx" # spdx, cyclone-dx
207
+ project_name: "my-project"
208
+ ```
209
+
210
+ ### Configuration Options
211
+
212
+ | Option | Description | Default |
213
+ |--------|-------------|---------|
214
+ | `lockfile_path` | Path to Gemfile.lock | `"Gemfile.lock"` |
215
+ | `output_format` | Output format (table/json) | `"table"` |
216
+ | `fail_on_vulnerabilities` | Exit with code 1 if vulnerabilities found | `true` |
217
+ | `severity_threshold` | Minimum severity to report | `"low"` |
218
+ | `output_file` | Write output to file | `null` |
219
+ | `ignore_vulnerabilities` | List of CVE/GHSA IDs to ignore | `[]` |
220
+ | `typosquat.similarity_threshold` | Typosquat detection sensitivity | `0.8` |
221
+ | `typosquat.enabled` | Enable typosquat detection | `true` |
222
+ | `sbom.format` | SBOM format (spdx/cyclone-dx) | `"spdx"` |
223
+ | `sbom.project_name` | Project name in SBOM | `"ruby-project"` |
224
+
225
+ ## 🔄 CI/CD Integration
226
+
227
+ ### Exit Codes
228
+
229
+ GemGuard uses standard exit codes for CI/CD integration:
230
+
231
+ - **0**: Success (no vulnerabilities or typosquats found)
232
+ - **1**: Vulnerabilities/typosquats found
233
+ - **2**: Error (invalid arguments, missing files, etc.)
234
+
235
+ ### GitHub Actions
236
+
237
+ ```yaml
238
+ name: Security Scan
239
+ on: [push, pull_request]
240
+
241
+ jobs:
242
+ security:
243
+ runs-on: ubuntu-latest
244
+ steps:
245
+ - uses: actions/checkout@v4
246
+ - uses: ruby/setup-ruby@v1
247
+ with:
248
+ ruby-version: '3.2'
249
+ bundler-cache: true
250
+
251
+ - name: Install GemGuard
252
+ run: gem install gem_guard
253
+
254
+ - name: Vulnerability Scan
255
+ run: gem_guard scan --format json --output vulnerabilities.json
256
+
257
+ - name: Typosquat Check
258
+ run: gem_guard typosquat --format json --output typosquats.json
259
+
260
+ - name: Generate SBOM
261
+ run: gem_guard sbom --output sbom.json
262
+
263
+ - name: Upload Security Reports
264
+ uses: actions/upload-artifact@v4
265
+ if: always()
266
+ with:
267
+ name: security-reports
268
+ path: |
269
+ vulnerabilities.json
270
+ typosquats.json
271
+ sbom.json
272
+ ```
273
+
274
+ ### GitLab CI
275
+
276
+ ```yaml
277
+ security_scan:
278
+ stage: test
279
+ image: ruby:3.2
280
+ before_script:
281
+ - bundle install
282
+ - gem install gem_guard
283
+ script:
284
+ - gem_guard scan --format json --output vulnerabilities.json
285
+ - gem_guard typosquat --format json --output typosquats.json
286
+ - gem_guard sbom --output sbom.json
287
+ artifacts:
288
+ reports:
289
+ # GitLab can parse these for security dashboard
290
+ dependency_scanning: vulnerabilities.json
291
+ paths:
292
+ - "*.json"
293
+ when: always
294
+ allow_failure: false
295
+ ```
296
+
297
+ ### CircleCI
298
+
299
+ ```yaml
300
+ version: 2.1
301
+ jobs:
302
+ security:
303
+ docker:
304
+ - image: cimg/ruby:3.2
305
+ steps:
306
+ - checkout
307
+ - run: bundle install
308
+ - run: gem install gem_guard
309
+ - run: gem_guard scan --fail-on-vulnerabilities
310
+ - run: gem_guard typosquat
311
+ - run: gem_guard sbom --output sbom.json
312
+ - store_artifacts:
313
+ path: sbom.json
80
314
  ```
81
315
 
82
316
  ## Development
@@ -106,14 +340,63 @@ Releases are automated via GitHub Actions. To create a new release:
106
340
 
107
341
  The release workflow is triggered only when `lib/gem_guard/version.rb` changes.
108
342
 
109
- ## Contributing
343
+ ## 🤝 Contributing
344
+
345
+ We welcome contributions! Here's how you can help:
346
+
347
+ 1. **Fork the repository**
348
+ 2. **Create a feature branch** (`git checkout -b feature/amazing-feature`)
349
+ 3. **Write tests** for your changes (we use strict TDD)
350
+ 4. **Run the test suite** (`bundle exec rspec`)
351
+ 5. **Run the linter** (`bundle exec rake standard`)
352
+ 6. **Commit your changes** (`git commit -am 'Add amazing feature'`)
353
+ 7. **Push to the branch** (`git push origin feature/amazing-feature`)
354
+ 8. **Open a Pull Request**
355
+
356
+ ### Development Guidelines
357
+
358
+ - Follow DHH-style Ruby: pragmatic, intention-revealing, minimal abstractions
359
+ - Use strict outside-in TDD with RSpec
360
+ - Maintain 100% test coverage
361
+ - Follow StandardRB for code style
362
+ - Write clear, descriptive commit messages
110
363
 
111
- Bug reports and pull requests are welcome on GitHub at https://github.com/wilburhimself/gem_guard.
364
+ ## 📊 Roadmap
112
365
 
113
- ## License
366
+ - [ ] **Enhanced Vulnerability Sources**: Additional security databases
367
+ - [ ] **Auto-Fix Suggestions**: Automated dependency updates
368
+ - [ ] **Web Dashboard**: Browser-based security monitoring
369
+ - [ ] **IDE Integrations**: VS Code, RubyMine plugins
370
+ - [ ] **Slack/Teams Notifications**: Real-time security alerts
371
+ - [ ] **Custom Rules Engine**: User-defined security policies
372
+
373
+ ## 🏆 Why GemGuard?
374
+
375
+ | Feature | GemGuard | bundler-audit | Other Tools |
376
+ |---------|----------|---------------|-------------|
377
+ | **Vulnerability Scanning** | ✅ OSV.dev + Ruby Advisory | ✅ Ruby Advisory Only | ❌ Limited Sources |
378
+ | **Typosquat Detection** | ✅ Fuzzy Matching | ❌ | ❌ |
379
+ | **SBOM Generation** | ✅ SPDX + CycloneDX | ❌ | ❌ |
380
+ | **CI/CD Integration** | ✅ Full Support | ⚠️ Basic | ⚠️ Limited |
381
+ | **JSON Output** | ✅ | ✅ | ⚠️ Varies |
382
+ | **Configuration Files** | ✅ | ❌ | ⚠️ Limited |
383
+ | **Platform Deduplication** | ✅ | ❌ | ❌ |
384
+ | **Active Development** | ✅ | ⚠️ Maintenance | ⚠️ Varies |
385
+
386
+ ## 📄 License
114
387
 
115
388
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
116
389
 
117
- ## Security
390
+ ## 🔒 Security
391
+
392
+ If you discover a security vulnerability within GemGuard, please see our [Security Policy](SECURITY.md) for responsible disclosure guidelines.
393
+
394
+ ## 🙏 Acknowledgments
395
+
396
+ - [OSV.dev](https://osv.dev/) for comprehensive vulnerability data
397
+ - [Ruby Advisory Database](https://github.com/rubysec/ruby-advisory-db) for Ruby-specific advisories
398
+ - The Ruby community for continuous feedback and contributions
399
+
400
+ ---
118
401
 
119
- If you discover a security vulnerability within GemGuard, please send an email to security@example.com. All security vulnerabilities will be promptly addressed.
402
+ **Made with ❤️ for the Ruby community**
data/SECURITY.md CHANGED
@@ -46,8 +46,52 @@ GemGuard itself implements several security best practices:
46
46
 
47
47
  When using GemGuard:
48
48
 
49
- - Keep GemGuard updated to the latest version
50
- - Review vulnerability reports carefully before applying fixes
49
+ - **Keep GemGuard updated** to the latest version for security patches
50
+ - **Review vulnerability reports** carefully before applying fixes
51
+ - **Validate SBOM outputs** before sharing with external parties
52
+ - **Use secure channels** when transmitting security reports
53
+ - **Configure ignore lists** carefully to avoid missing critical vulnerabilities
54
+ - **Monitor CI/CD pipelines** for security scan failures
55
+
56
+ ## Threat Model
57
+
58
+ GemGuard protects against:
59
+
60
+ - **Known Vulnerabilities**: CVEs in your dependency chain
61
+ - **Typosquat Attacks**: Malicious gems with similar names to popular packages
62
+ - **Supply Chain Attacks**: Compromised or malicious dependencies
63
+ - **Outdated Dependencies**: Gems with known security issues
64
+
65
+ ## Data Handling
66
+
67
+ GemGuard:
68
+
69
+ - **Does not collect** personal or sensitive data
70
+ - **Queries public APIs** (OSV.dev) for vulnerability information
71
+ - **Processes locally** your Gemfile.lock and dependency information
72
+ - **Does not transmit** your code or proprietary information
73
+ - **Caches vulnerability data** temporarily for performance
74
+
75
+ ## Security Updates
76
+
77
+ We provide security updates through:
78
+
79
+ - **GitHub Security Advisories** for critical vulnerabilities
80
+ - **RubyGems.org releases** with security patches
81
+ - **Email notifications** to security@wilburhimself.com subscribers
82
+ - **GitHub releases** with detailed changelogs
83
+
84
+ ## Contact
85
+
86
+ For security-related inquiries:
87
+
88
+ - **Email**: security@wilburhimself.com
89
+ - **PGP Key**: Available upon request
90
+ - **Response Time**: 48 hours for initial response
91
+
92
+ ---
93
+
94
+ *Last updated: January 2025*
51
95
  - Use GemGuard in your CI/CD pipeline to catch vulnerabilities early
52
96
  - Consider the source and severity of reported vulnerabilities
53
97
 
@@ -8,7 +8,10 @@ module GemGuard
8
8
 
9
9
  next if matching_vulns.empty?
10
10
 
11
- matching_vulns.each do |vulnerability|
11
+ # Deduplicate vulnerabilities by ID to avoid duplicate entries for the same vulnerability
12
+ unique_vulns = matching_vulns.uniq { |vuln| vuln.id }
13
+
14
+ unique_vulns.each do |vulnerability|
12
15
  if version_affected?(dependency.version, vulnerability)
13
16
  vulnerable_dependencies << VulnerableDependency.new(
14
17
  dependency: dependency,