rails-health-checker 0.1.0 → 0.2.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 +4 -4
- data/README.md +55 -18
- metadata +25 -69
- data/CHANGELOG.md +0 -37
- data/COMMANDS.md +0 -118
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -222
- data/LICENSE +0 -21
- data/Rakefile +0 -6
- data/SECURITY.md +0 -41
- data/TESTING.md +0 -64
- data/TEST_RESULTS.md +0 -51
- data/example_usage.rb +0 -23
- data/lib/rails_health_checker/checker.rb +0 -88
- data/lib/rails_health_checker/dashboard_middleware.rb +0 -503
- data/lib/rails_health_checker/gem_analyzer.rb +0 -39
- data/lib/rails_health_checker/health_middleware.rb +0 -53
- data/lib/rails_health_checker/job_analyzer.rb +0 -108
- data/lib/rails_health_checker/railtie.rb +0 -11
- data/lib/rails_health_checker/report_generator.rb +0 -499
- data/lib/rails_health_checker/system_analyzer.rb +0 -182
- data/lib/rails_health_checker/tasks.rb +0 -63
- data/lib/rails_health_checker/version.rb +0 -3
- data/lib/rails_health_checker.rb +0 -17
- data/rails_health_checker.gemspec +0 -33
- data/simple_test.rb +0 -52
- data/test_gem.rb +0 -100
data/SECURITY.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Security
|
|
2
|
-
|
|
3
|
-
## Authentication
|
|
4
|
-
|
|
5
|
-
The health dashboard is protected by HTTP Basic Authentication to prevent unauthorized access to sensitive application information.
|
|
6
|
-
|
|
7
|
-
### Default Credentials
|
|
8
|
-
- **Username:** `admin`
|
|
9
|
-
- **Password:** `health123`
|
|
10
|
-
|
|
11
|
-
### Custom Credentials
|
|
12
|
-
Set environment variables to use custom credentials:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
export HEALTH_USERNAME=your_username
|
|
16
|
-
export HEALTH_PASSWORD=your_secure_password
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Security Considerations
|
|
20
|
-
|
|
21
|
-
1. **Change Default Password:** Always change the default password in production
|
|
22
|
-
2. **Use Strong Passwords:** Use complex passwords with mixed characters
|
|
23
|
-
3. **Environment Variables:** Store credentials in environment variables, not in code
|
|
24
|
-
4. **HTTPS Only:** Use HTTPS in production to encrypt authentication headers
|
|
25
|
-
5. **Access Logs:** Monitor access to health endpoints
|
|
26
|
-
|
|
27
|
-
### Endpoints Protected
|
|
28
|
-
|
|
29
|
-
- `/health` - Main health dashboard
|
|
30
|
-
|
|
31
|
-
### What Information is Exposed
|
|
32
|
-
|
|
33
|
-
The health dashboard shows:
|
|
34
|
-
- Rails and Ruby versions
|
|
35
|
-
- Database connection status
|
|
36
|
-
- Gem dependencies and versions
|
|
37
|
-
- Security vulnerabilities (outdated gems)
|
|
38
|
-
- Background job status
|
|
39
|
-
- System configuration details
|
|
40
|
-
|
|
41
|
-
**Note:** This information should only be accessible to authorized personnel.
|
data/TESTING.md
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Testing RailsHealthChecker Gem
|
|
2
|
-
|
|
3
|
-
## 1. Basic Functionality Test
|
|
4
|
-
```bash
|
|
5
|
-
cd rails_health_checker
|
|
6
|
-
ruby simple_test.rb
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## 2. Test in Existing Rails App
|
|
10
|
-
|
|
11
|
-
### Add to Gemfile:
|
|
12
|
-
```ruby
|
|
13
|
-
gem 'rails_health_checker', path: '/path/to/rails_health_checker'
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### Run bundle:
|
|
17
|
-
```bash
|
|
18
|
-
bundle install
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Test rake tasks:
|
|
22
|
-
```bash
|
|
23
|
-
rake health:check
|
|
24
|
-
rake health:gems
|
|
25
|
-
rake health:database
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Test HTTP endpoint:
|
|
29
|
-
```bash
|
|
30
|
-
# Start Rails server
|
|
31
|
-
rails server
|
|
32
|
-
|
|
33
|
-
# Test health endpoint
|
|
34
|
-
curl http://localhost:3000/health
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## 3. Test with FinaSync Project
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
cd /Users/arshdeepsingh/Desktop/personal/PROJECTS/FinaSync/FinaSync-rails
|
|
41
|
-
|
|
42
|
-
# Add gem to Gemfile
|
|
43
|
-
echo "gem 'rails_health_checker', path: '../rails_health_checker'" >> Gemfile
|
|
44
|
-
|
|
45
|
-
# Install
|
|
46
|
-
bundle install
|
|
47
|
-
|
|
48
|
-
# Test
|
|
49
|
-
rake health:check
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## 4. RSpec Tests
|
|
53
|
-
```bash
|
|
54
|
-
cd rails_health_checker
|
|
55
|
-
bundle install
|
|
56
|
-
bundle exec rspec
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Expected Output:
|
|
60
|
-
- ✓ Version information
|
|
61
|
-
- ✓ Rails/Ruby version checks
|
|
62
|
-
- ✓ Database connectivity
|
|
63
|
-
- ✓ Gem dependency analysis
|
|
64
|
-
- ✓ HTTP health endpoint (200 OK)
|
data/TEST_RESULTS.md
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Test Results
|
|
2
|
-
|
|
3
|
-
## ✅ Successfully Tested
|
|
4
|
-
|
|
5
|
-
### 1. Basic Functionality
|
|
6
|
-
- ✓ Gem loads correctly
|
|
7
|
-
- ✓ Version: 0.1.0
|
|
8
|
-
- ✓ Core modules work
|
|
9
|
-
|
|
10
|
-
### 2. Rails Integration (FinaSync Project)
|
|
11
|
-
- ✓ Gem installs in Rails app
|
|
12
|
-
- ✓ Rake tasks work:
|
|
13
|
-
- `rake health:gems` → 93 total gems, 33 outdated
|
|
14
|
-
- `rake health:database` → Database connection healthy
|
|
15
|
-
- `rake health:check` → Complete health report
|
|
16
|
-
|
|
17
|
-
### 3. Health Check Results
|
|
18
|
-
```
|
|
19
|
-
=== Rails Health Check Report ===
|
|
20
|
-
Rails Version: 7.1.5.2 (healthy)
|
|
21
|
-
Ruby Version: 3.0.6 (healthy)
|
|
22
|
-
Database: healthy
|
|
23
|
-
Gems: 93 total, 33 outdated
|
|
24
|
-
Security: needs_attention
|
|
25
|
-
================================
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## How to Test:
|
|
29
|
-
|
|
30
|
-
### Quick Test:
|
|
31
|
-
```bash
|
|
32
|
-
cd rails_health_checker
|
|
33
|
-
ruby simple_test.rb
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Full Rails Test:
|
|
37
|
-
```bash
|
|
38
|
-
# Add to any Rails project Gemfile:
|
|
39
|
-
gem 'rails_health_checker', path: '/path/to/rails_health_checker'
|
|
40
|
-
|
|
41
|
-
# Install and test:
|
|
42
|
-
bundle install
|
|
43
|
-
rake health:check
|
|
44
|
-
rake health:gems
|
|
45
|
-
rake health:database
|
|
46
|
-
|
|
47
|
-
# Test HTTP endpoint:
|
|
48
|
-
curl http://localhost:3000/health
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## ✅ Gem is Ready for Use!
|
data/example_usage.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Example usage in a Rails application
|
|
2
|
-
|
|
3
|
-
# 1. Add to Gemfile:
|
|
4
|
-
# gem 'rails_health_checker'
|
|
5
|
-
|
|
6
|
-
# 2. In your Rails application, you can use:
|
|
7
|
-
|
|
8
|
-
# Run complete health check
|
|
9
|
-
results = RailsHealthChecker.check
|
|
10
|
-
|
|
11
|
-
# Access specific health data
|
|
12
|
-
puts "Rails version: #{results[:rails_version][:current]}"
|
|
13
|
-
puts "Database status: #{results[:database][:status]}"
|
|
14
|
-
puts "Total gems: #{results[:gems][:total]}"
|
|
15
|
-
|
|
16
|
-
# Use rake tasks
|
|
17
|
-
# rake health:check
|
|
18
|
-
# rake health:gems
|
|
19
|
-
# rake health:database
|
|
20
|
-
|
|
21
|
-
# Access health endpoint
|
|
22
|
-
# GET /health
|
|
23
|
-
# Returns JSON with health status
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
module RailsHealthChecker
|
|
2
|
-
class Checker
|
|
3
|
-
def run
|
|
4
|
-
results = {
|
|
5
|
-
rails_version: check_rails_version,
|
|
6
|
-
ruby_version: check_ruby_version,
|
|
7
|
-
database: check_database_connection,
|
|
8
|
-
gems: check_gems_health,
|
|
9
|
-
security: check_security_vulnerabilities,
|
|
10
|
-
jobs: check_background_jobs,
|
|
11
|
-
system: check_system_details
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
generate_report(results)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def check_rails_version
|
|
20
|
-
{
|
|
21
|
-
current: Rails.version,
|
|
22
|
-
supported: rails_version_supported?,
|
|
23
|
-
status: rails_version_supported? ? "healthy" : "outdated"
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def check_ruby_version
|
|
28
|
-
{
|
|
29
|
-
current: RUBY_VERSION,
|
|
30
|
-
supported: ruby_version_supported?,
|
|
31
|
-
status: ruby_version_supported? ? "healthy" : "outdated"
|
|
32
|
-
}
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def check_database_connection
|
|
36
|
-
ActiveRecord::Base.connection.active?
|
|
37
|
-
{ status: "healthy", connected: true }
|
|
38
|
-
rescue => e
|
|
39
|
-
{ status: "unhealthy", connected: false, error: e.message }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def check_gems_health
|
|
43
|
-
GemAnalyzer.new.analyze
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def check_security_vulnerabilities
|
|
47
|
-
outdated_gems = `bundle outdated --parseable`.split("\n")
|
|
48
|
-
{
|
|
49
|
-
outdated_count: outdated_gems.length,
|
|
50
|
-
status: outdated_gems.empty? ? "secure" : "needs_attention"
|
|
51
|
-
}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def check_background_jobs
|
|
55
|
-
JobAnalyzer.new.analyze
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def check_system_details
|
|
59
|
-
SystemAnalyzer.new.analyze
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def rails_version_supported?
|
|
63
|
-
Rails.version >= "6.0"
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def ruby_version_supported?
|
|
67
|
-
RUBY_VERSION >= "2.7"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def generate_report(results)
|
|
71
|
-
puts "\n=== Rails Health Check Report ==="
|
|
72
|
-
puts "Rails Version: #{results[:rails_version][:current]} (#{results[:rails_version][:status]})"
|
|
73
|
-
puts "Ruby Version: #{results[:ruby_version][:current]} (#{results[:ruby_version][:status]})"
|
|
74
|
-
puts "Database: #{results[:database][:status]}"
|
|
75
|
-
puts "Gems: #{results[:gems][:total]} total, #{results[:gems][:outdated]} outdated"
|
|
76
|
-
puts "Security: #{results[:security][:status]}"
|
|
77
|
-
puts "Background Jobs: #{results[:jobs][:status]}"
|
|
78
|
-
puts "================================\n"
|
|
79
|
-
|
|
80
|
-
# Generate markdown report
|
|
81
|
-
report_generator = ReportGenerator.new(results)
|
|
82
|
-
filename = report_generator.save_to_file
|
|
83
|
-
puts "📄 Detailed report saved to: #{filename} (previous report replaced)"
|
|
84
|
-
|
|
85
|
-
results
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|