URL: https://github.com/freeipa/freeipa/pull/712
Author: pvomacka
 Title: #712: WebUI: Coverity fixes
Action: opened

PR body:
"""
Several fixes: 

- null pointer exception
- add explicit object
- removes identical branches of if statement

"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/712/head:pr712
git checkout pr712
From bcd280b6bebed9853522029a04e141c84fc7c2e2 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 13 Apr 2017 11:04:47 +0200
Subject: [PATCH 1/3] WebUI: Coverity - add explicit window object to alert
 methods

All calls of alert were without explicit object. This commit
adds explicit object window.
---
 install/ui/src/freeipa/association.js | 10 +++++-----
 install/ui/src/freeipa/dns.js         |  2 +-
 install/ui/src/freeipa/search.js      |  2 +-
 install/ui/src/freeipa/sudo.js        |  4 ++--
 install/ui/src/freeipa/widget.js      |  2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 27a76a5..dcb78f1 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -116,7 +116,7 @@ IPA.serial_associator = function(spec) {
 
             batch.add_command(command);
         }
-        //alert(JSON.stringify(command.to_json()));
+        //window.alert(JSON.stringify(command.to_json()));
 
         batch.execute();
     };
@@ -154,7 +154,7 @@ IPA.bulk_associator = function(spec) {
 
         command.set_option(that.other_entity.name, that.values);
 
-        //alert(JSON.stringify(command.to_json()));
+        //window.alert(JSON.stringify(command.to_json()));
 
         command.execute();
     };
@@ -731,7 +731,7 @@ IPA.association_table_widget = function (spec) {
 
         if (!selected_values.length) {
             var message = text.get('@i18n:dialogs.remove_empty');
-            alert(message);
+            window.alert(message);
             return;
         }
 
@@ -1268,7 +1268,7 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) {
 
         if (!values.length) {
             var message = text.get('@i18n:dialogs.remove_empty');
-            alert(message);
+            window.alert(message);
             return;
         }
 
@@ -1579,7 +1579,7 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) {
 
         if (!selected_values.length) {
             var message = text.get('@i18n:dialogs.remove_empty');
-            alert(message);
+            window.alert(message);
             return;
         }
 
diff --git a/install/ui/src/freeipa/dns.js b/install/ui/src/freeipa/dns.js
index 1ea3aaa..1be8513 100644
--- a/install/ui/src/freeipa/dns.js
+++ b/install/ui/src/freeipa/dns.js
@@ -1949,7 +1949,7 @@ IPA.dns.record_type_table_widget = function(spec) {
 
         if (!selected_values.length) {
             var message = text.get('@i18n:dialogs.remove_empty');
-            alert(message);
+            window.alert(message);
             return;
         }
 
diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index e2fbf44..fd7174d 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -213,7 +213,7 @@ IPA.search_facet = function(spec, no_init) {
         var title;
         if (!values.length) {
             title = text.get('@i18n:dialogs.remove_empty');
-            alert(title);
+            window.alert(title);
             return null;
         }
 
diff --git a/install/ui/src/freeipa/sudo.js b/install/ui/src/freeipa/sudo.js
index 44c9a20..733e411 100644
--- a/install/ui/src/freeipa/sudo.js
+++ b/install/ui/src/freeipa/sudo.js
@@ -860,7 +860,7 @@ IPA.sudo.options_section = function(spec) {
 
         if (!values.length) {
             var message = text.get('@i18n:dialogs.remove_empty');
-            alert(message);
+            window.alert(message);
             return;
         }
 
@@ -952,4 +952,4 @@ exp.register = function() {
 phases.on('registration', exp.register);
 
 return exp;
-});
\ No newline at end of file
+});
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index b7a6504..495e294 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -4331,7 +4331,7 @@ IPA.attribute_table_widget = function(spec) {
 
         if (!selected_values.length) {
             var message = text.get('@i18n:dialogs.remove_empty');
-            alert(message);
+            window.alert(message);
             return null;
         }
 

From c3c0909e6f2f1d451dde04b9c79a6e058bec838e Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 13 Apr 2017 12:03:08 +0200
Subject: [PATCH 2/3] WebUI - Coverity: fixed null pointer exception

The record variable could be null. This check makes sure
that variable won't be null.
---
 install/ui/src/freeipa/field.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js
index 76ce253..4cd9f13 100644
--- a/install/ui/src/freeipa/field.js
+++ b/install/ui/src/freeipa/field.js
@@ -888,7 +888,7 @@ field.Adapter = declare(null, {
                 if (result) record = result[this.result_name];
                 var res_type = typeof record;
                 var obj_in_type = typeof this.object_index;
-                if (res_type === 'object' && obj_in_type === 'number')
+                if (record && res_type === 'object' && obj_in_type === 'number')
                     record = record[this.object_index];
             }
         }

From 112fb1615f1989535725744dc76a53b2e32f8013 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 13 Apr 2017 13:05:44 +0200
Subject: [PATCH 3/3] WebUI - Coverity: fix identical branches of if statement

---
 install/ui/src/freeipa/vault.js | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/install/ui/src/freeipa/vault.js b/install/ui/src/freeipa/vault.js
index 36a4838..29aa546 100644
--- a/install/ui/src/freeipa/vault.js
+++ b/install/ui/src/freeipa/vault.js
@@ -379,11 +379,7 @@ vault.public_key_widget = function(spec) {
                 status = String.fromCharCode(decimal_check_i);
             }
         } else {
-            if (!value || value === '') {
-                status = text.get('@i18n:objects.publickey.status_new_ns');
-            } else {
-                status = text.get('@i18n:objects.publickey.status_new_ns');
-            }
+            status = text.get('@i18n:objects.publickey.status_new_ns');
         }
 
         return status;
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to