aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/cloudify.js6
-rw-r--r--lib/deploy.js6
-rw-r--r--lib/logging.js9
-rw-r--r--lib/promise_request.js4
4 files changed, 18 insertions, 7 deletions
diff --git a/lib/cloudify.js b/lib/cloudify.js
index 303134a..23e779a 100644
--- a/lib/cloudify.js
+++ b/lib/cloudify.js
@@ -76,6 +76,8 @@ var delay = function(dtime) {
// Get current status of a workflow execution
const getExecutionStatus = function(execution_id, mainReq) {
+ /* Defense: Some callers do not supply mainReq */
+ mainReq = mainReq || {};
var reqOptions = {
method : "GET",
uri : cfyAPI + "/executions/" + execution_id
@@ -86,6 +88,8 @@ const getExecutionStatus = function(execution_id, mainReq) {
// Poll for the result of a workflow execution until it's done
var getWorkflowResult = function(execution_id, mainReq) {
+ /* Defense: Some callers do not supply mainReq */
+ mainReq = mainReq || {};
logger.debug(mainReq.dcaeReqId, "Getting workflow result for execution id: " + execution_id);
// Function for testing if workflow is finished
@@ -158,6 +162,8 @@ var getWorkflowResult = function(execution_id, mainReq) {
// bare start of a workflow execution against a deployment
const startWorkflowExecution = function(mainReq, deployment_id, workflow_id, parameters) {
+ /* Defense: Some callers do not supply mainReq */
+ mainReq = mainReq || {};
// Set up the HTTP POST request
var reqOptions = {
method : "POST",
diff --git a/lib/deploy.js b/lib/deploy.js
index 741affb..7f83620 100644
--- a/lib/deploy.js
+++ b/lib/deploy.js
@@ -160,7 +160,7 @@ const launchBlueprint = function(id, blueprint, inputs) {
.catch(function(error) {
logger.debug(null, "Error: " + error + " for launch blueprint for deploymentId " + id);
throw normalizeError(error);
- })
+ });
};
exports.launchBlueprint = launchBlueprint;
@@ -191,7 +191,7 @@ const finishInstallation = function(deploymentId, executionId) {
logger.debug(null, "Error finishing install workflow: " + err + " -- " + JSON.stringify(err));
throw normalizeError(err);
});
-}
+};
exports.finishInstallation = finishInstallation;
// Initiate uninstall workflow against a deployment, but don't wait for workflow to finish
@@ -239,7 +239,7 @@ exports.getExecutionStatus = function (exid) {
var result = {
operationType: res.json.workflow_id
- }
+ };
// Map execution status
if (res.json.status === "terminated") {
diff --git a/lib/logging.js b/lib/logging.js
index 4d85898..a21f37e 100644
--- a/lib/logging.js
+++ b/lib/logging.js
@@ -140,7 +140,7 @@ const formatAuditRecord = function(req, status, extra) {
rec[AUDIT_CATLOGLEVEL] = "INFO"; // The audit records are informational, regardless of the outcome of the operation
rec[AUDIT_SRVIP] = req.socket.address().address;
rec[AUDIT_ELAPSED] = end - req.startTime;
- rec[AUDIT_SERVER] = req.hostname // From the Host header, again
+ rec[AUDIT_SERVER] = req.hostname; // From the Host header, again
rec[AUDIT_CLIENTIP] = req.connection.remoteAddress;
if (extra) {
@@ -169,8 +169,9 @@ const formatMetricsRecord = function(req, opInfo, extra) {
rec[METRICS_REQID] = req.dcaeReqId;
rec[METRICS_SRVNAME] = req.hostname; // Use name from the host header
rec[METRICS_SVCNAME] = req.method + ' ' + req.originalUrl; // Method and URL identify the operation being performed
- rec[METRICS_CLIENTIP] = req.connection.remoteAddress;
- rec[METRICS_SRVIP] = req.socket.address().address;
+ /* Defense: some clients will pass in a req that's incomplete */
+ if (req.connection) {rec[METRICS_CLIENTIP] = req.connection.remoteAddress;}
+ if (req.socket) {rec[METRICS_SRVIP] = req.socket.address().address;}
}
else {
/* No incoming request */
@@ -259,7 +260,7 @@ exports.getLogger = function() {
debug: function(reqId, msg) {
debugLogger.debug(formatDebugRecord(reqId, msg));
}
- }
+ };
};
exports.setLevel = function(level) {
diff --git a/lib/promise_request.js b/lib/promise_request.js
index bda4d66..0572ac4 100644
--- a/lib/promise_request.js
+++ b/lib/promise_request.js
@@ -32,6 +32,10 @@ const querystring = require('querystring');
const logger = require('./logging').getLogger();
exports.doRequest = function(options, body, targetEntity, mainReq) {
+
+ /* Defense: for now, some callers don't provide mainReq */
+ mainReq = mainReq || {};
+
var opInfo = {"startTime":new Date(), "targetEntity": targetEntity};
return new Promise(function(resolve, reject) {