diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2019-11-06 13:37:01 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-11-12 21:37:11 +0100 |
commit | 4f785531e6e10265bd82cc1d67df5fa84e07de49 (patch) | |
tree | 50810106682269afe4e0dc1dd54bcc1ff7cd054a /sources/ogAdmServer.cpp | |
parent | f51c245c9308db9abf9b242a65a8ff8cf4df5ad1 (diff) |
#915 Validate POST /image/restore/incremental REST API parameters
This patch ensures that all required parameters are sent in the request.
Diffstat (limited to 'sources/ogAdmServer.cpp')
-rw-r--r-- | sources/ogAdmServer.cpp | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp index 94ac4d2..f63eda4 100644 --- a/sources/ogAdmServer.cpp +++ b/sources/ogAdmServer.cpp @@ -4544,29 +4544,59 @@ static int og_cmd_restore_incremental_image(json_t *element, struct og_msg_param return -1; json_object_foreach(element, key, value) { - if (!strcmp(key, "clients")) + if (!strcmp(key, "clients")) { err = og_json_parse_clients(value, params); - else if (!strcmp(key, "disk")) + } else if (!strcmp(key, "disk")) { err = og_json_parse_string(value, ¶ms->disk); - else if (!strcmp(key, "partition")) + params->flags |= OG_REST_PARAM_DISK; + } else if (!strcmp(key, "partition")) { err = og_json_parse_string(value, ¶ms->partition); - else if (!strcmp(key, "id")) + params->flags |= OG_REST_PARAM_PARTITION; + } else if (!strcmp(key, "id")) { err = og_json_parse_string(value, ¶ms->id); - else if (!strcmp(key, "name")) + params->flags |= OG_REST_PARAM_ID; + } else if (!strcmp(key, "name")) { err = og_json_parse_string(value, ¶ms->name); - else if (!strcmp(key, "repository")) + params->flags |= OG_REST_PARAM_NAME; + } else if (!strcmp(key, "repository")) { err = og_json_parse_string(value, ¶ms->repository); - else if (!strcmp(key, "profile")) + params->flags |= OG_REST_PARAM_REPO; + } else if (!strcmp(key, "profile")) { err = og_json_parse_string(value, ¶ms->profile); - else if (!strcmp(key, "type")) + params->flags |= OG_REST_PARAM_PROFILE; + } else if (!strcmp(key, "type")) { err = og_json_parse_string(value, ¶ms->type); - else if (!strcmp(key, "sync_params")) - err = og_json_parse_sync_params(value, &(params->sync_setup)); + params->flags |= OG_REST_PARAM_TYPE; + } else if (!strcmp(key, "sync_params")) { + err = og_json_parse_sync_params(value, params); + } if (err < 0) break; } + if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR | + OG_REST_PARAM_DISK | + OG_REST_PARAM_PARTITION | + OG_REST_PARAM_ID | + OG_REST_PARAM_NAME | + OG_REST_PARAM_REPO | + OG_REST_PARAM_PROFILE | + OG_REST_PARAM_TYPE | + OG_REST_PARAM_SYNC_DIFF_ID | + OG_REST_PARAM_SYNC_DIFF_NAME | + OG_REST_PARAM_SYNC_PATH | + OG_REST_PARAM_SYNC_METHOD | + OG_REST_PARAM_SYNC_SYNC | + OG_REST_PARAM_SYNC_DIFF | + OG_REST_PARAM_SYNC_REMOVE | + OG_REST_PARAM_SYNC_COMPRESS | + OG_REST_PARAM_SYNC_CLEANUP | + OG_REST_PARAM_SYNC_CACHE | + OG_REST_PARAM_SYNC_CLEANUP_CACHE | + OG_REST_PARAM_SYNC_REMOVE_DST)) + return -1; + len = snprintf(buf, sizeof(buf), "nfn=RestaurarSoftIncremental\rdsk=%s\rpar=%s\ridi=%s\rnci=%s\r" "ipr=%s\rifs=%s\ridf=%s\rncf=%s\rrti=%s\rmet=%s\rmsy=%s\r" |