passivetotal 1.0.2 → 1.0.3
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/lib/passivetotal/api.rb +26 -1
- data/lib/passivetotal/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d3c95b2a176f2d2169468d5588f6b966ab8138e1
         | 
| 4 | 
            +
              data.tar.gz: a40c315a92542733ab1e181ac875fb85f2a03893
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 76a3fd0c35b524a726cc57f3cb0f50feb852b1bf7bac01a02f52cccd4475063145fa1ee9d5554046abbd96eab075234545ba5f19baf346c6a30341cefb2a67af
         | 
| 7 | 
            +
              data.tar.gz: 4058e27c7a5ffec725fc5d496983e34ceae7d143ac46250d4fe0f704cb161766f903fe4b625d85ea4bb91386aa0b3a372f7ece8cd6f8c233431bc6782fc6bd1a
         | 
    
        data/lib/passivetotal/api.rb
    CHANGED
    
    | @@ -176,7 +176,7 @@ module PassiveTotal # :nodoc: | |
| 176 176 | 
             
                def classification(query, set=nil)
         | 
| 177 177 | 
             
                  is_valid_with_error(__method__, [:ipv4, :domain], query)
         | 
| 178 178 | 
             
                  if domain?(query)
         | 
| 179 | 
            -
                    query = normalize_domain( | 
| 179 | 
            +
                    query = normalize_domain(q)
         | 
| 180 180 | 
             
                  end
         | 
| 181 181 | 
             
                  if set.nil?
         | 
| 182 182 | 
             
                    get('actions/classification', {'query' => query})
         | 
| @@ -186,6 +186,22 @@ module PassiveTotal # :nodoc: | |
| 186 186 | 
             
                  end
         | 
| 187 187 | 
             
                end
         | 
| 188 188 |  | 
| 189 | 
            +
                # Get the classification for a query in bulk
         | 
| 190 | 
            +
                # query: An array of domains or IP address to query
         | 
| 191 | 
            +
                def bulk_classification(query)
         | 
| 192 | 
            +
                  if query.class != Array
         | 
| 193 | 
            +
                    query = [query]
         | 
| 194 | 
            +
                  end
         | 
| 195 | 
            +
                  query.map do |q|
         | 
| 196 | 
            +
                    is_valid_with_error(__method__, [:ipv4, :domain], q)
         | 
| 197 | 
            +
                    if domain?(q)
         | 
| 198 | 
            +
                      q = normalize_domain(q)
         | 
| 199 | 
            +
                    end
         | 
| 200 | 
            +
                    q
         | 
| 201 | 
            +
                  end
         | 
| 202 | 
            +
                  get_with_data('actions/bulk/classification', { 'query' => query })
         | 
| 203 | 
            +
                end
         | 
| 204 | 
            +
                
         | 
| 189 205 | 
             
                # PassiveTotal allows users to notate if a domain or IP address have ever been compromised. These values aid in letting users know that a site may be benign, but it was used in an attack at some point in time.
         | 
| 190 206 | 
             
                # PassiveTotal::API#ever_compromised() queries if only one argument is given, and sets if both are given
         | 
| 191 207 | 
             
                # query: A domain or IP address to query
         | 
| @@ -421,6 +437,10 @@ module PassiveTotal # :nodoc: | |
| 421 437 | 
             
                  url2json(:GET, "#{@endpoint}#{api}", params)
         | 
| 422 438 | 
             
                end
         | 
| 423 439 |  | 
| 440 | 
            +
                def get_with_data(api, params={})
         | 
| 441 | 
            +
                  url2json(:GET_DATA, "#{@endpoint}#{api}", params)
         | 
| 442 | 
            +
                end
         | 
| 443 | 
            +
                
         | 
| 424 444 | 
             
                # helper function to perform an HTTP POST against the web API
         | 
| 425 445 | 
             
                def post(api, params)
         | 
| 426 446 | 
             
                  url2json(:POST, "#{@endpoint}#{api}", params)
         | 
| @@ -444,6 +464,11 @@ module PassiveTotal # :nodoc: | |
| 444 464 | 
             
                  request = nil
         | 
| 445 465 | 
             
                  if method == :GET
         | 
| 446 466 | 
             
                    request = Net::HTTP::Get.new(url.request_uri)
         | 
| 467 | 
            +
                  elsif method == :GET_DATA
         | 
| 468 | 
            +
                    request = Net::HTTP::Get.new(url.request_uri)
         | 
| 469 | 
            +
                    form_data = params.to_json
         | 
| 470 | 
            +
                    request.content_type = 'application/json'
         | 
| 471 | 
            +
                    request.body = form_data
         | 
| 447 472 | 
             
                  elsif method == :POST
         | 
| 448 473 | 
             
                    request = Net::HTTP::Post.new(url.request_uri)
         | 
| 449 474 | 
             
                    form_data = params.to_json
         | 
    
        data/lib/passivetotal/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: passivetotal
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - chrislee35
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016- | 
| 11 | 
            +
            date: 2016-10-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: json
         |