diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2019-03-01 10:32:17 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2019-03-01 10:53:31 +0530 |
commit | 8d59ae0158a8b3f0d038194f42b95424e8c8b38a (patch) | |
tree | 2b96c2638722680dd6b04d511008c5b20f538945 /profiles/command | |
parent | adfc77d913cb8e54750d8fe167fde2bb4ffc57ef (diff) |
Fix the code vulnerabilities
Issue-ID: CLI-129
Change-Id: I441d7897c2e47b8eda13775d66327401656300ba
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'profiles/command')
-rw-r--r-- | profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java index 69987d9b..8e94db85 100644 --- a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java +++ b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java @@ -138,7 +138,7 @@ public class OpenCommandShellCmd extends OnapCommand { cwd); try { pr.run(); - } catch (InterruptedException | IOException e) { + } catch (Exception e) { throw new OnapCommandExecutionFailed(this.getName(), e); } @@ -251,21 +251,25 @@ public class OpenCommandShellCmd extends OnapCommand { bodyProcessedLine += processedPattern.substring(currentIdx); break; } - int idxE = idxS + 2; // %s + + int idxEnd = idxS + 2; // %s + try { - Object value = values.get(positionalIdx); - String valueS = String.valueOf(value); - if (value instanceof JSONArray) { - JSONArray arr = (JSONArray) value; - if (!arr.isEmpty()) { - valueS = arr.get(i).toString(); + Object val = values.get(positionalIdx); + String valStr = String.valueOf(val); + + if (val instanceof JSONArray) { + JSONArray aJson = (JSONArray) val; + + if (!aJson.isEmpty()) { + valStr = aJson.get(i).toString(); } else { throw new OnapCommandResultEmpty(); } } - bodyProcessedLine += processedPattern.substring(currentIdx, idxS) + valueS; - currentIdx = idxE; + bodyProcessedLine += processedPattern.substring(currentIdx, idxS) + valStr; + currentIdx = idxEnd; positionalIdx++; } catch (OnapCommandResultEmpty e) { throw e; |