bundler-trivy-plugin 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ea7f6f75aad29ec1c71c632cd92cc3cdb579bb561534cf2f3bffd94b56230027
4
+ data.tar.gz: 8f54b32d097f04f2954a4140647e78779860b9807d1d54b82ef06e45276e4526
5
+ SHA512:
6
+ metadata.gz: dfc15a2ad1275fe5a1b6885d90a2ee267f61e73261db6f7b783a6903f7bb338f6072e5b0e47132ec25f5bb6dee14e132638081f17ced72d045ebc4c284c8d985
7
+ data.tar.gz: b74d1fd1c04cd582919038233c43d9cb83c6da8a866ac7da4424e83a5975863c20f9cb2c6d96ec8987c1a0e84917fdae35fc97ffaa32f02c93b84a3be40d4fff
data/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial project structure and foundational code
12
+ - Core scanning functionality using Trivy
13
+ - Configuration system supporting YAML files and environment variables
14
+ - Reporter with terminal output support
15
+ - Automatic scanning after `bundle install`
16
+ - Support for ignoring CVEs with expiration dates
17
+ - CI environment detection for automatic fail-on-critical behavior
18
+ - Configurable timeout for Trivy scans
19
+ - Severity filtering (CRITICAL, HIGH, MEDIUM, LOW, UNKNOWN)
20
+
21
+ ### Changed
22
+ - Migrated from RSpec to Minitest for testing (per Durable Programming standards)
23
+ - Moved bundler from development dependency to runtime dependency
24
+ - Enhanced gemspec metadata with RubyGems.org requirements
25
+
26
+ ### Documentation
27
+ - Created comprehensive TODO.md with improvement roadmap
28
+ - Added LICENSE file (MIT)
29
+ - Created CHANGELOG.md following Keep a Changelog format
30
+ - Added CONTRIBUTING.md with development guidelines
31
+ - Added SECURITY.md with vulnerability reporting procedures
32
+
33
+ ## [0.1.0] - 2025-01-31
34
+
35
+ ### Added
36
+ - Initial alpha release
37
+ - Basic Trivy integration for Bundler
38
+ - Configuration file support (`.bundler-trivy.yml`)
39
+ - Environment variable configuration
40
+ - Vulnerability reporting
41
+ - CVE ignore list with expiration
42
+
43
+ [Unreleased]: https://github.com/durableprogramming/bundler-trivy-plugin/compare/v0.1.0...HEAD
44
+ [0.1.0]: https://github.com/durableprogramming/bundler-trivy-plugin/releases/tag/v0.1.0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Durable Programming LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,480 @@
1
+ # Bundler Trivy Plugin
2
+
3
+ **Automated security vulnerability scanning for Ruby dependencies using Trivy.**
4
+
5
+ A Bundler plugin that automatically integrates [Trivy](https://trivy.dev/) security scanner into your Ruby development workflow. After every `bundle install`, the plugin scans your dependencies for known vulnerabilities and provides actionable remediation guidance.
6
+
7
+ ## Features
8
+
9
+ - **Automatic Scanning**: Scans dependencies after `bundle install` with zero configuration
10
+ - **CI/CD Integration**: Smart defaults for CI environments with configurable fail-on policies
11
+ - **Flexible Configuration**: YAML config files and environment variables
12
+ - **CVE Ignore List**: Temporary ignore vulnerabilities with expiration dates
13
+ - **Multiple Output Formats**: Terminal (default), JSON, and compact modes
14
+ - **Detailed Reporting**: Clear vulnerability summaries with fix recommendations
15
+ - **Zero Dependencies**: Lightweight plugin with minimal runtime dependencies
16
+
17
+ ## Quick Start
18
+
19
+ ### 1. Install Trivy
20
+
21
+ First, install the Trivy scanner:
22
+
23
+ **macOS**:
24
+ ```bash
25
+ brew install aquasecurity/trivy/trivy
26
+ ```
27
+
28
+ **Linux (Ubuntu/Debian)**:
29
+ ```bash
30
+ wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
31
+ echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
32
+ sudo apt-get update
33
+ sudo apt-get install trivy
34
+ ```
35
+
36
+ **Other platforms**: See [Trivy Installation Guide](https://trivy.dev/docs/getting-started/installation/)
37
+
38
+ ### 2. Install the Plugin
39
+
40
+ **From source** (currently):
41
+ ```bash
42
+ gem build bundler-trivy-plugin.gemspec
43
+ bundle plugin install bundler-trivy-plugin --source .
44
+ ```
45
+
46
+ **Coming soon - from RubyGems**:
47
+ ```bash
48
+ gem install bundler-trivy-plugin
49
+ bundle plugin install bundler-trivy-plugin
50
+ ```
51
+
52
+ ### 3. Verify Installation
53
+
54
+ ```bash
55
+ bundle plugin list
56
+ # Should show: bundler-trivy-plugin
57
+
58
+ trivy --version
59
+ # Should show: Version: 0.x.x or later
60
+ ```
61
+
62
+ ### 4. Use It
63
+
64
+ That's it! The plugin now runs automatically:
65
+
66
+ ```bash
67
+ bundle install
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ ### Automatic Scanning
73
+
74
+ The plugin runs automatically after `bundle install`:
75
+
76
+ ```bash
77
+ $ bundle install
78
+ Fetching gem metadata from https://rubygems.org/
79
+ ...
80
+ Bundle complete! 15 Gemfile dependencies, 73 gems now installed.
81
+
82
+ âš  Trivy found 2 vulnerabilities:
83
+
84
+ CRITICAL: 1
85
+ HIGH: 1
86
+
87
+ CRITICAL Vulnerabilities:
88
+
89
+ rails (6.1.0)
90
+ CVE-2023-38545: Rails ActiveRecord SQL Injection
91
+ Fixed in: 6.1.7.6, 7.0.8
92
+ https://avd.aquasec.com/nvd/cve-2023-38545
93
+
94
+ Recommended Actions:
95
+
96
+ Update rails: bundle update rails
97
+ ```
98
+
99
+ ### Skipping Scans
100
+
101
+ Temporarily skip scanning:
102
+
103
+ ```bash
104
+ BUNDLER_TRIVY_SKIP=true bundle install
105
+ ```
106
+
107
+ ### CI/CD Integration
108
+
109
+ The plugin automatically detects CI environments and enables strict mode:
110
+
111
+ ```yaml
112
+ # GitHub Actions example
113
+ - name: Install dependencies
114
+ run: bundle install
115
+ # Plugin automatically fails on critical vulnerabilities in CI
116
+
117
+ # Override if needed
118
+ - name: Install dependencies (non-blocking)
119
+ run: BUNDLER_TRIVY_FAIL_ON_CRITICAL=false bundle install
120
+ ```
121
+
122
+ **Supported CI platforms**:
123
+ - GitHub Actions
124
+ - GitLab CI
125
+ - Travis CI
126
+ - Jenkins
127
+ - CircleCI (via CI=true)
128
+
129
+ ## Configuration
130
+
131
+ ### Configuration File
132
+
133
+ Create `.bundler-trivy.yml` in your project root:
134
+
135
+ ```yaml
136
+ # Enable/disable scanning (default: true)
137
+ enabled: true
138
+
139
+ # Fail conditions - exit with error code 1 if vulnerabilities found
140
+ fail_on:
141
+ critical: true # Default: true in CI, false locally
142
+ high: false # Default: false
143
+ # Note: BUNDLER_TRIVY_FAIL_ON_ANY=true fails on any severity
144
+
145
+ # Output configuration
146
+ output:
147
+ format: terminal # Options: terminal, json
148
+ compact: false # Default: false locally, true in CI
149
+
150
+ # Scanning configuration
151
+ scanning:
152
+ timeout: 120 # Scan timeout in seconds (default: 120)
153
+ severity_filter:
154
+ - CRITICAL
155
+ - HIGH
156
+ # Options: CRITICAL, HIGH, MEDIUM, LOW, UNKNOWN
157
+
158
+ # Ignore specific CVEs (use sparingly!)
159
+ ignores:
160
+ - id: CVE-2023-12345
161
+ reason: "False positive - does not affect our usage pattern"
162
+ expires: 2025-12-31 # Required: forces periodic review
163
+
164
+ - id: CVE-2023-67890
165
+ reason: "Waiting for backport to current Rails version"
166
+ expires: 2025-06-30
167
+ ```
168
+
169
+ ### Environment Variables
170
+
171
+ Environment variables override configuration file settings:
172
+
173
+ | Variable | Description | Default | Example |
174
+ |----------|-------------|---------|---------|
175
+ | `BUNDLER_TRIVY_SKIP` | Skip scanning entirely | `false` | `true` |
176
+ | `BUNDLER_TRIVY_FAIL_ON_CRITICAL` | Exit on critical vulns | CI=true | `true` |
177
+ | `BUNDLER_TRIVY_FAIL_ON_HIGH` | Exit on high vulns | `false` | `true` |
178
+ | `BUNDLER_TRIVY_FAIL_ON_ANY` | Exit on any vulns | `false` | `true` |
179
+ | `BUNDLER_TRIVY_COMPACT` | Compact output | CI=true | `true` |
180
+ | `BUNDLER_TRIVY_FORMAT` | Output format | `terminal` | `json` |
181
+ | `BUNDLER_TRIVY_TIMEOUT` | Scan timeout (seconds) | `120` | `300` |
182
+ | `BUNDLER_TRIVY_SEVERITY` | Severity threshold | `CRITICAL` | `HIGH` |
183
+
184
+ **Examples**:
185
+
186
+ ```bash
187
+ # Ultra-strict mode (fail on any vulnerability)
188
+ BUNDLER_TRIVY_FAIL_ON_ANY=true bundle install
189
+
190
+ # JSON output for parsing
191
+ BUNDLER_TRIVY_FORMAT=json bundle install > vulnerabilities.json
192
+
193
+ # Longer timeout for large projects
194
+ BUNDLER_TRIVY_TIMEOUT=300 bundle install
195
+
196
+ # Skip scanning temporarily
197
+ BUNDLER_TRIVY_SKIP=true bundle install
198
+ ```
199
+
200
+ ### Multiple Environments
201
+
202
+ Use environment-specific configs:
203
+
204
+ ```bash
205
+ # .bundler-trivy.development.yml - lenient for local dev
206
+ enabled: true
207
+ fail_on:
208
+ critical: false
209
+
210
+ # .bundler-trivy.production.yml - strict for production
211
+ enabled: true
212
+ fail_on:
213
+ critical: true
214
+ high: true
215
+ ```
216
+
217
+ Activate with:
218
+
219
+ ```bash
220
+ BUNDLER_TRIVY_ENV=production bundle install
221
+ ```
222
+
223
+ ### Global Configuration
224
+
225
+ Create `~/.bundle/trivy.yml` for user-wide defaults:
226
+
227
+ ```yaml
228
+ # Your personal defaults for all projects
229
+ output:
230
+ compact: false
231
+ scanning:
232
+ timeout: 180
233
+ ```
234
+
235
+ Project configs override global configs.
236
+
237
+ ## Examples
238
+
239
+ ### Example: GitHub Actions Workflow
240
+
241
+ ```yaml
242
+ name: Security Scan
243
+
244
+ on: [push, pull_request]
245
+
246
+ jobs:
247
+ security:
248
+ runs-on: ubuntu-latest
249
+ steps:
250
+ - uses: actions/checkout@v3
251
+
252
+ - name: Set up Ruby
253
+ uses: ruby/setup-ruby@v1
254
+ with:
255
+ ruby-version: 3.2
256
+ bundler-cache: false # We'll handle bundling
257
+
258
+ - name: Install Trivy
259
+ run: |
260
+ wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
261
+ echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
262
+ sudo apt-get update
263
+ sudo apt-get install trivy
264
+
265
+ - name: Install Plugin
266
+ run: |
267
+ gem build bundler-trivy-plugin.gemspec
268
+ bundle plugin install bundler-trivy-plugin --source .
269
+
270
+ - name: Install Dependencies with Security Scan
271
+ run: bundle install
272
+ # Automatically fails on critical vulnerabilities in CI
273
+ ```
274
+
275
+ ### Example: GitLab CI
276
+
277
+ ```yaml
278
+ security_scan:
279
+ image: ruby:3.2
280
+ before_script:
281
+ - apt-get update && apt-get install -y wget gnupg
282
+ - wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | apt-key add -
283
+ - echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/trivy.list
284
+ - apt-get update && apt-get install -y trivy
285
+ - gem build bundler-trivy-plugin.gemspec
286
+ - bundle plugin install bundler-trivy-plugin --source .
287
+ script:
288
+ - bundle install
289
+ allow_failure: false
290
+ ```
291
+
292
+ ### Example: Local Development Workflow
293
+
294
+ ```bash
295
+ # Initial setup
296
+ bundle install # Scans and warns about vulnerabilities
297
+
298
+ # Working on features (skip scanning for speed)
299
+ BUNDLER_TRIVY_SKIP=true bundle install
300
+
301
+ # Before committing (strict check)
302
+ BUNDLER_TRIVY_FAIL_ON_HIGH=true bundle install
303
+ ```
304
+
305
+ ## Troubleshooting
306
+
307
+ ### Plugin not running
308
+
309
+ **Check plugin is installed**:
310
+ ```bash
311
+ bundle plugin list
312
+ # Should show bundler-trivy-plugin
313
+ ```
314
+
315
+ **Reinstall if needed**:
316
+ ```bash
317
+ bundle plugin uninstall bundler-trivy-plugin
318
+ bundle plugin install bundler-trivy-plugin --source .
319
+ ```
320
+
321
+ ### Trivy not found
322
+
323
+ **Verify Trivy is installed**:
324
+ ```bash
325
+ which trivy
326
+ trivy --version
327
+ ```
328
+
329
+ **Install Trivy**: See [Quick Start](#quick-start)
330
+
331
+ ### Scan timing out
332
+
333
+ **Increase timeout**:
334
+ ```bash
335
+ BUNDLER_TRIVY_TIMEOUT=300 bundle install
336
+ ```
337
+
338
+ **Or in config**:
339
+ ```yaml
340
+ scanning:
341
+ timeout: 300
342
+ ```
343
+
344
+ ### False positives
345
+
346
+ **Ignore specific CVEs temporarily**:
347
+ ```yaml
348
+ ignores:
349
+ - id: CVE-2023-XXXXX
350
+ reason: "Detailed explanation of why this is safe"
351
+ expires: 2025-12-31 # Forces review
352
+ ```
353
+
354
+ **Best practice**: Always include an expiration date to force periodic review.
355
+
356
+ ### Scan failing in CI
357
+
358
+ **Check CI logs for specific error**:
359
+ ```bash
360
+ # Run locally with same settings
361
+ CI=true bundle install
362
+ ```
363
+
364
+ **Common causes**:
365
+ - Outdated Trivy database
366
+ - Network connectivity issues
367
+ - Actual vulnerabilities (intended behavior!)
368
+
369
+ ### Permission errors
370
+
371
+ **Linux/macOS**: Ensure Trivy binary is executable:
372
+ ```bash
373
+ chmod +x $(which trivy)
374
+ ```
375
+
376
+ ## Development
377
+
378
+ ### Setup
379
+
380
+ ```bash
381
+ git clone https://github.com/durableprogramming/bundler-trivy-plugin.git
382
+ cd bundler-trivy-plugin
383
+ bundle install
384
+ ```
385
+
386
+ ### Running Tests
387
+
388
+ ```bash
389
+ # Run all tests
390
+ rake test
391
+
392
+ # Run specific test file
393
+ ruby test/bundler/trivy/config_test.rb
394
+
395
+ # Run with coverage
396
+ COVERAGE=true rake test
397
+ ```
398
+
399
+ ### Code Quality
400
+
401
+ ```bash
402
+ # Check style
403
+ bundle exec rubocop
404
+
405
+ # Auto-fix violations
406
+ bundle exec rubocop -a
407
+ ```
408
+
409
+ ### Local Testing
410
+
411
+ ```bash
412
+ # Build gem
413
+ gem build bundler-trivy-plugin.gemspec
414
+
415
+ # Install in test project
416
+ cd /path/to/test/project
417
+ bundle plugin uninstall bundler-trivy-plugin || true
418
+ bundle plugin install bundler-trivy-plugin --source /path/to/plugin
419
+
420
+ # Test
421
+ bundle install
422
+ ```
423
+
424
+ ### Opening Console
425
+
426
+ ```bash
427
+ rake console
428
+ ```
429
+
430
+ ## Requirements
431
+
432
+ - **Ruby**: 2.7.0 or later
433
+ - **Bundler**: 2.0 or later
434
+ - **Trivy**: Latest version recommended (0.40.0+)
435
+ - **Operating Systems**: macOS, Linux, Windows (with WSL)
436
+
437
+ ## Contributing
438
+
439
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for:
440
+ - Development setup
441
+ - Code style guidelines
442
+ - Testing requirements
443
+ - Pull request process
444
+
445
+ ## Security
446
+
447
+ Security is paramount. See [SECURITY.md](SECURITY.md) for:
448
+ - Vulnerability reporting procedures
449
+ - Security best practices
450
+ - Supported versions
451
+
452
+ **Report security issues to**: security@durableprogramming.com
453
+
454
+ ## Changelog
455
+
456
+ See [CHANGELOG.md](CHANGELOG.md) for version history and release notes.
457
+
458
+ ## Roadmap
459
+
460
+ See [TODO.md](TODO.md) for planned features and improvements.
461
+
462
+ ## License
463
+
464
+ MIT License - see [LICENSE](LICENSE) for details.
465
+
466
+ ## Support
467
+
468
+ - **Documentation**: [GitHub README](https://github.com/durableprogramming/bundler-trivy-plugin)
469
+ - **Issues**: [GitHub Issues](https://github.com/durableprogramming/bundler-trivy-plugin/issues)
470
+ - **Email**: commercial@durableprogramming.com
471
+
472
+ ## Credits
473
+
474
+ - Built by [Durable Programming LLC](https://durableprogramming.com)
475
+ - Powered by [Aqua Security Trivy](https://trivy.dev/)
476
+ - Inspired by the Ruby security community
477
+
478
+ ---
479
+
480
+ **Stay secure!** 🔒