Class: Ronin::DB::CertName

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Model, Model::HasUniqueName, Model::Importable
Defined in:
lib/ronin/db/cert_name.rb

Overview

Represents a certificate's common name (CN) or subjectAltNames.

Since:

  • 0.2.0

Instance Attribute Summary collapse

Attributes included from Model::HasUniqueName

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::Importable

included

Methods included from Model::HasUniqueName

included

Methods included from Model

included

Instance Attribute Details

#certsArray<CertSubject>

The certificates that use this name as their common name (CN).

Returns:



54
55
56
# File 'lib/ronin/db/cert_name.rb', line 54

has_many :subjects, class_name:  'CertSubject',
foreign_key: :common_name_id,
dependent:   :destroy

#created_atTime

When the certificate name was created.

Returns:

  • (Time)


48
# File 'lib/ronin/db/cert_name.rb', line 48

attribute :created_at, :datetime

#idInteger

The primary key of the certificate name.

Returns:

  • (Integer)


42
# File 'lib/ronin/db/cert_name.rb', line 42

attribute :id, :integer

#subject_alt_namesArray<CertSubjectAltName>

The certificates that use this name as one of their subjectAltName values.

Returns:



63
64
65
# File 'lib/ronin/db/cert_name.rb', line 63

has_many :subject_alt_names, class_name:  'CertSubjectAltName',
foreign_key: :name_id,
dependent:   :destroy

Class Method Details

.import(name) ⇒ CertName

Imports the certificate name.

Parameters:

  • name (String)

    The certificate name to import.

Returns:

  • (CertName)

    The newly created certificate name.

Since:

  • 0.2.0



89
90
91
# File 'lib/ronin/db/cert_name.rb', line 89

def self.import(name)
  create(name: name)
end

.lookup(name) ⇒ CertName?

Looks up the certificate name.

Parameters:

  • name (String)

    The name to search by.

Returns:

  • (CertName, nil)

    The found certificate name with the matching name.

Since:

  • 0.2.0



76
77
78
# File 'lib/ronin/db/cert_name.rb', line 76

def self.lookup(name)
  find_by(name: name)
end

Instance Method Details

#to_sString

Converts the certificate name to a String.

Returns:

  • (String)

Since:

  • 0.2.0



98
99
100
# File 'lib/ronin/db/cert_name.rb', line 98

def to_s
  name
end