Class: Sarif::Invocation

Inherits:
Object
  • Object
show all
Defined in:
lib/sarif/invocation.rb

Overview

The runtime environment of the analysis tool run.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_line: nil, arguments: nil, response_files: nil, start_time_utc: nil, end_time_utc: nil, exit_code: nil, rule_configuration_overrides: [], notification_configuration_overrides: [], tool_execution_notifications: [], tool_configuration_notifications: [], exit_code_description: nil, exit_signal_name: nil, exit_signal_number: nil, process_start_failure_message: nil, execution_successful:, machine: nil, account: nil, process_id: nil, executable_location: nil, working_directory: nil, environment_variables: nil, stdin: nil, stdout: nil, stderr: nil, stdout_stderr: nil, properties: nil) ⇒ Invocation

Returns a new instance of Invocation.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sarif/invocation.rb', line 8

def initialize(command_line: nil, arguments: nil, response_files: nil, start_time_utc: nil, end_time_utc: nil, exit_code: nil, rule_configuration_overrides: [], notification_configuration_overrides: [], tool_execution_notifications: [], tool_configuration_notifications: [], exit_code_description: nil, exit_signal_name: nil, exit_signal_number: nil, process_start_failure_message: nil, execution_successful:, machine: nil, account: nil, process_id: nil, executable_location: nil, working_directory: nil, environment_variables: nil, stdin: nil, stdout: nil, stderr: nil, stdout_stderr: nil, properties: nil)
  @command_line = command_line
  @arguments = arguments
  @response_files = response_files
  @start_time_utc = start_time_utc
  @end_time_utc = end_time_utc
  @exit_code = exit_code
  @rule_configuration_overrides = rule_configuration_overrides
  @notification_configuration_overrides = notification_configuration_overrides
  @tool_execution_notifications = tool_execution_notifications
  @tool_configuration_notifications = tool_configuration_notifications
  @exit_code_description = exit_code_description
  @exit_signal_name = exit_signal_name
  @exit_signal_number = exit_signal_number
  @process_start_failure_message = process_start_failure_message
  @execution_successful = execution_successful
  @machine = machine
  @account = 
  @process_id = process_id
  @executable_location = executable_location
  @working_directory = working_directory
  @environment_variables = environment_variables
  @stdin = stdin
  @stdout = stdout
  @stderr = stderr
  @stdout_stderr = stdout_stderr
  @properties = properties
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def 
  @account
end

#argumentsObject

Returns the value of attribute arguments.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def arguments
  @arguments
end

#command_lineObject

Returns the value of attribute command_line.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def command_line
  @command_line
end

#end_time_utcObject

Returns the value of attribute end_time_utc.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def end_time_utc
  @end_time_utc
end

#environment_variablesObject

Returns the value of attribute environment_variables.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def environment_variables
  @environment_variables
end

#executable_locationObject

Returns the value of attribute executable_location.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def executable_location
  @executable_location
end

#execution_successfulObject

Returns the value of attribute execution_successful.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def execution_successful
  @execution_successful
end

#exit_codeObject

Returns the value of attribute exit_code.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def exit_code
  @exit_code
end

#exit_code_descriptionObject

Returns the value of attribute exit_code_description.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def exit_code_description
  @exit_code_description
end

#exit_signal_nameObject

Returns the value of attribute exit_signal_name.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def exit_signal_name
  @exit_signal_name
end

#exit_signal_numberObject

Returns the value of attribute exit_signal_number.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def exit_signal_number
  @exit_signal_number
end

#machineObject

Returns the value of attribute machine.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def machine
  @machine
end

#notification_configuration_overridesObject

Returns the value of attribute notification_configuration_overrides.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def notification_configuration_overrides
  @notification_configuration_overrides
end

#process_idObject

Returns the value of attribute process_id.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def process_id
  @process_id
end

#process_start_failure_messageObject

Returns the value of attribute process_start_failure_message.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def process_start_failure_message
  @process_start_failure_message
end

#propertiesObject

Returns the value of attribute properties.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def properties
  @properties
end

#response_filesObject

Returns the value of attribute response_files.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def response_files
  @response_files
end

#rule_configuration_overridesObject

Returns the value of attribute rule_configuration_overrides.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def rule_configuration_overrides
  @rule_configuration_overrides
end

#start_time_utcObject

Returns the value of attribute start_time_utc.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def start_time_utc
  @start_time_utc
end

#stderrObject

Returns the value of attribute stderr.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def stderr
  @stderr
end

#stdinObject

Returns the value of attribute stdin.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def stdin
  @stdin
end

#stdoutObject

Returns the value of attribute stdout.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def stdout
  @stdout
end

#stdout_stderrObject

Returns the value of attribute stdout_stderr.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def stdout_stderr
  @stdout_stderr
end

#tool_configuration_notificationsObject

Returns the value of attribute tool_configuration_notifications.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def tool_configuration_notifications
  @tool_configuration_notifications
end

#tool_execution_notificationsObject

Returns the value of attribute tool_execution_notifications.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def tool_execution_notifications
  @tool_execution_notifications
end

#working_directoryObject

Returns the value of attribute working_directory.



6
7
8
# File 'lib/sarif/invocation.rb', line 6

def working_directory
  @working_directory
end

Class Method Details

.from_hash(h) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/sarif/invocation.rb', line 72

def self.from_hash(h)
  return nil if h.nil?
  new(
    command_line: h["commandLine"],
    arguments: h["arguments"],
    response_files: h["responseFiles"]&.map { |v| ArtifactLocation.from_hash(v) },
    start_time_utc: h["startTimeUtc"],
    end_time_utc: h["endTimeUtc"],
    exit_code: h["exitCode"],
    rule_configuration_overrides: h["ruleConfigurationOverrides"]&.map { |v| ConfigurationOverride.from_hash(v) } || [],
    notification_configuration_overrides: h["notificationConfigurationOverrides"]&.map { |v| ConfigurationOverride.from_hash(v) } || [],
    tool_execution_notifications: h["toolExecutionNotifications"]&.map { |v| Notification.from_hash(v) } || [],
    tool_configuration_notifications: h["toolConfigurationNotifications"]&.map { |v| Notification.from_hash(v) } || [],
    exit_code_description: h["exitCodeDescription"],
    exit_signal_name: h["exitSignalName"],
    exit_signal_number: h["exitSignalNumber"],
    process_start_failure_message: h["processStartFailureMessage"],
    execution_successful: h["executionSuccessful"],
    machine: h["machine"],
    account: h["account"],
    process_id: h["processId"],
    executable_location: ArtifactLocation.from_hash(h["executableLocation"]),
    working_directory: ArtifactLocation.from_hash(h["workingDirectory"]),
    environment_variables: h["environmentVariables"],
    stdin: ArtifactLocation.from_hash(h["stdin"]),
    stdout: ArtifactLocation.from_hash(h["stdout"]),
    stderr: ArtifactLocation.from_hash(h["stderr"]),
    stdout_stderr: ArtifactLocation.from_hash(h["stdoutStderr"]),
    properties: h["properties"]
  )
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



104
105
106
107
# File 'lib/sarif/invocation.rb', line 104

def ==(other)
  return false unless other.is_a?(Invocation)
  @command_line == other.command_line && @arguments == other.arguments && @response_files == other.response_files && @start_time_utc == other.start_time_utc && @end_time_utc == other.end_time_utc && @exit_code == other.exit_code && @rule_configuration_overrides == other.rule_configuration_overrides && @notification_configuration_overrides == other.notification_configuration_overrides && @tool_execution_notifications == other.tool_execution_notifications && @tool_configuration_notifications == other.tool_configuration_notifications && @exit_code_description == other.exit_code_description && @exit_signal_name == other.exit_signal_name && @exit_signal_number == other.exit_signal_number && @process_start_failure_message == other.process_start_failure_message && @execution_successful == other.execution_successful && @machine == other.machine && @account == other. && @process_id == other.process_id && @executable_location == other.executable_location && @working_directory == other.working_directory && @environment_variables == other.environment_variables && @stdin == other.stdin && @stdout == other.stdout && @stderr == other.stderr && @stdout_stderr == other.stdout_stderr && @properties == other.properties
end

#hashObject



111
112
113
# File 'lib/sarif/invocation.rb', line 111

def hash
  [@command_line, @arguments, @response_files, @start_time_utc, @end_time_utc, @exit_code, @rule_configuration_overrides, @notification_configuration_overrides, @tool_execution_notifications, @tool_configuration_notifications, @exit_code_description, @exit_signal_name, @exit_signal_number, @process_start_failure_message, @execution_successful, @machine, @account, @process_id, @executable_location, @working_directory, @environment_variables, @stdin, @stdout, @stderr, @stdout_stderr, @properties].hash
end

#to_hObject



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
65
66
# File 'lib/sarif/invocation.rb', line 37

def to_h
  h = {}
  h["commandLine"] = @command_line unless @command_line.nil?
  h["arguments"] = @arguments if @arguments&.any?
  h["responseFiles"] = @response_files&.map(&:to_h) if @response_files&.any?
  h["startTimeUtc"] = @start_time_utc unless @start_time_utc.nil?
  h["endTimeUtc"] = @end_time_utc unless @end_time_utc.nil?
  h["exitCode"] = @exit_code unless @exit_code.nil?
  h["ruleConfigurationOverrides"] = @rule_configuration_overrides&.map(&:to_h) if @rule_configuration_overrides&.any?
  h["notificationConfigurationOverrides"] = @notification_configuration_overrides&.map(&:to_h) if @notification_configuration_overrides&.any?
  h["toolExecutionNotifications"] = @tool_execution_notifications&.map(&:to_h) if @tool_execution_notifications&.any?
  h["toolConfigurationNotifications"] = @tool_configuration_notifications&.map(&:to_h) if @tool_configuration_notifications&.any?
  h["exitCodeDescription"] = @exit_code_description unless @exit_code_description.nil?
  h["exitSignalName"] = @exit_signal_name unless @exit_signal_name.nil?
  h["exitSignalNumber"] = @exit_signal_number unless @exit_signal_number.nil?
  h["processStartFailureMessage"] = @process_start_failure_message unless @process_start_failure_message.nil?
  h["executionSuccessful"] = @execution_successful
  h["machine"] = @machine unless @machine.nil?
  h["account"] = @account unless @account.nil?
  h["processId"] = @process_id unless @process_id.nil?
  h["executableLocation"] = @executable_location&.to_h unless @executable_location.nil?
  h["workingDirectory"] = @working_directory&.to_h unless @working_directory.nil?
  h["environmentVariables"] = @environment_variables unless @environment_variables.nil?
  h["stdin"] = @stdin&.to_h unless @stdin.nil?
  h["stdout"] = @stdout&.to_h unless @stdout.nil?
  h["stderr"] = @stderr&.to_h unless @stderr.nil?
  h["stdoutStderr"] = @stdout_stderr&.to_h unless @stdout_stderr.nil?
  h["properties"] = @properties unless @properties.nil?
  h
end

#to_json(pretty: false) ⇒ Object



68
69
70
# File 'lib/sarif/invocation.rb', line 68

def to_json(pretty: false)
  pretty ? JSON.pretty_generate(to_h) : JSON.generate(to_h)
end