Skip to main content
deleted 132 characters in body; edited tags; edited title
Source Link
200_success
  • 144.1k
  • 22
  • 188
  • 473

Request to perform security check on angularjs code AngularJS shopping cart using local storage

Two weeks ago i'veI started writing some javascriptJavascript and angularjsAngularJS code for a customer. As a proud newby I must also be aware of the dangers on the big bad internetInternet. In particular vulnerabilities such as XSS attacks.

I've already performed a vulnerability scan and this showed I didn't restrict session cookies to httponly. However nothing about the javascriptJavascript or angularjsAngularJS scripting.

Because my vocabulary of the language (javascriptMy familiarity with JavaScript and angularjs)AngularJS is somewhat limited I would appreciate it, if one of you guys do a quick check on the code. Just to be sure.

Thanks in advance

Request to perform security check on angularjs code

Two weeks ago i've started writing some javascript and angularjs code for a customer. As a proud newby I must also be aware of the dangers on the big bad internet. In particular vulnerabilities such as XSS attacks.

I've already performed a vulnerability scan and this showed I didn't restrict session cookies to httponly. However nothing about the javascript or angularjs scripting.

Because my vocabulary of the language (javascript and angularjs) is somewhat limited I would appreciate it, if one of you guys do a quick check on the code. Just to be sure.

Thanks in advance

AngularJS shopping cart using local storage

Two weeks ago I started writing some Javascript and AngularJS code for a customer. As a proud newby I must also be aware of the dangers on the big bad Internet. In particular vulnerabilities such as XSS attacks.

I've already performed a vulnerability scan and this showed I didn't restrict session cookies to httponly. However nothing about the Javascript or AngularJS scripting.

My familiarity with JavaScript and AngularJS is somewhat limited.

Source Link
RvdM
  • 21
  • 1
  • 2

Request to perform security check on angularjs code

Two weeks ago i've started writing some javascript and angularjs code for a customer. As a proud newby I must also be aware of the dangers on the big bad internet. In particular vulnerabilities such as XSS attacks.

I've already performed a vulnerability scan and this showed I didn't restrict session cookies to httponly. However nothing about the javascript or angularjs scripting.

Because my vocabulary of the language (javascript and angularjs) is somewhat limited I would appreciate it, if one of you guys do a quick check on the code. Just to be sure.

var kvv = angular.module('kvv', ['ngStorage']);

kvv.controller('CartController', ["$scope", "$localStorage", "$sessionStorage", "$timeout", function($scope, $localStorage, $sessionStorage, $timeout) {

if ($localStorage.items === undefined) {
    $localStorage.items = [];
};

$scope.localStorage = $localStorage

$scope.remove = function(index) {
  $localStorage.items.splice(index, 1);
};

$scope.checked = false;

$scope.addToCart = function(index, title, desc, price, timeout) {

  $scope.checked = true;
  var found = false;
  angular.forEach($localStorage.items, function(items) {
      if (items.id  === index) {
        $timeout(function() {
          (items.quantity++);
          $scope.checked = false;
        }, 750);
        found = true;
    }
  });
  if (!found) {
    $timeout(function() {
        $localStorage.items.push(angular.extend({
        id: index,
        title: title,
        quantity: 1,
        price: price}, index))
        $scope.checked = false;
        },750);
    }
};

$scope.itemWithoutBtw = function(index) {
    var itemWithoutBtw = 0;
    angular.forEach($localStorage.items, function(items) {
        itemWithoutBtw += items.price / 106 * 100;
    })
    return itemWithoutBtw;
};

$scope.total = function(index) {
        var total = 0;
        angular.forEach($localStorage.items, function(items) {
            total += items.quantity * items.price;
        })
        return total;
};

$scope.totalBtw = function(index) {
        var totalBtw = 0;
        var total = $scope.total();
        angular.forEach($localStorage.items, function(items) {
            totalBtw = total / 106 * 6;
        })
        return totalBtw;
};

$scope.totalWithBtw = function(index) {
        var totalWithBtw = 0;
        angular.forEach($localStorage.items, function(items) {
            totalWithBtw += (items.quantity * items.price) + (items.quantity * items.price  / 100 * 6);
        })
        return totalWithBtw;
};
$scope.totalWithoutBtw = function(index) {
        var total = $scope.total();
        var totalBtw = $scope.totalBtw();
        var totalWithoutBtw = 0;
        angular.forEach($localStorage.items, function(items) {
            totalWithoutBtw = total - totalBtw;
        })
        return totalWithoutBtw;
};

$scope.orderTotal = function(index) {
        var orderTotal = 0;
        angular.forEach($localStorage.items, function(items) {
            orderTotal += items.quantity;
        })
        return orderTotal;
};

$scope.orderDelete = function(index) {
    delete $localStorage.items;
    $localStorage.items = [];
    $('html, body').animate({scrollTop: 0}, 2500);
};

}]);

Thanks in advance