Class: HybridAnalysis::Clients::FileCollection

Inherits:
Client
  • Object
show all
Defined in:
lib/hybridanalysis/clients/file_collection.rb

Constant Summary

Constants inherited from Client

Client::BASE_URL, Client::DEFAULT_UA, Client::HOST, Client::VERSION

Instance Attribute Summary

Attributes inherited from Client

#key

Instance Method Summary collapse

Methods inherited from Client

#initialize

Constructor Details

This class inherits a constructor from HybridAnalysis::Clients::Client

Instance Method Details

#add(id:, file:) ⇒ Hash

add file to collection

Parameters:

  • id (String)

    File collection id

  • file (String)

    File to add

Returns:

  • (Hash)


84
85
86
87
# File 'lib/hybridanalysis/clients/file_collection.rb', line 84

def add(id:, file: )
  params = { file: file }.compact
  _post("/file-collection/#{id}/files/add", params) { |json| json }
end

#create(collection_name: nil, comment: nil, no_share_third_party: nil, allow_community_access: nil) ⇒ Hash

create file collection

Parameters:

  • collection_name (String, nil) (defaults to: nil)

    Optional collection name

  • comment (String, nil) (defaults to: nil)

    Optional comment text that may be associated with the file collection (Note: you can use #tags here)

  • no_share_third_party (Boolean, nil) (defaults to: nil)

    When set to ‘true’, samples within collection will never be shared with any third party. Default: true

  • allow_community_access (Boolean, nil) (defaults to: nil)

    When set to ‘true’, samples within collection will be available for the community. Default: true

Returns:

  • (Hash)


66
67
68
69
70
71
72
73
74
# File 'lib/hybridanalysis/clients/file_collection.rb', line 66

def create(collection_name: nil, comment: nil, no_share_third_party: nil, allow_community_access: nil)
  params = {
    collection_name: collection_name,
    comment: comment,
    no_share_third_party: no_share_third_party,
    allow_community_access: allow_community_access
  }.compact
  _post("/file-collection/create", params) { |json| json }
end

#delete(id:, hash:) ⇒ Hash

remove file within collection without hard removal from system

Parameters:

  • id (String)

    File collection id

  • hash (String)

    SHA256 of file to remove

Returns:

  • (Hash)


14
15
16
# File 'lib/hybridanalysis/clients/file_collection.rb', line 14

def delete(id:, hash: )
  _delete("/file-collection/#{id}/files/#{hash}") { |json| json }
end

#download(id) ⇒ Hash

return an archive with all collection samples

Parameters:

  • id (String)

    File collection id

Returns:

  • (Hash)


36
37
38
# File 'lib/hybridanalysis/clients/file_collection.rb', line 36

def download(id)
  _get("/file-collection/#{id}/files/download") { |json| json }
end

#get(id) ⇒ Hash

return a summary of file collection

Parameters:

  • id (String)

    File collection id

Returns:

  • (Hash)


25
26
27
# File 'lib/hybridanalysis/clients/file_collection.rb', line 25

def get(id)
  _get("/file-collection/#{id}") { |json| json }
end

#search(collection_name: nil, tag: nil) ⇒ Hash

search the database using the search terms

Parameters:

  • collection_name (String, nil) (defaults to: nil)

    Collection Name

  • tag (String, nil) (defaults to: nil)

    Hashtag e.g. ransomware

Returns:

  • (Hash)


48
49
50
51
52
53
54
# File 'lib/hybridanalysis/clients/file_collection.rb', line 48

def search(collection_name: nil, tag: nil)
  params = {
    collection_name: collection_name,
    tag: tag
  }.compact
  _post("/file-collection/search", params) { |json| json }
end