qualys 0.1.0 → 0.1.2
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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +3 -0
- data/README.md +4 -1
- data/lib/qualys.rb +2 -0
- data/lib/qualys/api.rb +3 -3
- data/lib/qualys/scans.rb +32 -6
- data/lib/qualys/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6a46cedfa5961875af503af600cb5a1c0e37800
|
4
|
+
data.tar.gz: 075cbebe73c86adf984e75450702a9f3403e9681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cdaa1a3650ab9178de86d4f62b6338347c1f93102438d642c08197e8ce8b9bd25282f211bc890b4d907420b7dbddc5423cc8143af25ab42e5c90ec221fcdffa
|
7
|
+
data.tar.gz: d65a1e6edd53d6f2b5f81187ca87b9625b18f30ee563fe40978c588560097f0e00c90052cd6034d0f7753da989a6afe1089dc58a204dadd440047664ca147f48
|
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
language: ruby
|
data/Gemfile
ADDED
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:
|
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
|
data/lib/qualys.rb
CHANGED
data/lib/qualys/api.rb
CHANGED
@@ -3,7 +3,7 @@ module Qualys
|
|
3
3
|
|
4
4
|
class InvalidResponse < RuntimeError; end
|
5
5
|
class AuthorizationRequired < RuntimeError; end
|
6
|
-
class
|
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::
|
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::
|
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
|
data/lib/qualys/scans.rb
CHANGED
@@ -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
|
-
|
7
|
-
|
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
|
-
|
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
|
data/lib/qualys/version.rb
CHANGED
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.
|
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
|