Skip to content

Latest commit

 

History

History
35 lines (32 loc) · 943 Bytes

analysis.md

File metadata and controls

35 lines (32 loc) · 943 Bytes

Analysis Code Examples

Detecting unexpected data fields

var objTemplate={ ip:['ip'], md5:['md5'] }
var fnCompareSchema=function(objMsg){
  var arrKeys=Object.keys(objMsg);
  for(var i=0;i<arrKeys.length;i++){
    if(typeof objTemplate[arrKeys[i]] === 'undefined'){
      //this is a new field, do something about it here
    }
  }
};

Detect new data type values

var objTemplate={ ip:['ip'], md5:['md5'] }
var arrDataTypes=objDataTester.test(objMsg.ip);
for(var i=0;i<arrDataTypes.length;i++){
  if(objTemplate.ip.indexOf(arrDataTypes[i]) === -1){
    //this data type isn't in the template
    console.log('new data type in msg',arrDataTypes[i]);
  }
}

look for unique values

var arrKnownValues=['127.0.0.1','75.75.75.75','8.8.8.8'];
if(arrKnownValues.indexOf(objMsg.ip) === -1){
  //this value is not in the known array of values
  console.log('new value:',objMsg.ip);
}