Class: Ronin::DB::Software

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Model, Model::HasName
Defined in:
lib/ronin/db/software.rb

Overview

Represents a Software product.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::HasName

included

Methods included from Model

included

Instance Attribute Details

#idInteger

The primary key of the software.

Returns:

  • (Integer)


40
# File 'lib/ronin/db/software.rb', line 40

attribute :id, :integer

#nameString

The software's name.

Returns:

  • (String)


46
# File 'lib/ronin/db/software.rb', line 46

attribute :name, :string

#open_portsArray<OpenPort>

The open ports running the software

Returns:



68
# File 'lib/ronin/db/software.rb', line 68

has_many :open_ports

#vendorSoftwareVendor?

The vendor of the software

Returns:



61
62
# File 'lib/ronin/db/software.rb', line 61

belongs_to :vendor, optional:   true,
class_name: 'SoftwareVendor'

#versionString

The software's Version.

Returns:

  • (String)


53
# File 'lib/ronin/db/software.rb', line 53

attribute :version, :string

Class Method Details

.with_vendor_name(name) ⇒ Array<Software>

Queries all software with the matching vendor name.

Parameters:

  • name (String)

    The vendor name to search for.

Returns:

  • (Array<Software>)

    The matching software.

Since:

  • 0.2.0



100
101
102
# File 'lib/ronin/db/software.rb', line 100

def self.with_vendor_name(name)
  joins(:vendor).where(vendor: {name: name})
end

.with_version(version) ⇒ Array<Software>

Queries all software with the matching version.

Parameters:

  • version (String)

    The version number to search for.

Returns:

  • (Array<Software>)

    The matching software.

Since:

  • 0.2.0



83
84
85
# File 'lib/ronin/db/software.rb', line 83

def self.with_version(version)
  where(version: version)
end

Instance Method Details

#to_sString

Converts the software to a String.

Returns:

  • (String)

    The software vendor, name and version.



112
113
114
# File 'lib/ronin/db/software.rb', line 112

def to_s
  [self.vendor, self.name, self.version].compact.join(' ')
end