icat4json 1.0.6 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 434bb4dee92074b3e017c99a2fc4804ac578ff47ce3fbc069266997d93ba7851
4
- data.tar.gz: 31357442c1d87b77a3eabb73ea802d9a98bc37e7bc49b4692903058057266d54
3
+ metadata.gz: c85d6a903ebea3b9c793c9afe4896bdcefe2623d3fdb12ad38caab5d80d0911f
4
+ data.tar.gz: 12e136c7720e1ba168b44cec60242aa0314abbe818e6ffa04909bfcf569aaaa8
5
5
  SHA512:
6
- metadata.gz: 363c88013bde3b1ccca2f7708b3b32300ca4984b6043e0485db1d6b140f3211edc6c37ee8abc3e9a84823ddcb0f46c16d584c8336b753cef2756f5eccb0a22e7
7
- data.tar.gz: 71233622a630170737cf6b1234c3e396f5c5bfec8f8cb9eb092b20a870a5e1121a535c81f3bcbad523bd557e9b56a9c54ad951d8041ff4ad637a7a6e3de1d09a
6
+ metadata.gz: c2e294b7257bfaff1a98631900252be8f903148d43f8d8623a33e95ad5765126968b4bd75c04b247f92685241fe54c6356aa645472c89a9e6e6f6d8c692b9775
7
+ data.tar.gz: c31a4de53e09cdb2a3e85ed1d0a7f106fde2fb85247e6ee19d94db0ca1b1723f45f4b4837c9d0489de4aaed3c19f0f31ec1702be3a23859afaa52b08606e3edf
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in icat4json.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,12 +1,77 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- icat4json (1.0.2)
4
+ icat4json (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ ast (2.4.3)
10
+ date (3.4.1)
11
+ erb (5.0.2)
12
+ io-console (0.8.1)
13
+ irb (1.15.2)
14
+ pp (>= 0.6.0)
15
+ rdoc (>= 4.0.0)
16
+ reline (>= 0.4.2)
17
+ json (2.15.0)
18
+ language_server-protocol (3.17.0.5)
19
+ lint_roller (1.1.0)
20
+ parallel (1.27.0)
21
+ parser (3.3.9.0)
22
+ ast (~> 2.4.1)
23
+ racc
24
+ pp (0.6.2)
25
+ prettyprint
26
+ prettyprint (0.2.0)
27
+ prism (1.5.1)
28
+ psych (5.2.6)
29
+ date
30
+ stringio
31
+ racc (1.8.1)
32
+ rainbow (3.1.1)
9
33
  rake (13.3.0)
34
+ rdoc (6.14.2)
35
+ erb
36
+ psych (>= 4.0.0)
37
+ regexp_parser (2.11.3)
38
+ reline (0.6.2)
39
+ io-console (~> 0.5)
40
+ rubocop (1.80.2)
41
+ json (~> 2.3)
42
+ language_server-protocol (~> 3.17.0.2)
43
+ lint_roller (~> 1.1.0)
44
+ parallel (~> 1.10)
45
+ parser (>= 3.3.0.2)
46
+ rainbow (>= 2.2.2, < 4.0)
47
+ regexp_parser (>= 2.9.3, < 3.0)
48
+ rubocop-ast (>= 1.46.0, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 2.4.0, < 4.0)
51
+ rubocop-ast (1.47.1)
52
+ parser (>= 3.3.7.2)
53
+ prism (~> 1.4)
54
+ rubocop-performance (1.25.0)
55
+ lint_roller (~> 1.1)
56
+ rubocop (>= 1.75.0, < 2.0)
57
+ rubocop-ast (>= 1.38.0, < 2.0)
58
+ ruby-progressbar (1.13.0)
59
+ standard (1.51.1)
60
+ language_server-protocol (~> 3.17.0.2)
61
+ lint_roller (~> 1.0)
62
+ rubocop (~> 1.80.2)
63
+ standard-custom (~> 1.0.0)
64
+ standard-performance (~> 1.8)
65
+ standard-custom (1.0.2)
66
+ lint_roller (~> 1.0)
67
+ rubocop (~> 1.50)
68
+ standard-performance (1.8.0)
69
+ lint_roller (~> 1.1)
70
+ rubocop-performance (~> 1.25.0)
71
+ stringio (3.1.7)
72
+ unicode-display_width (3.2.0)
73
+ unicode-emoji (~> 4.1)
74
+ unicode-emoji (4.1.0)
10
75
 
11
76
  PLATFORMS
12
77
  ruby
@@ -14,7 +79,9 @@ PLATFORMS
14
79
  DEPENDENCIES
15
80
  bundler (~> 2.0)
16
81
  icat4json!
82
+ irb
17
83
  rake (~> 13.0)
84
+ standard (~> 1.0)
18
85
 
19
86
  BUNDLED WITH
20
87
  2.5.18
data/README.md CHANGED
@@ -29,7 +29,7 @@ require 'icat4json'
29
29
  so,
30
30
 
31
31
  ```
32
- data = ICat4JSON::ICat4JSON.new
32
+ data = ICat4JSON.new
33
33
  puts data.json
34
34
  puts data.icat
35
35
  ```
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ task default: :spec
data/icat4json.gemspec CHANGED
@@ -1,25 +1,26 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "icat4json/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "icat4json"
8
- spec.version = Icat4json::VERSION
9
- spec.authors = ["FUNABARA Masao"]
10
- spec.email = ["masao@masoo.jp"]
11
- spec.summary = "Ruby client for IPA's icat for JSON vulnerability feed"
12
- spec.description = "A Ruby gem to fetch and parse vulnerability information from IPA's icat for JSON feed. Provides easy access to Japanese vulnerability database."
13
- spec.homepage = "https://github.com/masoo/icat4json"
14
- spec.license = "MIT"
15
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
6
+ spec.name = "icat4json"
7
+ spec.version = ICat4JSON::VERSION
8
+ spec.authors = ["FUNABARA Masao"]
9
+ spec.email = ["masao@masoo.jp"]
10
+ spec.summary = "Ruby client for IPA's icat for JSON vulnerability feed"
11
+ spec.description = "A Ruby gem to fetch and parse vulnerability information from IPA's icat for JSON feed. Provides easy access to Japanese vulnerability database."
12
+ spec.homepage = "https://github.com/masoo/icat4json"
13
+ spec.license = "MIT"
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
15
  f.match(%r{^(test|spec|features)/})
17
16
  end
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
19
  spec.require_paths = ["lib"]
21
20
  spec.required_ruby_version = ">= 3.2.0"
22
21
 
23
22
  spec.add_development_dependency "bundler", "~> 2.0"
24
23
  spec.add_development_dependency "rake", "~> 13.0"
24
+ spec.add_development_dependency "irb"
25
+ spec.add_development_dependency "standard", "~> 1.0"
25
26
  end
@@ -1,3 +1,3 @@
1
- module Icat4json
2
- VERSION = "1.0.6"
1
+ module ICat4JSON
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/icat4json.rb CHANGED
@@ -5,26 +5,46 @@ require "json"
5
5
 
6
6
  module ICat4JSON
7
7
  class ICat4JSON
8
- attr_accessor :json, :icat
9
- ICAT4JSON_URL = "http://isec-myjvn-feed1.ipa.go.jp/IPARssReader.php?1456207434&tool=icatw"
8
+ attr_reader :json, :icat
9
+
10
+ ICATData = Struct.new(:itemdata, :docTitle, :docTitleFix, :docLink, :docDate)
11
+ ItemData = Struct.new(:item_title, :item_link, :item_date, :item_identifier)
10
12
 
11
13
  def initialize
12
- uri = URI.parse(ICAT4JSON_URL)
13
- http = Net::HTTP.get(uri)
14
- @json = JSON.parse(http)
15
- struct_icat = Struct.new(:itemdata, :docTitle, :docTitleFix, :docLink, :docDate)
16
- struct_item = Struct.new(:item_title, :item_link, :item_date, :item_identifier)
17
- @icat = struct_icat.new
18
- @json.each {|k, v| icat[k] = v unless k == "itemdata" }
14
+ begin
15
+ uri = URI.parse(icat4json_url)
16
+ http = Net::HTTP.get(uri)
17
+ rescue => e
18
+ raise e, "HTTP request failed: #{e.message}"
19
+ end
20
+
21
+ begin
22
+ @json = JSON.parse(http)
23
+ rescue JSON::ParserError => e
24
+ raise e, "JSON parsing failed: #{e.message}"
25
+ end
26
+
27
+ @icat = ICATData.new
28
+ @json.each { |k, v| icat[k] = v unless k == "itemdata" }
19
29
  @icat[:itemdata] = []
20
30
  @json["itemdata"].each do |itemdata|
21
- item = struct_item.new
22
- itemdata.each do |k,v|
31
+ item = ItemData.new
32
+ itemdata.each do |k, v|
23
33
  item[k] = v
24
34
  end
25
35
  @icat[:itemdata].push item
26
36
  end
27
- true
28
37
  end
38
+
39
+ private
40
+
41
+ # analize https://www.ipa.go.jp/security/announce/irss/icatw2.js
42
+ def icat4json_url
43
+ "http://isec-myjvn-feed1.ipa.go.jp/IPARssReader.php?#{Time.now.to_i}&tool=icatw"
44
+ end
45
+ end
46
+
47
+ def self.new(*args, &block)
48
+ ICat4JSON.new(*args, &block)
29
49
  end
30
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icat4json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FUNABARA Masao
@@ -37,6 +37,34 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '13.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: irb
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: standard
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.0'
40
68
  description: A Ruby gem to fetch and parse vulnerability information from IPA's icat
41
69
  for JSON feed. Provides easy access to Japanese vulnerability database.
42
70
  email: