hedra 1.0.0 → 2.0.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/LICENSE +1 -1
- data/README.md +374 -213
- data/config/example_config.yml +88 -10
- data/lib/hedra/analyzer.rb +10 -2
- data/lib/hedra/baseline.rb +83 -0
- data/lib/hedra/cache.rb +67 -0
- data/lib/hedra/certificate_checker.rb +94 -0
- data/lib/hedra/circuit_breaker.rb +80 -0
- data/lib/hedra/cli.rb +232 -16
- data/lib/hedra/config.rb +1 -1
- data/lib/hedra/exporter.rb +7 -0
- data/lib/hedra/html_reporter.rb +136 -0
- data/lib/hedra/http_client.rb +46 -9
- data/lib/hedra/progress_tracker.rb +45 -0
- data/lib/hedra/rate_limiter.rb +60 -0
- data/lib/hedra/security_txt_checker.rb +93 -0
- data/lib/hedra/version.rb +1 -1
- data/lib/hedra.rb +17 -9
- metadata +13 -5
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hedra
|
|
4
|
+
# Check for security.txt file (RFC 9116)
|
|
5
|
+
class SecurityTxtChecker
|
|
6
|
+
SECURITY_TXT_PATHS = [
|
|
7
|
+
'/.well-known/security.txt',
|
|
8
|
+
'/security.txt'
|
|
9
|
+
].freeze
|
|
10
|
+
|
|
11
|
+
def check(url, http_client)
|
|
12
|
+
uri = URI.parse(url)
|
|
13
|
+
base_url = "#{uri.scheme}://#{uri.host}#{":#{uri.port}" if uri.port && ![80, 443].include?(uri.port)}"
|
|
14
|
+
|
|
15
|
+
findings = []
|
|
16
|
+
found = false
|
|
17
|
+
|
|
18
|
+
SECURITY_TXT_PATHS.each do |path|
|
|
19
|
+
response = http_client.get("#{base_url}#{path}")
|
|
20
|
+
if response.status.success?
|
|
21
|
+
found = true
|
|
22
|
+
findings.concat(validate_security_txt(response.body.to_s))
|
|
23
|
+
break
|
|
24
|
+
end
|
|
25
|
+
rescue StandardError
|
|
26
|
+
# Continue to next path
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
unless found
|
|
30
|
+
findings << {
|
|
31
|
+
header: 'security.txt',
|
|
32
|
+
issue: 'security.txt file not found',
|
|
33
|
+
severity: :info,
|
|
34
|
+
recommended_fix: 'Add security.txt file at /.well-known/security.txt'
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
findings
|
|
39
|
+
rescue StandardError => e
|
|
40
|
+
warn "security.txt check failed: #{e.message}"
|
|
41
|
+
[]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def validate_security_txt(content)
|
|
47
|
+
findings = []
|
|
48
|
+
required_fields = %w[Contact]
|
|
49
|
+
recommended_fields = %w[Expires]
|
|
50
|
+
|
|
51
|
+
required_fields.each do |field|
|
|
52
|
+
next if content.match?(/^#{field}:/i)
|
|
53
|
+
|
|
54
|
+
findings << {
|
|
55
|
+
header: 'security.txt',
|
|
56
|
+
issue: "Missing required field: #{field}",
|
|
57
|
+
severity: :warning,
|
|
58
|
+
recommended_fix: "Add #{field} field to security.txt"
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
recommended_fields.each do |field|
|
|
63
|
+
next if content.match?(/^#{field}:/i)
|
|
64
|
+
|
|
65
|
+
findings << {
|
|
66
|
+
header: 'security.txt',
|
|
67
|
+
issue: "Missing recommended field: #{field}",
|
|
68
|
+
severity: :info,
|
|
69
|
+
recommended_fix: "Consider adding #{field} field to security.txt"
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Check expiry
|
|
74
|
+
if content =~ /^Expires:\s*(.+)$/i
|
|
75
|
+
begin
|
|
76
|
+
expiry = Time.parse(::Regexp.last_match(1))
|
|
77
|
+
if expiry < Time.now
|
|
78
|
+
findings << {
|
|
79
|
+
header: 'security.txt',
|
|
80
|
+
issue: 'security.txt has expired',
|
|
81
|
+
severity: :warning,
|
|
82
|
+
recommended_fix: 'Update Expires field in security.txt'
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
rescue StandardError
|
|
86
|
+
# Invalid date format
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
findings
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
data/lib/hedra/version.rb
CHANGED
data/lib/hedra.rb
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative 'hedra/version'
|
|
4
|
-
require_relative 'hedra/cli'
|
|
5
|
-
require_relative 'hedra/analyzer'
|
|
6
|
-
require_relative 'hedra/http_client'
|
|
7
|
-
require_relative 'hedra/config'
|
|
8
|
-
require_relative 'hedra/plugin_manager'
|
|
9
|
-
require_relative 'hedra/exporter'
|
|
10
|
-
require_relative 'hedra/scorer'
|
|
11
|
-
|
|
12
3
|
module Hedra
|
|
13
4
|
class Error < StandardError; end
|
|
14
5
|
class NetworkError < Error; end
|
|
15
6
|
class ConfigError < Error; end
|
|
16
7
|
end
|
|
8
|
+
|
|
9
|
+
require_relative 'hedra/version'
|
|
10
|
+
require_relative 'hedra/config'
|
|
11
|
+
require_relative 'hedra/scorer'
|
|
12
|
+
require_relative 'hedra/circuit_breaker'
|
|
13
|
+
require_relative 'hedra/certificate_checker'
|
|
14
|
+
require_relative 'hedra/cache'
|
|
15
|
+
require_relative 'hedra/security_txt_checker'
|
|
16
|
+
require_relative 'hedra/progress_tracker'
|
|
17
|
+
require_relative 'hedra/baseline'
|
|
18
|
+
require_relative 'hedra/rate_limiter'
|
|
19
|
+
require_relative 'hedra/http_client'
|
|
20
|
+
require_relative 'hedra/plugin_manager'
|
|
21
|
+
require_relative 'hedra/exporter'
|
|
22
|
+
require_relative 'hedra/html_reporter'
|
|
23
|
+
require_relative 'hedra/analyzer'
|
|
24
|
+
require_relative 'hedra/cli'
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hedra
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- BlackStack
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-11-
|
|
10
|
+
date: 2025-11-19 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: concurrent-ruby
|
|
@@ -96,7 +96,7 @@ dependencies:
|
|
|
96
96
|
description: A comprehensive security header analyzer with scanning, auditing, and
|
|
97
97
|
monitoring capabilities
|
|
98
98
|
email:
|
|
99
|
-
-
|
|
99
|
+
- info@blackstack.com
|
|
100
100
|
executables:
|
|
101
101
|
- hedra
|
|
102
102
|
extensions: []
|
|
@@ -109,14 +109,22 @@ files:
|
|
|
109
109
|
- config/example_rules.yml
|
|
110
110
|
- lib/hedra.rb
|
|
111
111
|
- lib/hedra/analyzer.rb
|
|
112
|
+
- lib/hedra/baseline.rb
|
|
113
|
+
- lib/hedra/cache.rb
|
|
114
|
+
- lib/hedra/certificate_checker.rb
|
|
115
|
+
- lib/hedra/circuit_breaker.rb
|
|
112
116
|
- lib/hedra/cli.rb
|
|
113
117
|
- lib/hedra/config.rb
|
|
114
118
|
- lib/hedra/exporter.rb
|
|
119
|
+
- lib/hedra/html_reporter.rb
|
|
115
120
|
- lib/hedra/http_client.rb
|
|
116
121
|
- lib/hedra/plugin_manager.rb
|
|
122
|
+
- lib/hedra/progress_tracker.rb
|
|
123
|
+
- lib/hedra/rate_limiter.rb
|
|
117
124
|
- lib/hedra/scorer.rb
|
|
125
|
+
- lib/hedra/security_txt_checker.rb
|
|
118
126
|
- lib/hedra/version.rb
|
|
119
|
-
homepage: https://github.com/
|
|
127
|
+
homepage: https://github.com/bl4ckstack/hedra
|
|
120
128
|
licenses:
|
|
121
129
|
- MIT
|
|
122
130
|
metadata:
|