internet_security_event 1.1.0 → 2.0.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: 2d93be47b6e84cb8d7e40c2f604732ee48ba6582235253710dd473e0634099c1
4
- data.tar.gz: b58978d3f62628a1239a03e60438ca5f516f19ac59ff6946987c4541080b90ca
3
+ metadata.gz: 96f9a7ff480196b6577e3d641424234b389a047b9c96c4f3984d8eabc1def59b
4
+ data.tar.gz: 194a8f754e108ac4abc3caec23711da90744aedc9afd0709e138f513ae07d840
5
5
  SHA512:
6
- metadata.gz: c936050537ef4665d970fea58906b3c1de303a80abe73a082a09040801ebfda12c0826d055c89345591c7844472c82bfb8ccce01bed48dd79618f3a89b78f2e5
7
- data.tar.gz: e03ee5ccf138e9d4a9bc6534dcfa3987f631fca669ed1cf0f450d159536c88a43405de338abb71508abb8297f05689818b7ace1abcab97238f6122ecf2519c86
6
+ metadata.gz: 225eb6c94b4d3888546451f3676dd243e52b5587cce800fa1da10638f0b0c202bd2365bc6091419c63e5a6e406f55ba34d1b94e103911ce071e1bf7f301627e8
7
+ data.tar.gz: 669d9be990c119395fb67b76db876f94319693a3379d9e9a28442f5cb30498a93510f5b1142f83d47fca0bc7e3ae34d6df7c8a52b81394d37ac957afd315045d
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ schedule:
11
+ - cron: "0 17 * * *"
12
+
13
+ jobs:
14
+ rubocop:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Setup ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: 3.0
22
+ bundler-cache: true
23
+ - name: Run static code analysis
24
+ run: bundle exec rubocop
25
+ unit:
26
+ runs-on: ubuntu-latest
27
+ needs: rubocop
28
+ strategy:
29
+ matrix:
30
+ ruby:
31
+ - "2.6"
32
+ - "2.7"
33
+ - "3.0"
34
+ - "3.1"
35
+ name: Ruby ${{ matrix.ruby }}
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+ - name: Setup ruby
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby }}
42
+ bundler-cache: true
43
+ - name: Run tests without uploading code coverage
44
+ if: ${{ matrix.ruby != '3.0' }}
45
+ run: bundle exec rake
46
+ - name: Run tests and upload coverage to Code Climate
47
+ if: ${{ matrix.ruby == '3.0' }}
48
+ uses: paambaati/codeclimate-action@v3.0.0
49
+ env:
50
+ CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }}
51
+ with:
52
+ coverageCommand: bundle exec rake
data/.rubocop.yml ADDED
@@ -0,0 +1,25 @@
1
+ AllCops:
2
+ AllowSymlinksInCacheRootDirectory: true
3
+
4
+ require:
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
8
+ Layout/HashAlignment:
9
+ EnforcedColonStyle: table
10
+ EnforcedHashRocketStyle: table
11
+
12
+ Metrics/LineLength:
13
+ Max: 160
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Style/TrailingCommaInArrayLiteral:
19
+ EnforcedStyleForMultiline: comma
20
+
21
+ Style/TrailingCommaInHashLiteral:
22
+ EnforcedStyleForMultiline: comma
23
+
24
+ Style/TrailingCommaInArguments:
25
+ EnforcedStyleForMultiline: comma
data/CHANGELOG.md CHANGED
@@ -1,24 +1,48 @@
1
1
  # Changelog
2
- All notable changes to this project will be documented in this file.
3
2
 
4
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3
+ ## [v2.0.0](https://github.com/smortex/internet_security_event/tree/v2.0.0) (2022-07-16)
4
+
5
+ [Full Changelog](https://github.com/smortex/internet_security_event/compare/v1.2.1...v2.0.0)
6
+
7
+ **Breaking changes:**
8
+
9
+ - Bump activesupport to 6.x [\#2](https://github.com/smortex/internet_security_event/pull/2) ([smortex](https://github.com/smortex))
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Integrate github\_changelog\_generator [\#1](https://github.com/smortex/internet_security_event/pull/1) ([smortex](https://github.com/smortex))
14
+
15
+ ## [v1.2.1] - 2022-07-15
16
+
17
+ ### Changed
18
+ - Emit a `warning` state instead of a `warn` state to match Riemann wording.
19
+
20
+ ## [v1.2.0] - 2019-02-28
21
+
22
+ ### Changed
23
+ - Rely on `OpenSSL::SSL.verify_certificate_identity` to check that a certificate
24
+ is valid for the provided hostname.
25
+
26
+ ## [v1.1.0] - 2019-02-21
6
27
 
7
- ## [1.1.0] - 2019-02-21
8
28
  ### Added
9
29
  - Add basic suport for TLSA events.
10
30
 
11
- ## [1.0.2] - 2019-02-21
31
+ ## [v1.0.2] - 2019-02-21
12
32
 
13
33
  ### Changed
14
34
  - Fix checking of TLS hostnames with wildcard certificates.
15
35
 
16
- ## [1.0.1] - 2019-02-18
36
+ ## [v1.0.1] - 2019-02-18
17
37
 
18
38
  ### Changed
19
39
  - Improve the way TLS certificates state is computed.
20
40
 
21
- [Unreleased]: https://github.com/smortex/internet_security_event/compare/v1.1.0...HEAD
22
- [1.1.0]: https://github.com/smortex/internet_security_event/compare/v1.0.2...v1.1.0
23
- [1.0.2]: https://github.com/smortex/internet_security_event/compare/v1.0.1...v1.0.2
24
- [1.0.1]: https://github.com/smortex/internet_security_event/compare/v1.0.0...v1.0.1
41
+ [v1.2.1]: https://github.com/smortex/internet_security_event/compare/v1.2.0...v1.2.1
42
+ [v1.2.0]: https://github.com/smortex/internet_security_event/compare/v1.1.0...v1.2.0
43
+ [v1.1.0]: https://github.com/smortex/internet_security_event/compare/v1.0.2...v1.1.0
44
+ [v1.0.2]: https://github.com/smortex/internet_security_event/compare/v1.0.1...v1.0.2
45
+ [v1.0.1]: https://github.com/smortex/internet_security_event/compare/v1.0.0...v1.0.1
46
+
47
+
48
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/HISTORY.md ADDED
@@ -0,0 +1,31 @@
1
+ ## [v1.2.1] - 2022-07-15
2
+
3
+ ### Changed
4
+ - Emit a `warning` state instead of a `warn` state to match Riemann wording.
5
+
6
+ ## [v1.2.0] - 2019-02-28
7
+
8
+ ### Changed
9
+ - Rely on `OpenSSL::SSL.verify_certificate_identity` to check that a certificate
10
+ is valid for the provided hostname.
11
+
12
+ ## [v1.1.0] - 2019-02-21
13
+
14
+ ### Added
15
+ - Add basic suport for TLSA events.
16
+
17
+ ## [v1.0.2] - 2019-02-21
18
+
19
+ ### Changed
20
+ - Fix checking of TLS hostnames with wildcard certificates.
21
+
22
+ ## [v1.0.1] - 2019-02-18
23
+
24
+ ### Changed
25
+ - Improve the way TLS certificates state is computed.
26
+
27
+ [v1.2.1]: https://github.com/smortex/internet_security_event/compare/v1.2.0...v1.2.1
28
+ [v1.2.0]: https://github.com/smortex/internet_security_event/compare/v1.1.0...v1.2.0
29
+ [v1.1.0]: https://github.com/smortex/internet_security_event/compare/v1.0.2...v1.1.0
30
+ [v1.0.2]: https://github.com/smortex/internet_security_event/compare/v1.0.1...v1.0.2
31
+ [v1.0.1]: https://github.com/smortex/internet_security_event/compare/v1.0.0...v1.0.1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # InternetSecurityEvent
2
2
 
3
- [![Build Status](https://travis-ci.com/smortex/internet_security_event.svg?branch=master)](https://travis-ci.com/smortex/internet_security_event)
3
+ [![Build Status](https://github.com/smortex/internet_security_event/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/smortex/internet_security_event/actions/workflows/ci.yml)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/bc64fb4f1c1088c15b8c/maintainability)](https://codeclimate.com/github/smortex/internet_security_event/maintainability)
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/bc64fb4f1c1088c15b8c/test_coverage)](https://codeclimate.com/github/smortex/internet_security_event/test_coverage)
6
6
 
@@ -38,7 +38,7 @@ certificate = OpenSSL::X509::Certificate.new(...)
38
38
 
39
39
  event = InternetSecurityEvent::X509Status.build(certificate)
40
40
 
41
- event[:state] #=> 'ok', 'warn', 'critical'
41
+ event[:state] #=> 'ok', 'warning', 'critical'
42
42
  event[:description] #=> Human readable state
43
43
  event[:metric] #=> an optional Float
44
44
  ```
@@ -81,4 +81,4 @@ License](https://opensource.org/licenses/MIT).
81
81
 
82
82
  Everyone interacting in the InternetSecurityEvent project’s codebases, issue
83
83
  trackers, chat rooms and mailing lists is expected to follow the [code of
84
- conduct](https://github.com/smortex/internet_security_event/blob/master/CODE_OF_CONDUCT.md).
84
+ conduct](https://github.com/smortex/internet_security_event/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,8 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
+ require 'github_changelog_generator/task'
4
5
  require 'rspec/core/rake_task'
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
7
8
 
9
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
10
+ config.user = 'smortex'
11
+ config.project = 'internet_security_event'
12
+ config.since_tag = 'v1.2.1'
13
+ require 'internet_security_event/version'
14
+ config.future_release = "v#{InternetSecurityEvent::VERSION}"
15
+ end
16
+
8
17
  task default: :spec
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.summary = 'Build events describing the status of various internet services'
14
14
  spec.homepage = 'https://github.com/smortex/internet_security_event'
15
15
  spec.license = 'MIT'
16
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
16
17
 
17
18
  # Specify which files should be added to the gem when it is released.
18
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -23,11 +24,14 @@ Gem::Specification.new do |spec|
23
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
25
  spec.require_paths = ['lib']
25
26
 
26
- spec.add_dependency 'actionview', '~> 5.2'
27
- spec.add_dependency 'activesupport', '~> 5.2'
27
+ spec.add_dependency 'activesupport', '~> 6.0'
28
28
 
29
29
  spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'github_changelog_generator'
30
31
  spec.add_development_dependency 'rake'
31
32
  spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency 'rubocop'
34
+ spec.add_development_dependency 'rubocop-rake'
35
+ spec.add_development_dependency 'rubocop-rspec'
32
36
  spec.add_development_dependency 'simplecov'
33
37
  end
@@ -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
- hostname_match_subject? || hostname_match_subject_alternative_name?
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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InternetSecurityEvent
4
- VERSION = '1.1.0'
4
+ VERSION = '2.0.0'
5
5
  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)
@@ -19,7 +15,7 @@ module InternetSecurityEvent
19
15
  obj.to_e
20
16
  end
21
17
 
22
- def to_e
18
+ def to_e # rubocop:disable Metrics/AbcSize
23
19
  {
24
20
  state: state,
25
21
  description: description,
@@ -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
@@ -45,7 +45,7 @@ module InternetSecurityEvent
45
45
  if not_valid_yet? || expired_or_expire_soon?
46
46
  'critical'
47
47
  elsif expire_soonish?
48
- 'warn'
48
+ 'warning'
49
49
  else
50
50
  'ok'
51
51
  end
@@ -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,29 @@ 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) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 minute', distance_in_minutes)
90
+ when 45...1440 then pluralize_string('about %d hour', (distance_in_minutes.to_f / 60.0).round)
91
+ # 24 hours up to 30 days
92
+ when 1440...43_200 then pluralize_string('%d day', (distance_in_minutes.to_f / 1440.0).round)
93
+ # 30 days up to 60 days
94
+ when 43_200...86_400 then pluralize_string('about %d month', (distance_in_minutes.to_f / 43_200.0).round)
95
+ # 60 days up to 365 days
96
+ when 86_400...525_600 then pluralize_string('%d month', (distance_in_minutes.to_f / 43_200.0).round)
97
+ else
98
+ pluralize_string('about %d year', (distance_in_minutes.to_f / 525_600.0).round)
99
+ end
100
+ end
101
+
102
+ def pluralize_string(string, number)
103
+ format(string, number) + (number == 1 ? '' : 's')
104
+ end
85
105
  end
86
106
  end
metadata CHANGED
@@ -1,45 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: internet_security_event
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain Tartière
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-22 00:00:00.000000000 Z
11
+ date: 2022-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: actionview
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.2'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.2'
34
- type: :runtime
33
+ version: '0'
34
+ type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5.2'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: github_changelog_generator
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -80,6 +80,48 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: simplecov
85
127
  requirement: !ruby/object:Gem::Requirement
@@ -94,19 +136,21 @@ dependencies:
94
136
  - - ">="
95
137
  - !ruby/object:Gem::Version
96
138
  version: '0'
97
- description:
139
+ description:
98
140
  email:
99
141
  - romain@blogreen.org
100
142
  executables: []
101
143
  extensions: []
102
144
  extra_rdoc_files: []
103
145
  files:
146
+ - ".github/workflows/ci.yml"
104
147
  - ".gitignore"
105
148
  - ".rspec"
106
- - ".travis.yml"
149
+ - ".rubocop.yml"
107
150
  - CHANGELOG.md
108
151
  - CODE_OF_CONDUCT.md
109
152
  - Gemfile
153
+ - HISTORY.md
110
154
  - LICENSE.txt
111
155
  - README.md
112
156
  - Rakefile
@@ -124,7 +168,7 @@ homepage: https://github.com/smortex/internet_security_event
124
168
  licenses:
125
169
  - MIT
126
170
  metadata: {}
127
- post_install_message:
171
+ post_install_message:
128
172
  rdoc_options: []
129
173
  require_paths:
130
174
  - lib
@@ -132,16 +176,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
176
  requirements:
133
177
  - - ">="
134
178
  - !ruby/object:Gem::Version
135
- version: '0'
179
+ version: 2.6.0
136
180
  required_rubygems_version: !ruby/object:Gem::Requirement
137
181
  requirements:
138
182
  - - ">="
139
183
  - !ruby/object:Gem::Version
140
184
  version: '0'
141
185
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.7.8
144
- signing_key:
186
+ rubygems_version: 3.3.17
187
+ signing_key:
145
188
  specification_version: 4
146
189
  summary: Build events describing the status of various internet services
147
190
  test_files: []
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- ---
2
- language: ruby
3
- rvm:
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- before_script:
8
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
9
- - chmod +x ./cc-test-reporter
10
- - ./cc-test-reporter before-build
11
- after_script:
12
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT