Skip to content

Commit

Permalink
MID-8842 ninja - fixed input validation in upgrade action command
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Sep 14, 2023
1 parent 25298dc commit b748488
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ActionResult<UpgradeObjectsItemsSummary> execute() throws Exception {
if (!options.getFiles().isEmpty()) {
if (context.isUserMode() && !options.isSkipUpgradeWarning()) {
log.warn("File update will remove XML comments and change formatting. Do you wish to proceed? (Y/n)");
String result = NinjaUtils.readInput(log, input -> StringUtils.isEmpty(input) || input.equalsIgnoreCase("y"));
String result = NinjaUtils.readInput(log, input -> StringUtils.isEmpty(input) || input.matches("[Yn]"));

if (result.trim().equalsIgnoreCase("n")) {
log.info("Upgrade aborted");
Expand All @@ -72,6 +72,15 @@ public ActionResult<UpgradeObjectsItemsSummary> execute() throws Exception {
return upgradeObjectsInFiles();
}

if (context.isUserMode() && !options.isSkipUpgradeWarning()) {
log.warn("Object now will be updated in repository. Do you wish to proceed? (Y/n)");
String result = NinjaUtils.readInput(log, input -> StringUtils.isEmpty(input) || input.matches("[Yn]"));
if (result.trim().equalsIgnoreCase("n")) {
log.info("Upgrade aborted");
return null;
}
}

return super.execute();
}

Expand Down

0 comments on commit b748488

Please sign in to comment.