X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Felk%2Fclient%2FElkConnectorImpl.java;h=59bf50071f8ce5244e947b3466c015992f8bccba;hb=refs%2Fchanges%2F37%2F30337%2F8;hp=8868db3bc77375e08a18d3049f33d8e85e378a65;hpb=073cc188efe9abb4c010cf674e34e2cf46ef1c52;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/ElkConnectorImpl.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/ElkConnectorImpl.java index 8868db3bc..59bf50071 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/ElkConnectorImpl.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/ElkConnectorImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,6 +101,9 @@ public class ElkConnectorImpl implements ElkConnector{ throw e; } } + private boolean isAlphaNumeric(String query){ + return query.matches("[a-zA-Z_0-9]+"); + } @Override public JestResult search(PolicyIndexType type, String text) throws IllegalStateException, IllegalArgumentException { @@ -112,6 +115,10 @@ public class ElkConnectorImpl implements ElkConnector{ throw new IllegalArgumentException("No search string provided"); } + if(!isAlphaNumeric(text)){ + throw new IllegalArgumentException("Search must be alpha numeric"); + } + QueryStringQueryBuilder mQ = QueryBuilders.queryStringQuery("*"+text+"*"); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().query(mQ); @@ -198,6 +205,10 @@ public class ElkConnectorImpl implements ElkConnector{ return search(type, text); } + if(!isAlphaNumeric(text)){ + throw new IllegalArgumentException("Search must be alpha numeric"); + } + String matches_s = ""; matches_s = "{\n" + " \"size\" : "+ ElkConnectorImpl.QUERY_MAXRECORDS + ",\n" + @@ -322,6 +333,7 @@ public class ElkConnectorImpl implements ElkConnector{ String[] splitPolicyName = policyName.split(":"); indexType = ElkConnector.toPolicyIndexType(splitPolicyName[1]); } catch (IllegalArgumentException e) { + LOGGER.error(e); throw new IllegalStateException("ELK: Index: " + ELK_INDEX_POLICY + e.getMessage()); } PolicyElasticData elasticData = new PolicyElasticData(policyData); @@ -337,13 +349,13 @@ public class ElkConnectorImpl implements ElkConnector{ if (result.isSucceeded()) { if (LOGGER.isInfoEnabled()) - LOGGER.info("OK: PUT operation of " + "->" + ": " + + LOGGER.info("ElkConnector: OK: PUT operation of " + "->" + ": " + "success=" + result.isSucceeded() + "[" + result.getResponseCode() + ":" + result.getPathToResult() + "]" + System.lineSeparator() + result.getJsonString()); } else { if (LOGGER.isWarnEnabled()) - LOGGER.warn("FAILURE: PUT operation of "+ "->" + ": " + + LOGGER.warn("ElkConnector: FAILURE: PUT operation of "+ "->" + ": " + "success=" + result.isSucceeded() + "[" + result.getResponseCode() + ":" + result.getPathToResult() + "]" + System.lineSeparator() + result.getJsonString());