qualys 0.1.0 → 0.1.2

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
  SHA1:
3
- metadata.gz: 82d46fe75c445a67a07782c8ea2b9f92011e7f9e
4
- data.tar.gz: 79fb99dbdcbf7bb6da466cd91b806662c7979c2f
3
+ metadata.gz: e6a46cedfa5961875af503af600cb5a1c0e37800
4
+ data.tar.gz: 075cbebe73c86adf984e75450702a9f3403e9681
5
5
  SHA512:
6
- metadata.gz: 90601d93e13d3d24b2779290f5a112a5c8fb2edd84f89f193353364fd9c420390dab5aa7e7e435c9d05725b06b6e70639160618e2797411150715ceff698dc95
7
- data.tar.gz: d01666b6aefab5de181db30b3ec30df00aac9531e951f07324234001f770f024f413fbbc149e2e39acae006bb16e5ae57ad1723cdeaf78ff934cdb7571db3cc2
6
+ metadata.gz: 8cdaa1a3650ab9178de86d4f62b6338347c1f93102438d642c08197e8ce8b9bd25282f211bc890b4d907420b7dbddc5423cc8143af25ab42e5c90ec221fcdffa
7
+ data.tar.gz: d65a1e6edd53d6f2b5f81187ca87b9625b18f30ee563fe40978c588560097f0e00c90052cd6034d0f7753da989a6afe1089dc58a204dadd440047664ca147f48
@@ -0,0 +1 @@
1
+ language: ruby
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md CHANGED
@@ -49,4 +49,7 @@ scans = Qualys::Scans.all
49
49
 
50
50
  ## References
51
51
 
52
- The API was built using the following documentation: https://www.qualys.com/docs/qualys-api-v2-quick-reference.pdf
52
+ The API was built using the following documentation:
53
+
54
+ - https://www.qualys.com/docs/qualys-api-v2-quick-reference.pdf
55
+ - https://www.qualys.com/docs/qualys-api-v2-user-guide.pdf?_ga=1.246313805.857253578.1427813387
@@ -9,6 +9,8 @@ require 'qualys/api'
9
9
  require 'qualys/auth'
10
10
 
11
11
  require 'qualys/scans'
12
+ require 'qualys/compliance'
13
+ require 'qualys/reports'
12
14
 
13
15
 
14
16
  module Qualys
@@ -3,7 +3,7 @@ module Qualys
3
3
 
4
4
  class InvalidResponse < RuntimeError; end
5
5
  class AuthorizationRequired < RuntimeError; end
6
- class UnauthorizedRequest < RuntimeError; end
6
+ class Exception < RuntimeError; end
7
7
 
8
8
  # Set the current production endpoint
9
9
  PRODUCTION_ENDPOINT = 'https://qualysapi.qualys.com/api/2.0/fo/'
@@ -29,7 +29,7 @@ module Qualys
29
29
  if response.code.eql?(401)
30
30
  raise Qualys::Api::AuthorizationRequired, "Please Login Before Communicating With The API"
31
31
  elsif response.code.eql?(403)
32
- raise Qualys::Api::UnauthorizedRequest, "You either sent an invalid request or do not have access to that add-on"
32
+ raise Qualys::Api::Exception, response.parsed_response['SIMPLE_RETURN']['RESPONSE']['TEXT']
33
33
  elsif !response.code.eql?(200)
34
34
  raise Qualys::Api::InvalidResponse, "Invalid Response Received"
35
35
  end
@@ -53,7 +53,7 @@ module Qualys
53
53
  if response.code.eql?(401)
54
54
  raise Qualys::Api::AuthorizationRequired, "Please Configure A Username and Password Before Communicating With The API"
55
55
  elsif response.code.eql?(403)
56
- raise Qualys::Api::UnauthorizedRequest, "You either sent an invalid request or do not have access to that add-on"
56
+ raise Qualys::Api::Exception, response.parsed_response['SIMPLE_RETURN']['RESPONSE']['TEXT']
57
57
  elsif response.code.eql?(500)
58
58
  raise Qualys::Api::InvalidResponse, "Invalid Response Received"
59
59
  end
@@ -2,19 +2,45 @@ module Qualys
2
2
  class Scans < Api
3
3
 
4
4
  def self.all
5
- response = api_get("scan/", { :query => { :action => 'list' }})
6
- scanlist = response.parsed_response['SCAN_LIST_OUTPUT']['RESPONSE']['SCAN_LIST']
7
- puts scanlist.inspect
5
+ response = api_get("scan/", { :query => { :action => 'list' }} )
6
+ unless response.parsed_response['SCAN_LIST_OUTPUT']['RESPONSE'].has_key? 'SCAN_LIST'
7
+ return []
8
+ end
9
+
10
+ scanlist = response.parsed_response['SCAN_LIST_OUTPUT']['RESPONSE']['SCAN_LIST']['SCAN']
11
+ scanlist.map!{|scan| Scan.new(scan)}
12
+
8
13
  end
9
14
 
10
15
  def self.each
11
- @events.each do |event|
12
- yield event
13
- end
16
+ self.all
14
17
  end
15
18
 
16
19
  end
17
20
 
18
21
  class Scan
22
+
23
+ attr_accessor :ref, :title, :type, :date, :duration, :status, :target, :user
24
+
25
+ def initialize(scan)
26
+ @ref = scan['REF']
27
+ @title = scan['TITLE']
28
+ @type = scan['TYPE']
29
+ @date = scan['LAUNCH_DATETIME']
30
+ @duration = scan['DURATION']
31
+ @status = scan['STATUS']['STATE']
32
+ @target = scan['TARGET']
33
+ @user = scan['USER_LOGIN']
34
+ end
35
+
36
+ end
37
+
38
+ def finished?
39
+ if @status.eql? 'Finished'
40
+ return true
41
+ end
42
+
43
+ false
19
44
  end
45
+
20
46
  end
@@ -1,3 +1,3 @@
1
1
  module Qualys
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qualys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mackintosh
@@ -145,6 +145,8 @@ files:
145
145
  - ".gitignore"
146
146
  - ".rock.yml"
147
147
  - ".rspec"
148
+ - ".travis.yml"
149
+ - Gemfile
148
150
  - LICENSE.txt
149
151
  - README.md
150
152
  - Rakefile