crtsh-rb 0.2.0 → 0.3.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: 851220e9259aba8b67dcfe938576be29696f3b14fc10df074017bd31d7db030c
4
- data.tar.gz: eadf856be0b928cc1eb7f119017e28bfe83206fd0ecdb35cd43ef4de9c04ff78
3
+ metadata.gz: 166f2ae1b569a2cc6e2ceaaf94a4eb3441a1484c5662e1e7d5c71e3b8eb8ab68
4
+ data.tar.gz: 93672f754b8e4a0afef0c6db43b20ace71aea80a588f69fd94768295317b6d2b
5
5
  SHA512:
6
- metadata.gz: 91f8029021e4c63b2aea186d21645563d51211ed7c1aebf34f9e197c54cd53dcc3532ab39117926e9471b5bf71823a04dc6f357f3614fedc8a77ba98ac165824
7
- data.tar.gz: 2d625457a6048deb60bdd9a9b95890a713b8c4064a262023ca8f1292a61b348866aa19de7015cad6000719fca9ae956ba2b94f22b28196d12a896e08012d3f37
6
+ metadata.gz: 5e1fa611c95c9cc799f2089e27b9cdb1764a690bd3370fde9483546f897d41f0b3d505195a083c22972664127a17fb995741c94b269ff42ee53410c536ee420e
7
+ data.tar.gz: c732d7e31e2f690baa3e94eb62b0a1aa839de00cb9564e57a32f6910f08aa6712e58bb2ddce143cd22d3a44d298ab68c67d84014931ac5d8fe6d94fb25349167
data/README.md CHANGED
@@ -17,11 +17,26 @@ gem install crtsh-rb
17
17
  ```ruby
18
18
  require "crtsh"
19
19
 
20
+ # Interact with Web API
20
21
  api = Crtsh::API.new
21
22
  api.search("crt.sh")
22
23
  api.search("crt.sh", match: "LIKE")
23
24
  api.search("crt.sh", exclude: "expired")
24
25
  api.search("crt.sh", match: "LIKE", exclude: "expired")
26
+
27
+ # Interact with DB
28
+ db = Crtsh::DB.new
29
+ sql = """
30
+ SELECT digest(certificate.certificate, 'sha256') sha256
31
+ FROM certificate_identity, certificate
32
+ WHERE certificate.id = certificate_identity.certificate_id
33
+ AND x509_notAfter(certificate.certificate) > statement_timestamp()
34
+ AND reverse(lower(certificate_identity.name_value)) LIKE reverse(lower($1))
35
+ LIMIT 10
36
+ """
37
+ # Crtsh::DB#connection returns PG::Connection
38
+ result = db.connection.exec_params(sql, ["github.com"])
39
+ p result.values
25
40
  ```
26
41
 
27
42
  ## Contributing
@@ -29,5 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rake", "~> 13.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.9"
31
31
  spec.add_development_dependency "vcr", "~> 5.0"
32
- spec.add_development_dependency "webmock", "~> 3.7"
32
+ spec.add_development_dependency "webmock", "~> 3.8"
33
+
34
+ spec.add_dependency "pg", "~> 1.2"
33
35
  end
@@ -3,6 +3,7 @@
3
3
  require "crtsh/version"
4
4
 
5
5
  require "crtsh/api"
6
+ require "crtsh/db"
6
7
 
7
8
  module Crtsh
8
9
  class Error < StandardError; end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pg"
4
+
5
+ module Crtsh
6
+ class DB
7
+ #
8
+ # Returns a connection to certwatch DB
9
+ #
10
+ # @return [PG::Connection]
11
+ #
12
+ def connection
13
+ @connection ||= PG.connect(
14
+ host: "crt.sh",
15
+ user: "guest",
16
+ dbname: "certwatch"
17
+ )
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crtsh
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crtsh-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-12 00:00:00.000000000 Z
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.7'
89
+ version: '3.8'
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.7'
96
+ version: '3.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pg
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.2'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.2'
97
111
  description: crt.sh API wrapper for Ruby
98
112
  email:
99
113
  - manabu.niseki@gmail.com
@@ -111,6 +125,7 @@ files:
111
125
  - crtsh.gemspec
112
126
  - lib/crtsh.rb
113
127
  - lib/crtsh/api.rb
128
+ - lib/crtsh/db.rb
114
129
  - lib/crtsh/version.rb
115
130
  homepage: https://github.com/ninoseki/crtsh
116
131
  licenses: