Class: HeimdallTools::HeimdallDataFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/heimdall_tools/hdf.rb

Instance Method Summary collapse

Constructor Details

#initialize(profile_name: NA_TAG, version: NA_TAG, duration: NA_TAG, sha256: NA_TAG, title: NA_TAG, maintainer: NA_TAG, summary: NA_TAG, license: NA_TAG, copyright: NA_TAG, copyright_email: NA_TAG, supports: NA_ARRAY, attributes: NA_ARRAY, depends: NA_ARRAY, groups: NA_ARRAY, status: 'loaded', controls: NA_TAG, target_id: NA_TAG, statistics: NA_HASH) ⇒ HeimdallDataFormat

Returns a new instance of HeimdallDataFormat.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/heimdall_tools/hdf.rb', line 15

def initialize(profile_name: NA_TAG,
               version: NA_TAG,
               duration: NA_TAG,
               sha256: NA_TAG,
               title: NA_TAG,
               maintainer: NA_TAG,
               summary: NA_TAG,
               license: NA_TAG,
               copyright: NA_TAG,
               copyright_email: NA_TAG,
               supports: NA_ARRAY,
               attributes: NA_ARRAY,
               depends: NA_ARRAY,
               groups: NA_ARRAY,
               status: 'loaded',
               controls: NA_TAG,
               target_id: NA_TAG,
               statistics: NA_HASH)

  @results_json = {}
  @results_json['platform'] = {}
  @results_json['platform']['name'] = 'Heimdall Tools'
  @results_json['platform']['release'] = HeimdallTools::VERSION
  @results_json['platform']['target_id'] = target_id.to_s
  @results_json['version'] = HeimdallTools::VERSION

  @results_json['statistics'] = {}
  @results_json['statistics']['duration'] = duration || NA_TAG
  @results_json['statistics'].merge! statistics

  @results_json['profiles'] = []

  profile_block = {}
  profile_block['name']            = profile_name
  profile_block['version']         = version
  profile_block['title']           = title
  profile_block['maintainer']      = maintainer
  profile_block['summary']         = summary
  profile_block['license']         = license
  profile_block['copyright']       = copyright
  profile_block['copyright_email'] = copyright_email
  profile_block['supports']        = supports
  profile_block['attributes']      = attributes
  profile_block['depends']         = depends
  profile_block['groups']          = groups
  profile_block['status']          = status
  profile_block['controls']        = controls
  profile_block['sha256']          = OpenSSL::Digest::SHA256.digest(profile_block.to_s).unpack1('H*')
  @results_json['profiles'] << profile_block
end

Instance Method Details

#to_hdfObject



66
67
68
# File 'lib/heimdall_tools/hdf.rb', line 66

def to_hdf
  @results_json.to_json
end