knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pzamp...@apache.org
Subject [3/3] knox git commit: KNOX-1202 - Validate resource names
Date Tue, 08 May 2018 19:10:03 GMT
KNOX-1202 - Validate resource names


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/b509532d
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/b509532d
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/b509532d

Branch: refs/heads/master
Commit: b509532d18fe1c50fc499e9fd36870ccf74bb07e
Parents: c7477c1
Author: Phil Zampino <pzampino@apache.org>
Authored: Tue May 8 12:37:45 2018 -0400
Committer: Phil Zampino <pzampino@apache.org>
Committed: Tue May 8 14:53:41 2018 -0400

----------------------------------------------------------------------
 .../new-desc-wizard/new-desc-wizard.component.html  |  6 ++++--
 .../new-desc-wizard/new-desc-wizard.component.ts    | 16 ++++++++++++----
 .../provider-config-wizard.component.html           |  5 ++++-
 .../provider-config-wizard.component.ts             |  7 ++++++-
 .../src/app/topology-detail.component.ts            |  7 ++++++-
 gateway-admin-ui/src/app/utils/validation-utils.ts  |  5 +++++
 .../resources/applications/admin-ui/app/index.html  |  2 +-
 .../app/inline.97145cb3f7da2477fe2e.bundle.js       |  1 +
 .../app/inline.fda93ec14cbb0120997c.bundle.js       |  1 -
 .../app/main.b427e539938a9e0d8c92.bundle.js         |  1 +
 .../app/main.cf8a43d8be4617b91d5c.bundle.js         |  1 -
 11 files changed, 40 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.html
----------------------------------------------------------------------
diff --git a/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.html b/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.html
index 2a39585..7a0d19f 100644
--- a/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.html
+++ b/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.html
@@ -9,7 +9,8 @@
         <span>
           <strong>Name</strong> <input type="text" [(ngModel)]="descriptorName">
         </span>
-        <span *ngIf="!isValidDescriptorName()" style="color: red">required</span>
+        <span *ngIf="isMissingDescriptorName()" style="color: red">required</span>
+        <span *ngIf="!isMissingDescriptorName() && !isValidDescriptorName()" style="color:
red">invalid</span>
       </div> <!-- Descriptor Name -->
 
       <br>
@@ -37,7 +38,8 @@
             <span class="glyphicon glyphicon-edit"></span>
           </button>
         <app-provider-config-selector #choosePC></app-provider-config-selector>
-        <span *ngIf="!isValidProviderConfig()" style="color: red">required</span>
+        <span *ngIf="isMissingProviderConfig()" style="color: red">required</span>
+        <span *ngIf="!isMissingProviderConfig() && !isValidProviderConfig()" style="color:
red">invalid</span>
       </div> <!-- Provider Config reference -->
 
       <br>

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.ts
----------------------------------------------------------------------
diff --git a/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.ts b/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.ts
index ef2e8e2..246416c 100644
--- a/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.ts
+++ b/gateway-admin-ui/src/app/new-desc-wizard/new-desc-wizard.component.ts
@@ -185,21 +185,29 @@ export class NewDescWizardComponent implements OnInit {
     return isValid;
   }
 
+  isMissingDescriptorName(): boolean {
+    return !ValidationUtils.isValidString(this.descriptorName);
+  }
+
   isValidDescriptorName(): boolean {
     let isValid: boolean = false;
 
-    if (this.descriptorName) {
-      isValid = ValidationUtils.isValidString(this.descriptorName);
+    if (!this.isMissingDescriptorName()) {
+      isValid = ValidationUtils.isValidResourceName(this.descriptorName);
     }
 
     return isValid;
   }
 
+  isMissingProviderConfig(): boolean {
+    return (!this.descriptor || !ValidationUtils.isValidString(this.descriptor.providerConfig));
+  }
+
   isValidProviderConfig(): boolean {
     let isValid: boolean = false;
 
-    if (this.descriptor.providerConfig) {
-      isValid = ValidationUtils.isValidString(this.descriptor.providerConfig);
+    if (!this.isMissingProviderConfig()) {
+      isValid = ValidationUtils.isValidResourceName(this.descriptor.providerConfig);
     }
 
     return isValid;

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.html
----------------------------------------------------------------------
diff --git a/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.html
b/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.html
index c437d82..97377e2 100644
--- a/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.html
+++ b/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.html
@@ -17,7 +17,10 @@
                        size="60"
                        [(ngModel)]="name">
               <span *ngIf="field.errors?.required" style="color: red">
-                &nbsp;A provider configuration name is required.
+                &nbsp;required
+              </span>
+              <span *ngIf="!field.errors?.required && !isValidProviderConfigName()"
style="color: red">
+                &nbsp;invalid
               </span>
             </td>
           </tr>

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.ts
----------------------------------------------------------------------
diff --git a/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.ts
b/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.ts
index af5af86..628a932 100644
--- a/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.ts
+++ b/gateway-admin-ui/src/app/provider-config-wizard/provider-config-wizard.component.ts
@@ -31,6 +31,7 @@ import {OrderedParamContainer} from "./ordered-param-container";
 import {HostMapProviderWizard} from "./hostmap-provider-wizard";
 import {ProviderContributorWizard} from "./ProviderContributorWizard";
 import {WebAppSecurityWizard} from "./webappsec-wizard";
+import {ValidationUtils} from "../utils/validation-utils";
 
 
 @Component({
@@ -74,7 +75,7 @@ export class ProviderConfigWizardComponent implements OnInit {
 
   private step: number = 0;
 
-  name: String = '';
+  name: string = '';
 
   providers: Array<ProviderConfig> = [];
 
@@ -352,6 +353,10 @@ export class ProviderConfigWizardComponent implements OnInit {
     return result;
   }
 
+  isValidProviderConfigName(): boolean {
+    return ValidationUtils.isValidResourceName(this.name);
+  }
+
   isPasswordParam(name: string) {
     let result: boolean = false;
 

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-admin-ui/src/app/topology-detail.component.ts
----------------------------------------------------------------------
diff --git a/gateway-admin-ui/src/app/topology-detail.component.ts b/gateway-admin-ui/src/app/topology-detail.component.ts
index c21e578..1dd413d 100644
--- a/gateway-admin-ui/src/app/topology-detail.component.ts
+++ b/gateway-admin-ui/src/app/topology-detail.component.ts
@@ -22,6 +22,7 @@ import { ResourceService } from "./resource/resource.service";
 
 import 'brace/theme/monokai';
 import 'brace/mode/xml';
+import {ValidationUtils} from "./utils/validation-utils";
 
 @Component({
     selector: 'topology-detail',
@@ -65,7 +66,7 @@ import 'brace/mode/xml';
          </bs-modal-body>
          <bs-modal-footer>
            <button type="button" class="btn btn-default btn-sm" data-dismiss="duplicateModal"
(click)="duplicateModal.dismiss()">Cancel</button>
-           <button type="button" class="btn btn-primary btn-sm" [disabled]="!newTopologyName"
(click)="duplicateModal.close()">Ok</button>
+           <button type="button" class="btn btn-primary btn-sm" [disabled]="!isValidNewTopologyName()"
(click)="duplicateModal.close()">Ok</button>
          </bs-modal-footer>
        </bs-modal>
        <bs-modal (onClose)="deleteTopology()" #deleteConfirmModal>
@@ -148,6 +149,10 @@ export class TopologyDetailComponent implements OnInit {
         }
     }
 
+    isValidNewTopologyName(): boolean {
+      return ValidationUtils.isValidResourceName(this.newTopologyName);
+    }
+
     /*
     * Parse the XML and depending on the  
     * provided tag value make the editor read only

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-admin-ui/src/app/utils/validation-utils.ts
----------------------------------------------------------------------
diff --git a/gateway-admin-ui/src/app/utils/validation-utils.ts b/gateway-admin-ui/src/app/utils/validation-utils.ts
index 79e9d07..57680e2 100644
--- a/gateway-admin-ui/src/app/utils/validation-utils.ts
+++ b/gateway-admin-ui/src/app/utils/validation-utils.ts
@@ -48,6 +48,8 @@ export class ParsedURL {
 
 export class ValidationUtils {
 
+  private static VALID_NAME_REGEXP: RegExp = new RegExp('^[\\w\\d-_]*$')
+
   private static DN_TEMPLATE_REGEXP: RegExp =
     new RegExp('(?:[A-Za-z][\\w-]*|\\d+(?:\\.\\d+)*)' +
       '=(?:#(?:[\\dA-Fa-f]{2})+|(?:[^,=\\+<>#;\\"]|\\[,=\\+<>#;\\"]|\\[\\dA-Fa-f]{2})*|"(?:[^\\"]|\\[,=\\+<>#;\\"]|\\[\\dA-Fa-f]{2})*")'
+
@@ -115,6 +117,9 @@ export class ValidationUtils {
     return isValid;
   }
 
+  static isValidResourceName(name: string): boolean {
+    return ValidationUtils.isValidString(name) && ValidationUtils.VALID_NAME_REGEXP.test(name);
+  }
 
   static isValidURL(url: string): boolean {
     let isValid: boolean = false;

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-applications/src/main/resources/applications/admin-ui/app/index.html
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/admin-ui/app/index.html
b/gateway-applications/src/main/resources/applications/admin-ui/app/index.html
index d25f2da..537a4d9 100644
--- a/gateway-applications/src/main/resources/applications/admin-ui/app/index.html
+++ b/gateway-applications/src/main/resources/applications/admin-ui/app/index.html
@@ -11,4 +11,4 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
---><!doctype html><html><head><meta charset="utf-8"><title>Apache
Knox Manager</title><meta name="viewport" content="width=device-width,initial-scale=1"><link
rel="icon" type="image/x-icon" href="favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1"><!--
Latest compiled and minified CSS --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><!--
Optional theme --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"><!--
Custom styles for this template --><link href="assets/sticky-footer.css" rel="stylesheet"><script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script><!--
Latest compiled and minified JavaScript --><scr
 ipt src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script><script src="assets/vkbeautify.js"></script><link
href="styles.2ee5b7f4cd59a6cf015e.bundle.css" rel="stylesheet"/></head><body><div
class="navbar-wrapper"><div class="container-fluid"><nav class="navbar navbar-inverse
navbar-static-top"><div class="container-fluid"><div class="navbar-header"><button
type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span></button> <a class="navbar-brand" href="#"><img
style="max-width:200px; margin-top: -9px;" src="assets/knox-logo-transparent.gif" alt="Apache
Knox Manager"></a></div></div></nav></div><!-- Content
--><resource-management></res
 ource-management><footer class="footer"><div class="container-fluid"><div>Knox
Manager Version 1.0.0</div><gateway-version></gateway-version></div></footer><script
type="text/javascript" src="inline.fda93ec14cbb0120997c.bundle.js"></script><script
type="text/javascript" src="scripts.c50bb762c438ae0f8842.bundle.js"></script><script
type="text/javascript" src="main.cf8a43d8be4617b91d5c.bundle.js"></script></div></body></html>
\ No newline at end of file
+--><!doctype html><html><head><meta charset="utf-8"><title>Apache
Knox Manager</title><meta name="viewport" content="width=device-width,initial-scale=1"><link
rel="icon" type="image/x-icon" href="favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1"><!--
Latest compiled and minified CSS --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><!--
Optional theme --><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"><!--
Custom styles for this template --><link href="assets/sticky-footer.css" rel="stylesheet"><script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script><!--
Latest compiled and minified JavaScript --><scr
 ipt src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script><script src="assets/vkbeautify.js"></script><link
href="styles.2ee5b7f4cd59a6cf015e.bundle.css" rel="stylesheet"/></head><body><div
class="navbar-wrapper"><div class="container-fluid"><nav class="navbar navbar-inverse
navbar-static-top"><div class="container-fluid"><div class="navbar-header"><button
type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span></button> <a class="navbar-brand" href="#"><img
style="max-width:200px; margin-top: -9px;" src="assets/knox-logo-transparent.gif" alt="Apache
Knox Manager"></a></div></div></nav></div><!-- Content
--><resource-management></res
 ource-management><footer class="footer"><div class="container-fluid"><div>Knox
Manager Version 1.0.0</div><gateway-version></gateway-version></div></footer><script
type="text/javascript" src="inline.97145cb3f7da2477fe2e.bundle.js"></script><script
type="text/javascript" src="scripts.c50bb762c438ae0f8842.bundle.js"></script><script
type="text/javascript" src="main.b427e539938a9e0d8c92.bundle.js"></script></div></body></html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-applications/src/main/resources/applications/admin-ui/app/inline.97145cb3f7da2477fe2e.bundle.js
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/admin-ui/app/inline.97145cb3f7da2477fe2e.bundle.js
b/gateway-applications/src/main/resources/applications/admin-ui/app/inline.97145cb3f7da2477fe2e.bundle.js
new file mode 100644
index 0000000..64efea2
--- /dev/null
+++ b/gateway-applications/src/main/resources/applications/admin-ui/app/inline.97145cb3f7da2477fe2e.bundle.js
@@ -0,0 +1 @@
+!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,c,u){for(var a,i,f,l=0,s=[];l<r.length;l++)t[i=r[l]]&&s.push(t[i][0]),t[i]=0;for(a
in c)Object.prototype.hasOwnProperty.call(c,a)&&(e[a]=c[a]);for(n&&n(r,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=o(o.s=u[l]);return
f};var r={},t={2:0};function o(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return
e[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.e=function(e){var n=t[e];if(0===n)return
new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,o){n=t[e]=[r,o]});n[2]=r;var
c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,o.nc&&u.setAttribute("nonce",o.nc),u.src=o.p+""+e+"."+{0:"b427e539938a9e0d8c92",1:"aed76669724804835353"}[e]+".chunk.js";var
a=setTimeout(i,12e4);function i(){u.onerror=u.onload=null,clearTimeout(a);var n=t[e];0!==n&&(n&&n[1](new
Error("Loading chu
 nk "+e+" failed.")),t[e]=void 0)}return u.onerror=u.onload=i,c.appendChild(u),r},o.m=e,o.c=r,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},o.n=function(e){var
n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return
Object.prototype.hasOwnProperty.call(e,n)},o.p="",o.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/b509532d/gateway-applications/src/main/resources/applications/admin-ui/app/inline.fda93ec14cbb0120997c.bundle.js
----------------------------------------------------------------------
diff --git a/gateway-applications/src/main/resources/applications/admin-ui/app/inline.fda93ec14cbb0120997c.bundle.js
b/gateway-applications/src/main/resources/applications/admin-ui/app/inline.fda93ec14cbb0120997c.bundle.js
deleted file mode 100644
index f85b8d1..0000000
--- a/gateway-applications/src/main/resources/applications/admin-ui/app/inline.fda93ec14cbb0120997c.bundle.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,c,u){for(var a,i,f,l=0,s=[];l<r.length;l++)t[i=r[l]]&&s.push(t[i][0]),t[i]=0;for(a
in c)Object.prototype.hasOwnProperty.call(c,a)&&(e[a]=c[a]);for(n&&n(r,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=o(o.s=u[l]);return
f};var r={},t={2:0};function o(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return
e[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.e=function(e){var n=t[e];if(0===n)return
new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,o){n=t[e]=[r,o]});n[2]=r;var
c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,o.nc&&u.setAttribute("nonce",o.nc),u.src=o.p+""+e+"."+{0:"cf8a43d8be4617b91d5c",1:"aed76669724804835353"}[e]+".chunk.js";var
a=setTimeout(i,12e4);function i(){u.onerror=u.onload=null,clearTimeout(a);var n=t[e];0!==n&&(n&&n[1](new
Error("Loading chu
 nk "+e+" failed.")),t[e]=void 0)}return u.onerror=u.onload=i,c.appendChild(u),r},o.m=e,o.c=r,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},o.n=function(e){var
n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return
Object.prototype.hasOwnProperty.call(e,n)},o.p="",o.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file


Mime
View raw message