ruborg 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3dfe277e22cf29ef1132f479b8e8a969e87c69b383529b7f05eb7238ac5ea07
4
- data.tar.gz: fcf98cabcd5f4636fc513e69e3b446747c9ca2f054f6480f4da60416ec865f0d
3
+ metadata.gz: 263e32d62c24714f299a20218bc96733cf6f13cffa0e0d844ef5b37c5470dbdf
4
+ data.tar.gz: f020b2b5714fd3c02d9372414de7494e7beb637d5312bcf34f05e2be5bf1ecd1
5
5
  SHA512:
6
- metadata.gz: 159296240a1cec2e7791edb3689bf032569d8c1f4fda0ac5c1522e92076fec8c719dba3117326c9fcb9e074ffa295ed71a75b500657625d1ce71fab391b441c2
7
- data.tar.gz: f6385fa1ff56520719b1f8b3985931b4083b3139889b34ed4d1dcb5d449eec8ba98e96f030988cf03cdcb5744f47255ef3b7a605e7bb040d6b1f2c0446ab3b81
6
+ metadata.gz: 1ad51dcadf03ca1958ff6ecd10b24846d6e501219dd59637280eaf6d37a2d6b6a505ff0bbb9401d5f7ebfd361c24a3e1c3b09bc71f40bf788c6581da2a98832a
7
+ data.tar.gz: 5679385c1369eb161235c998dd69526a3bc27dca1cfc13acc22bd0602184f15438c042542495300b1752eb8ce810dfbc467bfe83d10b492641063e84381f3881
data/.rubocop.yml ADDED
@@ -0,0 +1,175 @@
1
+ # RuboCop configuration for Ruborg
2
+
3
+ plugins:
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 3.2
8
+ NewCops: enable
9
+ SuggestExtensions: false
10
+ Exclude:
11
+ - 'vendor/**/*'
12
+ - 'tmp/**/*'
13
+ - 'bin/*'
14
+
15
+ # Disable documentation requirement
16
+ Style/Documentation:
17
+ Enabled: false
18
+
19
+ # Allow development dependencies in gemspec
20
+ Gemspec/DevelopmentDependencies:
21
+ Enabled: false
22
+
23
+ # Allow longer lines in some cases
24
+ Layout/LineLength:
25
+ Max: 120
26
+ AllowedPatterns:
27
+ - '\s+# '
28
+ - '^\s*#'
29
+ Exclude:
30
+ - 'spec/**/*'
31
+
32
+ # Allow longer methods in specs
33
+ Metrics/MethodLength:
34
+ Max: 25
35
+ Exclude:
36
+ - 'spec/**/*'
37
+ - 'lib/ruborg/cli.rb' # CLI commands can be longer
38
+
39
+ # Allow longer blocks in specs
40
+ Metrics/BlockLength:
41
+ Exclude:
42
+ - 'spec/**/*'
43
+ - '*.gemspec'
44
+
45
+ # Allow more complex methods
46
+ Metrics/AbcSize:
47
+ Max: 30
48
+ Exclude:
49
+ - 'spec/**/*'
50
+ - 'lib/ruborg/cli.rb' # CLI commands can be more complex
51
+
52
+ # Allow reasonable cyclomatic complexity
53
+ Metrics/CyclomaticComplexity:
54
+ Max: 15
55
+ Exclude:
56
+ - 'lib/ruborg/cli.rb' # CLI commands can have more branches
57
+
58
+ # Allow reasonable perceived complexity
59
+ Metrics/PerceivedComplexity:
60
+ Max: 15
61
+ Exclude:
62
+ - 'lib/ruborg/cli.rb' # CLI commands can be more complex
63
+
64
+ # Allow larger classes for CLI and main library classes
65
+ Metrics/ClassLength:
66
+ Max: 350
67
+ Exclude:
68
+ - 'spec/**/*'
69
+
70
+ # Prefer modern hash syntax
71
+ Style/HashSyntax:
72
+ EnforcedStyle: ruby19
73
+
74
+ # Prefer double quotes for consistency
75
+ Style/StringLiterals:
76
+ EnforcedStyle: double_quotes
77
+
78
+ # Allow both single and double quotes in specs
79
+ Style/StringLiteralsInInterpolation:
80
+ EnforcedStyle: double_quotes
81
+
82
+ # Prefer symbols as hash keys
83
+ Style/SymbolArray:
84
+ EnforcedStyle: brackets
85
+
86
+ # Allow compact module/class definition
87
+ Style/ClassAndModuleChildren:
88
+ Enabled: false
89
+
90
+ # Allow both proc and lambda
91
+ Style/Lambda:
92
+ Enabled: false
93
+
94
+ # Allow if/unless modifiers
95
+ Style/IfUnlessModifier:
96
+ Enabled: true
97
+
98
+ # Prefer raise over fail
99
+ Style/SignalException:
100
+ EnforcedStyle: only_raise
101
+
102
+ # Allow compact empty methods
103
+ Style/EmptyMethod:
104
+ EnforcedStyle: compact
105
+
106
+ # Prefer explicit returns in some cases
107
+ Style/RedundantReturn:
108
+ Enabled: false
109
+
110
+ # Don't enforce attr_reader for method definitions in blocks
111
+ Style/TrivialAccessors:
112
+ Enabled: false
113
+
114
+ # RSpec specific cops
115
+ RSpec/ExampleLength:
116
+ Max: 25
117
+
118
+ RSpec/MultipleExpectations:
119
+ Max: 5
120
+
121
+ RSpec/NestedGroups:
122
+ Max: 5
123
+
124
+ RSpec/DescribeClass:
125
+ Exclude:
126
+ - 'spec/integration/**/*'
127
+ - 'spec/ruborg/auto_init_spec.rb'
128
+ - 'spec/ruborg/backup_integration_spec.rb'
129
+ - 'spec/ruborg/log_config_spec.rb'
130
+ - 'spec/ruborg/per_file_backup_spec.rb'
131
+ - 'spec/ruborg/security_spec.rb'
132
+
133
+ # Allow any_instance_of for testing
134
+ RSpec/AnyInstance:
135
+ Enabled: false
136
+
137
+ # Allow both expect and allow for message expectations
138
+ RSpec/MessageSpies:
139
+ Enabled: false
140
+
141
+ # Allow both expect and allow
142
+ RSpec/StubbedMock:
143
+ Enabled: false
144
+
145
+ # Allow normal doubles in specs
146
+ RSpec/VerifiedDoubles:
147
+ Enabled: false
148
+
149
+ # Allow multiple memoized helpers
150
+ RSpec/MultipleMemoizedHelpers:
151
+ Enabled: false
152
+
153
+ # Allow backticks for command execution
154
+ Style/CommandLiteral:
155
+ Enabled: false
156
+
157
+ # Allow safe navigation chains
158
+ Style/SafeNavigationChainLength:
159
+ Enabled: false
160
+
161
+ # Allow useless constant scoping for clarity
162
+ Lint/UselessConstantScoping:
163
+ Enabled: false
164
+
165
+ # Allow get_ prefix in method names for clarity
166
+ Naming/AccessorMethodName:
167
+ Enabled: false
168
+
169
+ # Allow predicate methods without ? suffix
170
+ Naming/PredicateMethod:
171
+ Enabled: false
172
+
173
+ # Allow any spec file path format
174
+ RSpec/SpecFilePathFormat:
175
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -7,6 +7,58 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.0] - 2025-10-06
11
+
12
+ ### Added
13
+ - Borg executable validation: verifies `borg_path` points to actual Borg binary
14
+ - bundler-audit integration for dependency vulnerability scanning
15
+ - RuboCop with rubocop-rspec for code quality enforcement
16
+ - Enhanced pruning logs showing retention mode (standard vs per-file)
17
+ - Comprehensive development workflow documentation in CLAUDE.md
18
+ - Example configuration file: `ruborg.yml.example`
19
+
20
+ ### Security
21
+ - **CRITICAL**: Fixed remaining command injection vulnerabilities in repository.rb
22
+ - Replaced backtick execution with Open3.capture3 in `list_archives_with_metadata`
23
+ - Replaced backtick execution with Open3.capture3 in `get_file_mtime_from_archive`
24
+ - Replaced backtick execution with Open3.capture2e in `execute_version_command`
25
+ - Added borg_path validation to prevent execution of arbitrary binaries
26
+ - Removed unused `env_to_cmd_prefix` helper method (no longer needed with Open3)
27
+ - Updated SECURITY.md with new security features and best practices
28
+ - Added config file permission requirements (chmod 600) to documentation
29
+ - Zero known vulnerabilities in dependencies (verified with bundler-audit)
30
+
31
+ ### Changed
32
+ - All command execution now uses Open3 methods (no backticks anywhere)
33
+ - Pruning logs now include retention mode details
34
+ - Enhanced security documentation with detailed config file protection guidelines
35
+
36
+ ## [0.3.1] - 2025-10-05
37
+
38
+ ### Added
39
+ - `borg_options` configuration for controlling Borg environment variables
40
+ - Repository path validation to prevent creation in system directories
41
+ - Backup path validation and normalization
42
+ - Archive name sanitization (alphanumeric, dash, underscore, dot only)
43
+
44
+ ### Changed
45
+ - Borg environment variables now configurable via `borg_options` (backward compatible)
46
+ - All backup paths are now normalized to absolute paths
47
+ - Custom archive names are automatically sanitized
48
+
49
+ ### Security
50
+ - Fixed command injection vulnerability in Passbolt CLI execution (now uses Open3.capture3)
51
+ - Added path traversal protection for extract operations
52
+ - Implemented symlink resolution and system path protection for --remove-source
53
+ - Changed to YAML.safe_load_file to prevent arbitrary code execution
54
+ - Added log path validation to prevent writing to system directories
55
+ - Added repository path validation (prevents /bin, /etc, /usr, etc.)
56
+ - Added backup path validation (rejects empty/nil paths)
57
+ - Added archive name sanitization (prevents injection attacks)
58
+ - Made Borg environment options configurable for enhanced security
59
+ - Added SECURITY.md with comprehensive security guidelines and best practices
60
+ - Enhanced test coverage for all security features
61
+
10
62
  ## [0.3.0] - 2025-10-05
11
63
 
12
64
  ### Added
data/CLAUDE.md CHANGED
@@ -1 +1,67 @@
1
- - ruborg is a ruby gem to perform backups using borg. it reads a configuration file in yaml and instructs borg about what to do. it is a friendly fornt end of borg in ruby. it can create and access backup repositories. it can take and recall backup files or directories. it can interract with passbolt through cli to access encryption passwords.
1
+ # Ruborg Project
2
+
3
+ ## Overview
4
+ Ruborg is a Ruby gem to perform backups using Borg. It reads a configuration file in YAML and instructs Borg about what to do. It is a friendly frontend of Borg in Ruby. It can create and access backup repositories. It can take and recall backup files or directories. It can interact with Passbolt through CLI to access encryption passwords.
5
+
6
+ ## Development Practices
7
+
8
+ ### Code Quality
9
+ - **RuboCop**: Static code analyzer and formatter configured in `.rubocop.yml`
10
+ - Run: `bundle exec rubocop`
11
+ - Auto-fix: `bundle exec rubocop -a`
12
+ - Target: 0 offenses (currently achieved)
13
+
14
+ - **RuboCop RSpec**: RSpec-specific linting rules
15
+ - Integrated with main RuboCop configuration
16
+ - Enforces consistent test patterns
17
+
18
+ ### Security
19
+ - **bundler-audit**: Checks for known vulnerabilities in dependencies
20
+ - Update database: `bundle exec bundle-audit update`
21
+ - Check vulnerabilities: `bundle exec bundle-audit check`
22
+ - Run regularly as part of CI/CD and before releases
23
+
24
+ - **Security Best Practices**:
25
+ - Use `YAML.safe_load_file` for configuration parsing
26
+ - Use `Open3.capture*` methods instead of backticks for command execution
27
+ - Validate and sanitize all user inputs (archive names, paths)
28
+ - Prevent path traversal with system directory blacklists
29
+ - Use array syntax for system calls to prevent shell injection
30
+
31
+ ### Testing
32
+ - **RSpec**: Test framework for unit and integration tests
33
+ - Run all tests: `bundle exec rspec`
34
+ - Run with documentation: `bundle exec rspec --format documentation`
35
+ - Target: All tests passing (currently 124 examples, 0 failures)
36
+
37
+ - **Test Coverage**:
38
+ - Unit tests for core classes (Repository, Backup, Config)
39
+ - Integration tests for end-to-end workflows
40
+ - Security tests for input validation and path handling
41
+
42
+ ### Development Workflow
43
+ 1. Make code changes
44
+ 2. Run tests: `bundle exec rspec`
45
+ 3. Run linter: `bundle exec rubocop`
46
+ 4. Check security: `bundle exec bundle-audit check`
47
+ 5. Commit changes with descriptive messages
48
+ 6. Open pull request for review
49
+
50
+ ### Project Structure
51
+ - `lib/ruborg/` - Main source code
52
+ - `cli.rb` - Command-line interface (Thor)
53
+ - `repository.rb` - Borg repository management
54
+ - `backup.rb` - Backup operations
55
+ - `config.rb` - YAML configuration handling
56
+ - `passbolt.rb` - Passbolt integration
57
+ - `logger.rb` - Logging functionality
58
+ - `spec/` - RSpec tests
59
+ - `exe/` - Executable scripts
60
+
61
+ ### Key Features
62
+ - **Multi-repository support**: Manage multiple backup repositories from a single config
63
+ - **Per-file backup mode**: Back up each file as a separate archive with metadata-based retention
64
+ - **Passbolt integration**: Retrieve encryption passphrases from Passbolt
65
+ - **Auto-initialization**: Automatically create repositories if they don't exist
66
+ - **Auto-pruning**: Automatically prune old backups based on retention policies
67
+ - **Logging**: Comprehensive logging to file or stdout