Class: Emasser::ScanFindings
- Inherits:
-
SubCommandBase
- Object
- Thor
- SubCommandBase
- Emasser::ScanFindings
- Defined in:
- lib/emasser/post.rb
Overview
The Static Code Scans endpoint provides the ability to upload application scan findings into a system’s assets module.
Application findings can also be cleared from the system.
Endpoint:
/api/systems/{systemId}/static-code-scans - Upload static code scans
Class Method Summary collapse
Instance Method Summary collapse
- #add ⇒ Object
-
#clear ⇒ Object
NOTE: clearFindings is a required parameter to clear an application’s findings, however Thor does not allow a boolean type to be required because it automatically creates a –no-clearFindings option for clearFindings=false.
Methods inherited from SubCommandBase
Methods included from OutputConverters
#change_to_datetime, #to_output_hash
Methods included from InputConverters
Methods included from OptionsParser
#optional_options, #required_options
Class Method Details
.exit_on_failure? ⇒ Boolean
1069 1070 1071 |
# File 'lib/emasser/post.rb', line 1069 def self.exit_on_failure? true end |
Instance Method Details
#add ⇒ Object
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 |
# File 'lib/emasser/post.rb', line 1087 def add application = EmassClient::StaticCodeRequestPostBodyApplication.new application.application_name = [:applicationName] application.version = [:version] application_findings = EmassClient::StaticCodeApplicationPost.new application_findings.code_check_name = [:codeCheckName] application_findings.scan_date = [:scanDate] application_findings.cwe_id = [:cweId] application_findings.count = [:count] application_findings.raw_severity = [:rawSeverity] if [:rawSeverity] app_findings_array = Array.new(1, application_findings) body = EmassClient::StaticCodeRequestPostBody.new body.application = application body.application_findings = app_findings_array body_array = Array.new(1, body) begin result = EmassClient::StaticCodeScansApi .new.add_static_code_scans_by_system_id([:systemId], body_array) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling StaticCodeScansApi->add_static_code_scans_by_system_id'.red puts to_output_hash(e) end end |
#clear ⇒ Object
NOTE: clearFindings is a required parameter to clear an application’s findings, however Thor does not allow a boolean type to be required because it automatically creates a –no-clearFindings option for clearFindings=false
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 |
# File 'lib/emasser/post.rb', line 1129 def clear unless [:clearFindings] puts 'To clear an application findings, the field clearFindings (--clearFindings) is required'.red puts SCAN_POST_HELP_MESSAGE.yellow exit end application = EmassClient::StaticCodeRequestPostBodyApplication.new application.application_name = [:applicationName] application.version = [:version] application_findings = EmassClient::StaticCodeApplicationPost.new application_findings.clear_findings = [:clearFindings] app_findings_array = Array.new(1, application_findings) body = EmassClient::StaticCodeRequestPostBody.new body.application = application body.application_findings = app_findings_array body_array = Array.new(1, body) begin result = EmassClient::StaticCodeScansApi .new.add_static_code_scans_by_system_id([:systemId], body_array) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling StaticCodeScansApi->add_static_code_scans_by_system_id'.red puts to_output_hash(e) end end |