internet_security_event 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6923d00090d3e6b18ace47b442146eedef8dc61a3a25cca68ba4080787db760
|
4
|
+
data.tar.gz: f8d9b8e164285b72fa9905590a389bb522552867d4cd20c435f415f1cb330cb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e92aa02b66c60f44cb10bd4b9d1f0a70a14beb2d101d174ec4d6b2fa34d1952ce37646df26db470ad683541d0aa3fc746e53b61bc71e644b60d5b1de589df415
|
7
|
+
data.tar.gz: ec0d055bd386f1a15692e8f6044510cb4060f8b4bc56b54ebdb85d14376660125516a37840436404239e35a848d90640a7b45974afe07965d0793dbc590b31ee
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
7
|
|
8
|
+
## [1.2.0] - 2019-02-28
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- Rely on `OpenSSL::SSL.verify_certificate_identity` to check that a certificate
|
12
|
+
is valid for the provided hostname.
|
13
|
+
|
7
14
|
## [1.1.0] - 2019-02-21
|
15
|
+
|
8
16
|
### Added
|
9
17
|
- Add basic suport for TLSA events.
|
10
18
|
|
@@ -18,7 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
18
26
|
### Changed
|
19
27
|
- Improve the way TLS certificates state is computed.
|
20
28
|
|
21
|
-
[Unreleased]: https://github.com/smortex/internet_security_event/compare/v1.
|
29
|
+
[Unreleased]: https://github.com/smortex/internet_security_event/compare/v1.2.0...HEAD
|
30
|
+
[1.2.0]: https://github.com/smortex/internet_security_event/compare/v1.1.0...v1.2.0
|
22
31
|
[1.1.0]: https://github.com/smortex/internet_security_event/compare/v1.0.2...v1.1.0
|
23
32
|
[1.0.2]: https://github.com/smortex/internet_security_event/compare/v1.0.1...v1.0.2
|
24
33
|
[1.0.1]: https://github.com/smortex/internet_security_event/compare/v1.0.0...v1.0.1
|
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_dependency 'actionview', '~> 5.2'
|
27
26
|
spec.add_dependency 'activesupport', '~> 5.2'
|
28
27
|
|
29
28
|
spec.add_development_dependency 'bundler'
|
@@ -33,36 +33,7 @@ module InternetSecurityEvent
|
|
33
33
|
def hostname_is_valid_for_this_certificate?
|
34
34
|
return true if hostname.nil?
|
35
35
|
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def hostname_match_subject?
|
40
|
-
name_match_patern(hostname, common_name)
|
41
|
-
end
|
42
|
-
|
43
|
-
def hostname_match_subject_alternative_name?
|
44
|
-
return false unless certificate
|
45
|
-
|
46
|
-
san = certificate.extensions.select { |ext| ext.oid == 'subjectAltName' }.first
|
47
|
-
|
48
|
-
if san
|
49
|
-
alt_names = san.value.split(', ').map { |name| name.sub(/\ADNS:/, '') }
|
50
|
-
return true if alt_names.any? { |alt_name| name_match_patern(hostname, alt_name) }
|
51
|
-
end
|
52
|
-
|
53
|
-
false
|
54
|
-
end
|
55
|
-
|
56
|
-
def name_match_patern(hostname, pattern)
|
57
|
-
re = Regexp.new('\A' + pattern.split('*').map do |st|
|
58
|
-
Regexp.escape(st)
|
59
|
-
end.join('[^.]*') + '\z')
|
60
|
-
|
61
|
-
re.match(hostname)
|
62
|
-
end
|
63
|
-
|
64
|
-
def common_name
|
65
|
-
certificate.subject.to_a.select { |data| data[0] == 'CN' }.map { |data| data[1] }.first if certificate
|
36
|
+
OpenSSL::SSL.verify_certificate_identity(certificate, hostname)
|
66
37
|
end
|
67
38
|
end
|
68
39
|
end
|
@@ -1,13 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'action_view'
|
4
|
-
require 'action_view/helpers'
|
5
3
|
require 'active_support/core_ext/numeric/time'
|
6
4
|
|
7
5
|
module InternetSecurityEvent
|
8
6
|
class X509Status
|
9
|
-
include ActionView::Helpers::DateHelper
|
10
|
-
|
11
7
|
attr_reader :certificate, :hostname
|
12
8
|
|
13
9
|
def initialize(certificate)
|
@@ -32,6 +28,10 @@ module InternetSecurityEvent
|
|
32
28
|
}
|
33
29
|
end
|
34
30
|
|
31
|
+
def renewal_duration
|
32
|
+
[validity_duration / 3, 90.days].min
|
33
|
+
end
|
34
|
+
|
35
35
|
private
|
36
36
|
|
37
37
|
def description
|
@@ -71,10 +71,6 @@ module InternetSecurityEvent
|
|
71
71
|
now + 2 * renewal_duration / 3 > certificate.not_after
|
72
72
|
end
|
73
73
|
|
74
|
-
def renewal_duration
|
75
|
-
[validity_duration / 3, 90.days].min
|
76
|
-
end
|
77
|
-
|
78
74
|
def validity_duration
|
79
75
|
certificate.not_after - certificate.not_before
|
80
76
|
end
|
@@ -82,5 +78,33 @@ module InternetSecurityEvent
|
|
82
78
|
def now
|
83
79
|
Now.instance.now
|
84
80
|
end
|
81
|
+
|
82
|
+
# Stolen from ActionView, to avoid pulling a lot of dependencies
|
83
|
+
def distance_of_time_in_words_to_now(to_time)
|
84
|
+
distance_in_seconds = (to_time - now).round.abs
|
85
|
+
distance_in_minutes = distance_in_seconds / 60
|
86
|
+
|
87
|
+
case distance_in_minutes
|
88
|
+
when 0 then 'less than 1 minute'
|
89
|
+
when 1...45 then pluralize_string('%d %s', distance_in_minutes, 'minute')
|
90
|
+
when 45...1440 then pluralize_string('about %d %s', (distance_in_minutes.to_f / 60.0).round, 'hour')
|
91
|
+
# 24 hours up to 30 days
|
92
|
+
when 1440...43_200 then pluralize_string('%d %s', (distance_in_minutes.to_f / 1440.0).round, 'day')
|
93
|
+
# 30 days up to 60 days
|
94
|
+
when 43_200...86_400 then pluralize_string('about %d %s', (distance_in_minutes.to_f / 43_200.0).round, 'month')
|
95
|
+
# 60 days up to 365 days
|
96
|
+
when 86_400...525_600 then pluralize_string('%d %s', (distance_in_minutes.to_f / 43_200.0).round, 'month')
|
97
|
+
else
|
98
|
+
pluralize_string('about %d %s', (distance_in_minutes.to_f / 525_600.0).round, 'year')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def pluralize_string(string, number, word)
|
103
|
+
format(string, number, pluralize_word(number, word))
|
104
|
+
end
|
105
|
+
|
106
|
+
def pluralize_word(number, word)
|
107
|
+
word + (number.abs == 1 ? '' : 's')
|
108
|
+
end
|
85
109
|
end
|
86
110
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: internet_security_event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain Tartière
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: actionview
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '5.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '5.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: activesupport
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
125
|
- !ruby/object:Gem::Version
|
140
126
|
version: '0'
|
141
127
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.7.8
|
128
|
+
rubygems_version: 3.0.2
|
144
129
|
signing_key:
|
145
130
|
specification_version: 4
|
146
131
|
summary: Build events describing the status of various internet services
|