Class: Site
- Inherits:
-
Domain::Model
- Object
- Domain::Model
- Site
- Defined in:
- lib/domain/site/model.rb
Overview
The Site class represents a site in the system, containing various attributes and methods related to site management and identification.
Constant Summary collapse
- UTR_PATTERN =
/:UTR\d{5}$/
- NETWORK_DISCOVERY_PATTERN =
/Network Discovery Scan/
- CMDB_VULNERABILITY_PATTERN =
/Vulnerability Scan/
Instance Attribute Summary collapse
-
#assets ⇒ Object
Returns the value of attribute assets.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#risk_score ⇒ Object
Returns the value of attribute risk_score.
-
#scan_engine ⇒ Object
Returns the value of attribute scan_engine.
-
#scan_template ⇒ Object
Returns the value of attribute scan_template.
Instance Method Summary collapse
- #cmdb_discovery? ⇒ Boolean
-
#cmdb_vulnerability? ⇒ Boolean
return true if the site name contains only 2 colons (:) and it is not a cmdb_discovery?.
- #country_code ⇒ Object
-
#country_discovery? ⇒ Boolean
return true if the site name contains Network Discovery Scan (2024).
- #scan_template_id ⇒ Object
-
#time_zone(country_code) ⇒ Object
returns the time_zone from the 2-letter country code.
- #to_s ⇒ Object
-
#utr? ⇒ Boolean
returns true if the site ends with :UTR followed by 5 digits.
- #utr_digits ⇒ Object
Methods inherited from Domain::Model
columns, from_csv, from_json, headers, #initialize, primary_key, table_name, #to_csv, #to_hash, view
Constructor Details
This class inherits a constructor from Domain::Model
Instance Attribute Details
#assets ⇒ Object
Returns the value of attribute assets.
14 15 16 |
# File 'lib/domain/site/model.rb', line 14 def assets @assets end |
#description ⇒ Object
Returns the value of attribute description.
14 15 16 |
# File 'lib/domain/site/model.rb', line 14 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
14 15 16 |
# File 'lib/domain/site/model.rb', line 14 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/domain/site/model.rb', line 14 def name @name end |
#risk_score ⇒ Object
Returns the value of attribute risk_score.
14 15 16 |
# File 'lib/domain/site/model.rb', line 14 def risk_score @risk_score end |
#scan_engine ⇒ Object
Returns the value of attribute scan_engine.
14 15 16 |
# File 'lib/domain/site/model.rb', line 14 def scan_engine @scan_engine end |
#scan_template ⇒ Object
Returns the value of attribute scan_template.
14 15 16 |
# File 'lib/domain/site/model.rb', line 14 def scan_template @scan_template end |
Instance Method Details
#cmdb_discovery? ⇒ Boolean
66 67 68 |
# File 'lib/domain/site/model.rb', line 66 def cmdb_discovery? utr? end |
#cmdb_vulnerability? ⇒ Boolean
return true if the site name contains only 2 colons (:) and it is not a cmdb_discovery?
73 74 75 76 77 |
# File 'lib/domain/site/model.rb', line 73 def cmdb_vulnerability? return false if cmdb_discovery? name =~ CMDB_VULNERABILITY_PATTERN && name.count(':') == 2 end |
#country_code ⇒ Object
44 45 46 47 48 49 |
# File 'lib/domain/site/model.rb', line 44 def country_code return nil unless utr? matches = name.match(/^:(.*?):/) matches ? matches[1] : nil end |
#country_discovery? ⇒ Boolean
return true if the site name contains Network Discovery Scan (2024)
62 63 64 |
# File 'lib/domain/site/model.rb', line 62 def country_discovery? name =~ NETWORK_DISCOVERY_PATTERN end |
#scan_template_id ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/domain/site/model.rb', line 26 def scan_template_id return nil unless utr? if name.include?(':za:') # settings[:za_full_audit] '_-sa-ca-_100_-_-pps_min-2000-_-max-15000-_--_-full-audit-without-web-spider' else # settings[:ar_full_audit] '_-angola-ca-_100_-_-pps_min-450-_-max-450-_--_-full-audit-without-web-spider-copy' end end |
#time_zone(country_code) ⇒ Object
returns the time_zone from the 2-letter country code
40 41 42 |
# File 'lib/domain/site/model.rb', line 40 def time_zone(country_code) # {'a'} end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/domain/site/model.rb', line 22 def to_s [id, name, scan_engine, scan_template].join ',' end |
#utr? ⇒ Boolean
returns true if the site ends with :UTR followed by 5 digits
57 58 59 |
# File 'lib/domain/site/model.rb', line 57 def utr? name =~ UTR_PATTERN end |
#utr_digits ⇒ Object
51 52 53 54 |
# File 'lib/domain/site/model.rb', line 51 def utr_digits digits = name.match(UTR_PATTERN) digits ? digits[1].to_i : 0 end |