| 195 | } |
| 196 | |
| 197 | void IfwApiCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, |
| 198 | const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros) |
| 199 | { |
| 200 | namespace asio = boost::asio; |
| 201 | namespace http = boost::beast::http; |
| 202 | using http::field; |
| 203 | |
| 204 | REQUIRE_NOT_NULL(checkable); |
| 205 | REQUIRE_NOT_NULL(cr); |
| 206 | |
| 207 | // We're going to just resolve macros for the actual check execution happening elsewhere |
| 208 | if (resolvedMacros && !useResolvedMacros) { |
| 209 | auto commandEndpoint (checkable->GetCommandEndpoint()); |
| 210 | |
| 211 | // There's indeed a command endpoint, obviously for the actual check execution |
| 212 | if (commandEndpoint) { |
| 213 | // But it doesn't have this function, yet ("ifw-api-check-command") |
| 214 | if (!(commandEndpoint->GetCapabilities() & (uint_fast64_t)ApiCapabilities::IfwApiCheckCommand)) { |
| 215 | // Assume "ifw-api-check-command" has been imported into a check command which can also work |
| 216 | // based on "plugin-check-command", delegate respectively and hope for the best |
| 217 | PluginCheckTask::ScriptFunc(checkable, cr, producer, resolvedMacros, useResolvedMacros); |
| 218 | return; |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | CheckCommand::Ptr command = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand(); |
| 224 | auto lcr (checkable->GetLastCheckResult()); |
| 225 | |
| 226 | Host::Ptr host; |
| 227 | Service::Ptr service; |
| 228 | tie(host, service) = GetHostService(checkable); |
| 229 | |
| 230 | MacroProcessor::ResolverList resolvers; |
| 231 | |
| 232 | if (MacroResolver::OverrideMacros) |
| 233 | resolvers.emplace_back("override", MacroResolver::OverrideMacros); |
| 234 | |
| 235 | if (service) |
| 236 | resolvers.emplace_back("service", service); |
| 237 | resolvers.emplace_back("host", host); |
| 238 | resolvers.emplace_back("command", command); |
| 239 | |
| 240 | auto resolveMacros ([&resolvers, &lcr, &resolvedMacros, useResolvedMacros](const char* macros) -> Value { |
| 241 | return MacroProcessor::ResolveMacros( |
| 242 | macros, resolvers, lcr, nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros |
| 243 | ); |
| 244 | }); |
| 245 | |
| 246 | String psCommand = resolveMacros("$ifw_api_command$"); |
| 247 | Dictionary::Ptr arguments = resolveMacros("$ifw_api_arguments$"); |
| 248 | String psHost = resolveMacros("$ifw_api_host$"); |
| 249 | String psPort = resolveMacros("$ifw_api_port$"); |
| 250 | String expectedSan = resolveMacros("$ifw_api_expected_san$"); |
| 251 | String cert = resolveMacros("$ifw_api_cert$"); |
| 252 | String key = resolveMacros("$ifw_api_key$"); |
| 253 | String ca = resolveMacros("$ifw_api_ca$"); |
| 254 | String crl = resolveMacros("$ifw_api_crl$"); |
nothing calls this directly
no test coverage detected