greynoise 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +23 -0
- data/README.md +2 -1
- data/greynoise.gemspec +5 -5
- data/lib/greynoise/api.rb +31 -4
- data/lib/greynoise/clients/client.rb +2 -2
- data/lib/greynoise/version.rb +1 -1
- data/renovate.json +5 -0
- metadata +19 -18
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec4490e5fb7c974683855f89edec6e2dccd4f439cdf79ec8909d09ee97717164
|
4
|
+
data.tar.gz: d05b274f86291dbd329c2caf9bafa3cd30965d7ed3c3c095c4719775828ecb9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f3c25589fc75d2b50913b25aabed6755effd820aee3d3224929ec005e4ce01633a5b824a695d0ab2718564f89cee487bcd11e7313d8e918c182bacd9838c623
|
7
|
+
data.tar.gz: e8a063753330c0a40c4fb5bdd2cd2c29e541f122c8888b5ad4a6ee375aca0ddd88dd9dd45c99457b8b97710b854c7169b41e33b8877ea39813e4c819de52c3e1
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [2.7, "3.0"]
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
bundler-cache: true
|
20
|
+
|
21
|
+
- name: Run RSpec
|
22
|
+
run: |
|
23
|
+
bundle exec rake
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# greynoise
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/greynoise.svg)](https://badge.fury.io/rb/greynoise)
|
3
4
|
[![Build Status](https://travis-ci.com/ninoseki/greynoise.svg?branch=master)](https://travis-ci.com/ninoseki/greynoise)
|
4
5
|
[![Coverage Status](https://coveralls.io/repos/github/ninoseki/greynoise/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/greynoise?branch=master)
|
5
6
|
[![CodeFactor](https://www.codefactor.io/repository/github/ninoseki/greynoise/badge)](https://www.codefactor.io/repository/github/ninoseki/greynoise)
|
@@ -17,7 +18,7 @@ gem install greynoise
|
|
17
18
|
```ruby
|
18
19
|
require "greynoise"
|
19
20
|
|
20
|
-
# when given nothing, it tries to load your API key via ENV["GREYNOISE_API_KEY"]
|
21
|
+
# when given nothing, it tries to load your API key via ENV["GREYNOISE_API_KEY"] and `~/.config/greynoise/config`
|
21
22
|
api = GreyNoise::API.new
|
22
23
|
# or you can set it manually
|
23
24
|
api = GreyNoise::API.new(key: YOUR_API_KEY)
|
data/greynoise.gemspec
CHANGED
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_development_dependency "bundler", "~> 2.
|
31
|
-
spec.add_development_dependency "
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
31
|
+
spec.add_development_dependency "coveralls_reborn", "~> 0.23"
|
32
32
|
spec.add_development_dependency "rake", "~> 13.0"
|
33
|
-
spec.add_development_dependency "rspec", "~> 3.
|
34
|
-
spec.add_development_dependency "vcr", "~>
|
35
|
-
spec.add_development_dependency "webmock", "~> 3.
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.10"
|
34
|
+
spec.add_development_dependency "vcr", "~> 6.0.0"
|
35
|
+
spec.add_development_dependency "webmock", "~> 3.14"
|
36
36
|
end
|
data/lib/greynoise/api.rb
CHANGED
@@ -1,21 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "json"
|
4
|
+
|
3
5
|
module GreyNoise
|
4
6
|
class API
|
5
|
-
|
7
|
+
attr_reader :key
|
8
|
+
|
9
|
+
def initialize(key: nil)
|
6
10
|
@key = key
|
11
|
+
@key ||= load_from_config
|
12
|
+
@key ||= load_from_env
|
13
|
+
|
14
|
+
raise ArgumentError if @key.nil?
|
7
15
|
end
|
8
16
|
|
9
17
|
def experimental
|
10
|
-
@experimental ||= Clients::Experimental.new(
|
18
|
+
@experimental ||= Clients::Experimental.new(key)
|
11
19
|
end
|
12
20
|
|
13
21
|
def meta
|
14
|
-
@meta ||= Clients::Meta.new(
|
22
|
+
@meta ||= Clients::Meta.new(key)
|
15
23
|
end
|
16
24
|
|
17
25
|
def noise
|
18
|
-
@noise ||= Clients::Noise.new(
|
26
|
+
@noise ||= Clients::Noise.new(key)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_from_env
|
32
|
+
ENV["GREYNOISE_API_KEY"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_from_config
|
36
|
+
path = File.expand_path("~/.config/greynoise/config")
|
37
|
+
return nil unless File.exist?(path)
|
38
|
+
|
39
|
+
begin
|
40
|
+
data = File.read(path)
|
41
|
+
json = JSON.parse(data)
|
42
|
+
json["api_key"]
|
43
|
+
rescue TypeError, JSON::ParserError => _e
|
44
|
+
nil
|
45
|
+
end
|
19
46
|
end
|
20
47
|
end
|
21
48
|
end
|
@@ -9,7 +9,7 @@ module GreyNoise
|
|
9
9
|
class Client
|
10
10
|
HOST = "api.greynoise.io"
|
11
11
|
VERSION = "v2"
|
12
|
-
BASE_URL = "https://#{HOST}/#{VERSION}"
|
12
|
+
BASE_URL = "https://#{HOST}/#{VERSION}".freeze
|
13
13
|
|
14
14
|
attr_reader :key
|
15
15
|
|
@@ -55,7 +55,7 @@ module GreyNoise
|
|
55
55
|
yield body
|
56
56
|
end
|
57
57
|
else
|
58
|
-
status = json ? json
|
58
|
+
status = json ? json["status"] : body
|
59
59
|
raise Error, "Unsupported response code returned: #{code} - #{status}"
|
60
60
|
end
|
61
61
|
end
|
data/lib/greynoise/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greynoise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.2'
|
20
20
|
type: :development
|
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: '2.
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: coveralls_reborn
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.23'
|
34
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: '0.
|
40
|
+
version: '0.23'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,42 +58,42 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vcr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 6.0.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 6.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.14'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.14'
|
97
97
|
description: GreyNoise API wrapper for Ruby
|
98
98
|
email:
|
99
99
|
- manabu.niseki@gmail.com
|
@@ -101,9 +101,9 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- ".github/workflows/test.yml"
|
104
105
|
- ".gitignore"
|
105
106
|
- ".rspec"
|
106
|
-
- ".travis.yml"
|
107
107
|
- Gemfile
|
108
108
|
- LICENSE
|
109
109
|
- README.md
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/greynoise/clients/meta.rb
|
119
119
|
- lib/greynoise/clients/noise.rb
|
120
120
|
- lib/greynoise/version.rb
|
121
|
+
- renovate.json
|
121
122
|
homepage: https://github.com/ninoseki/greynoise
|
122
123
|
licenses:
|
123
124
|
- MIT
|
@@ -125,7 +126,7 @@ metadata:
|
|
125
126
|
homepage_uri: https://github.com/ninoseki/greynoise
|
126
127
|
source_code_uri: https://github.com/ninoseki/greynoise
|
127
128
|
changelog_uri: https://github.com/ninoseki/greynoise/CHANGELOG.md
|
128
|
-
post_install_message:
|
129
|
+
post_install_message:
|
129
130
|
rdoc_options: []
|
130
131
|
require_paths:
|
131
132
|
- lib
|
@@ -140,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
- !ruby/object:Gem::Version
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
144
|
+
rubygems_version: 3.2.22
|
145
|
+
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: GreyNoise API wrapper for Ruby
|
147
148
|
test_files: []
|