Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fluid.each(entry.scope, function (preference) {
if (preference === "*") { // ontology independent wildcard - leave as is
tmpEntry.scope.push(preference);
return;
}
if (fluid.model.transform.hasWildcard(preference)) {
// explode wildcard preference to paths, and set all of these in toTransform
var paths = fluid.model.transform.collectInputPaths(transformSpec);
var prefix = preference.substring(0, preference.indexOf("*"));
for (var i in paths) {
var path = paths[i];
// each matching path should be added to toTransform for trannsform
if (path.indexOf(prefix) === 0) {
fluid.set(toTransform, path, true, fluid.model.escapedSetConfig);
}
}
return;
}
fluid.set(toTransform, preference, true, fluid.model.escapedSetConfig);
});
// transform to new ontology and collect all paths with 'true' value - these equal
gpii.settingsHandlers.XMLHandler.parser.stringify = function (content, options) {
options = options || {};
// Create XML - first line is the xml-tag from options if set.
var xml = options["xml-tag"] || "";
// Get inverse transformation rules.
var invertedJSON;
if (options.rules) {
var inverseRules = fluid.model.transform.invertConfiguration(
options.rules);
// Transform back.
invertedJSON = fluid.model.transformWithRules(content,
inverseRules);
} else {
invertedJSON = content;
}
xml += xm.toxml(invertedJSON);
// Fix indentation/newlines so it's readable.
xml = gpii.settingsHandlers.XMLHandler.formatXml(xml);
return xml;
};
gpii.metrics.preferenceChanged = function (that, current, previous) {
var diff = { changeMap: {}, changes: 0, unchanged: 0};
var same = fluid.model.diff(previous, current, diff);
if (!same) {
var changedPreferences;
if (fluid.isPlainObject(diff.changeMap)) {
changedPreferences = {};
fluid.each(diff.changeMap, function (value, key) {
if (value === "ADD") {
changedPreferences[key] = current[key];
}
});
} else if (diff.changeMap === "ADD") {
// Everything is new
changedPreferences = current;
}
fluid.each(changedPreferences, function (value, name) {
that.logMetric("preference", {
gpii.settingsHandlers.XMLHandler.parser.stringify = function (content, options) {
options = options || {};
// Create XML - first line is the xml-tag from options if set.
var xml = options["xml-tag"] || "";
// Get inverse transformation rules.
var invertedJSON;
if (options.rules) {
var inverseRules = fluid.model.transform.invertConfiguration(
options.rules);
// Transform back.
invertedJSON = fluid.model.transformWithRules(content,
inverseRules);
} else {
invertedJSON = content;
}
xml += xm.toxml(invertedJSON);
// Fix indentation/newlines so it's readable.
xml = gpii.settingsHandlers.XMLHandler.formatXml(xml);
return xml;
};
gpii.universal.solutionsRegistry.validators.validateRequest = function (that, globalValidator, requestHandler) {
var transformationRules = that.options.rules.outerPayload;
var outerPayload = fluid.model.transformWithRules(requestHandler.req, transformationRules);
var validationStages = [];
// "gross" validation based on the overall structure
validationStages.push(gpii.universal.solutionsRegistry.validators.singleValidation(that, globalValidator, that.options.baseSchema, outerPayload, that.options.baseSchemaHash));
// "deep" validation of individual settings, per solution.
var innerPayload = fluid.model.transformWithRules(requestHandler.req, that.options.rules.innerPayload);
fluid.each(innerPayload, function (solutionPayload, solutionURI) {
var solutionSchema = that.options.codex[solutionURI];
if (solutionSchema) {
if (!that.schemaHashesByUri[solutionURI]) {
that.schemaHashesByUri[solutionURI] = gpii.schema.hashSchema(solutionSchema);
}
validationStages.push(gpii.universal.solutionsRegistry.validators.singleValidation(that, globalValidator, solutionSchema, solutionPayload, that.schemaHashesByUri[solutionURI], [solutionURI]));
}
});
// Although our validation is synchronous, we use this pattern so that processing will be cleanly interrupted on the
// first validation error.
return fluid.promise.sequence(validationStages);
};
gpii.settingsHandlers.XMLHandler.parser.parse = function (content, options) {
// Parse XML to JSON.
var json = xm.tojson(content);
// Apply the settings
return (options && options.rules) ?
fluid.model.transformWithRules(json, options.rules) :
json;
};
fluid.each(processes, function (process, pindex) {
testDef.sequence.push({
func: "{exec}.exec",
args: [
fluid.model.composeSegments("{tests}.options.processes",
pindex),
fluid.model.composeSegments("{tests}.options.processes", pindex,
"expectConfigured")
]
}, {
event: "{exec}.events.onExecExit",
listener: "gpii.acceptanceTesting.onExecExit"
});
});
fluid.each(processes, function (process, pindex) {
testDef.sequence.push({
func: "{exec}.exec",
args: [
fluid.model.composeSegments("{tests}.options.processes",
pindex),
fluid.model.composeSegments("{tests}.options.processes", pindex,
"expectRestored")
]
}, {
event: "{exec}.events.onExecExit",
listener: "gpii.acceptanceTesting.onExecExit"
});
});
if (aDoc.schemaVersion !== gpii.migration.GPII4014.newSchemaVersion) {
console.log("Error with the document _id \"" + aDoc._id + "\": schema version is ", aDoc.schemaVersion, ", not ", gpii.migration.GPII4014.newSchemaVersion);
hasError = true;
}
if (aDoc.timestampUpdated === null) {
console.log("Error with the document _id \"" + aDoc._id + "\": the value of timestampUpdated is empty");
hasError = true;
}
if (aDoc.type === "clientCredential") {
var docFields = {
allowedIPBlocks: aDoc.allowedIPBlocks,
allowedPrefsToWrite: aDoc.allowedPrefsToWrite,
isCreateGpiiKeyAllowed: aDoc.isCreateGpiiKeyAllowed,
isCreatePrefsSafeAllowed: aDoc.isCreatePrefsSafeAllowed
};
var diffResult = fluid.model.diff(
docFields,
options.novaClientCredentials.includes(aDoc._id) ? gpii.migration.GPII4014.newValuesForNovaClientCredential : gpii.migration.GPII4014.newValuesForPublicClientCredential
);
if (!diffResult) {
console.log("Error with the document _id \"" + aDoc._id + "\": new field values for client credential are incorrect - ", docFields);
hasError = true;
}
}
}
if (hasError) {
numOfErrorDocs++;
}
});
console.log("The database has " + totalNumOfDocs + " documents. " + numOfVerified + " documents are qualified for verifications.");
fluid.each(preferences.applications, function (val, id) {
var trans = inverseCapabilities[id];
if (trans) {
$.extend(true, togo, fluid.model.transformWithRules(val.parameters, trans));
}
});
return togo;