diff options
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/DataModel.js | 6 | ||||
| -rw-r--r-- | www/js/LogCtrl.js | 44 | ||||
| -rw-r--r-- | www/js/app.js | 7 |
3 files changed, 44 insertions, 13 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index bfd81b74..711ec016 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -61,12 +61,6 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion zmLog("ZMData init: checking for stored variables & setting up log file"); - $fileLogger.setStorageFilename('zmNinjaLog.txt'); - - $fileLogger.deleteLogfile().then(function() { - console.log('Logfile deleted'); - }); - if (window.localStorage.getItem("username") != undefined) { loginData.username = window.localStorage.getItem("username"); diff --git a/www/js/LogCtrl.js b/www/js/LogCtrl.js index 1ac903a7..a4141930 100644 --- a/www/js/LogCtrl.js +++ b/www/js/LogCtrl.js @@ -2,27 +2,59 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', function ($scope, $rootScope, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer) { +angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', '$ionicPopup', function ($scope, $rootScope, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer, $ionicPopup) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; + //-------------------------------------------------------------------------- + // Make sure user knows information masking is best effort + //-------------------------------------------------------------------------- + + $scope.sendEmail = function (logstring) { + $ionicPopup.confirm({ + title: 'Sensitive Information', + template: 'zmNinja tries its best to remove sensitive data like urls and passwords, but it is eventually your responsibility to make sure there is no sensitive data in the logs. If you are not sure, please click Cancel' + }) + .then(function (res) { + if (res) sendEmailReally(logstring); + + }); + }; //-------------------------------------------------------------------------- // Convenience function to send logs via email //-------------------------------------------------------------------------- - $scope.sendEmail = function (logstring) { + function sendEmailReally(logstring) { if (window.cordova) { - // pass= password= should be replaced - //logstring = logstring.replace(/password=*?/g, 'password=xxxx' + $cordovaEmailComposer.isAvailable().then(function () { + + // do my best to replace sensitive information + var loginData = ZMDataModel.getLogin(); + var re1 = new RegExp(loginData.password, "g"); + logstring = logstring.replace(re1, "<deleted>"); + // keep the protocol, helps to debug + var urlNoProtocol = loginData.url.replace(/.*?:\/\//, ""); + var re2 = new RegExp(urlNoProtocol, "g"); + // just replacing baseurl - that will take care of + // masking api but may not be cgi + logstring = logstring.replace(re2, "<server>"); + + urlNoProtocol = loginData.streamingurl.replace(/.*?:\/\//, ""); + var re3 = new RegExp(urlNoProtocol, "g"); + logstring = logstring.replace(re3, "<server>"); + var email = { to: '', subject: 'zmNinja Logs', body: logstring, isHtml: false }; - $cordovaEmailComposer.open(email); + $cordovaEmailComposer.open(email) + .then(null, function () { + // user cancelled email + }); }, function () { ZMDataModel.zmLog("Email plugin not found", "error"); }); @@ -30,7 +62,7 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo console.log("Skipping email module as cordova does not exist"); } - }; + } //------------------------------------------------------------------------- // Lets make sure we set screen dim properly as we enter diff --git a/www/js/app.js b/www/js/app.js index bd21fabe..d7ef3f01 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -164,7 +164,7 @@ angular.module('zmApp', [ // First run in ionic //------------------------------------------------------------------ -.run(function ($ionicPlatform, $ionicPopup, $rootScope, $state, ZMDataModel, $cordovaSplashscreen, $http, $interval, zmAutoLogin) +.run(function ($ionicPlatform, $ionicPopup, $rootScope, $state, ZMDataModel, $cordovaSplashscreen, $http, $interval, zmAutoLogin, $fileLogger) { ZMDataModel.init(); @@ -221,6 +221,11 @@ angular.module('zmApp', [ ZMDataModel.zmLog("Device is ready"); console.log("**** DEVICE READY ***"); + $fileLogger.deleteLogfile().then(function() { + console.log('Logfile deleted'); + }); + $fileLogger.setStorageFilename('zmNinjaLog.txt'); + setTimeout(function () { |
