Skip to content

Commit

Permalink
Merge pull request #14 from ATIX-AG/add_errata_json_statistics_tool
Browse files Browse the repository at this point in the history
Add analyzer.rb to get some statistics on an errata JSON
  • Loading branch information
m-bucher authored Nov 4, 2024
2 parents 9fb56df + a3241d4 commit 4013ca2
Show file tree
Hide file tree
Showing 19 changed files with 1,132 additions and 4 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: rubocop Linting
on:
pull_request:
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libapt-pkg-dev
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler-cache: true
- name: Setup rubocop
run: |
bundle install --with=rubocop
- name: Execute rubocop
run: |
bundle exec rubocop
26 changes: 26 additions & 0 deletions .github/workflows/spec_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Spec Tests
on:
pull_request:
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libapt-pkg-dev
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler-cache: true
- name: Setup bundle
run: |
bundle install --with=test
- name: Run rspec
run: |
bundle exec rspec
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,3 @@ jobs:
- name: Run tests
run: |
bundle exec ruby test/all.rb
- name: Execute rubocop
run: |
bundle exec rubocop
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ debian_config.json
debian_errata.json
ubuntu_config.json
ubuntu_errata.json
coverage/
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
12 changes: 12 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ AllCops:
TargetRubyVersion: 3.3
NewCops: enable

require:
- rubocop-rspec

Layout/LineLength:
Max: 159

Expand Down Expand Up @@ -37,6 +40,15 @@ Metrics/PerceivedComplexity:
Max: 25


RSpec/MultipleDescribes:
Exclude:
- 'spec/lib/deb_erratum_rss_spec.rb'


Style/BlockComments:
Exclude:
- 'spec/spec_helper.rb'

Style/ClassVars:
Exclude:
- 'debRelease.rb'
Expand Down
16 changes: 16 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,30 @@ gem "bzip2-ffi", "~> 1.0", group: %i[build test]
# Added at 2018-09-07 16:41:14 +0200 by markus:
gem "test-unit", "~> 3.5", group: [:test]

gem "rspec", "~> 3.13", group: :test

gem "simplecov-lcov", "~> 0.8.0", group: :test

gem "simplecov", "~> 0.22.0", group: :test

gem "rspec-collection_matchers", "~> 1.2", group: :test

# Added at 2021-11-12 17:19:23 +0200 by bernhard:
gem 'parallel', '~> 1.20', '< 1.21', group: %i[build test]

# Added at 2018-12-05 19:28:10 +0100 by markus:
group :rubocop, optional: true do
gem "rubocop", "~> 1.51.0"
gem "rubocop-rspec", "~> 3.0"
end

gem "json-streamer", "~> 2.1"

group :development, optional: true do
gem "byebug", "~> 11.1"
gem "pry", "~> 0.14.2"
end

gem "feedjira", "~> 3.2", group: :monitor

gem "faraday", "~> 2.12", group: :monitor
65 changes: 64 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,60 @@ GEM
byebug (11.1.3)
bzip2-ffi (1.1.1)
ffi (~> 1.0)
ffi (1.17.0-x86_64-linux-gnu)
coderay (1.1.3)
crass (1.0.6)
diff-lcs (1.5.1)
docile (1.4.1)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-net_http (3.3.0)
net-http
feedjira (3.2.3)
loofah (>= 2.3.1, < 3)
sax-machine (>= 1.0, < 2)
ffi (1.17.0)
json (2.7.2)
json-stream (1.0.0)
json-streamer (2.1.0)
json-stream
logger (1.6.1)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
method_source (1.1.0)
net-http (0.4.1)
uri
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
parallel (1.20.1)
parser (3.3.3.0)
ast (~> 2.4.1)
racc
power_assert (2.0.3)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.8.0)
rainbow (3.1.1)
regexp_parser (2.9.2)
rexml (3.3.9)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-collection_matchers (1.2.1)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.51.0)
json (~> 2.3)
parallel (~> 1.10)
Expand All @@ -28,23 +71,43 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-rspec (3.0.0)
rubocop (~> 1.40)
ruby-debian (0.3.8)
ruby-progressbar (1.13.0)
ruby-xz (1.0.3)
sax-machine (1.3.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
test-unit (3.6.2)
power_assert
unicode-display_width (2.5.0)
uri (0.13.1)

PLATFORMS
x86_64-linux

DEPENDENCIES
byebug (~> 11.1)
bzip2-ffi (~> 1.0)
faraday (~> 2.12)
feedjira (~> 3.2)
json-streamer (~> 2.1)
parallel (~> 1.20, < 1.21)
pry (~> 0.14.2)
rspec (~> 3.13)
rspec-collection_matchers (~> 1.2)
rubocop (~> 1.51.0)
rubocop-rspec (~> 3.0)
ruby-debian (~> 0.3.8)
ruby-xz (~> 1.0)
simplecov (~> 0.22.0)
simplecov-lcov (~> 0.8.0)
test-unit (~> 3.5)

BUNDLED WITH
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,18 @@ The `<ubuntu_dict>` is somewhat simpler than that for Debian:

A single USN URL will suffice as an upstream source of information.
`whitelists` and `aliases` are structurally identical to those for Debian.


## Analyze created JSON files

To have an idea about how many errata and also how many packages per errata on avarage were created the following tool can be used:

bundle exec analyzer.rb <errata-json>

It is also possible now to check if the latest security-notices that can be found on the RSS-feeds are already part of the errata-file.
The `check_latest_errata.rb` command returns a nagios-compliant output and return-code.

This requires the `monitor` gem-group to be installed by bundler

bundle config set with 'monitor'
bundle
18 changes: 18 additions & 0 deletions analyzer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env ruby

# frozen_string_literal: true

require_relative 'lib/errata_statistics'

output_type = nil

output_type = ARGV.shift.slice(2..).to_sym if ARGV[0].start_with? '--'

stats = ErrataStatistics.new ARGV[0]
stats.calculate

case output_type
when :yaml then puts stats.to_yaml
when :json then puts stats.to_json
else stats.print_all
end
Loading

0 comments on commit 4013ca2

Please sign in to comment.