Repository navigation
T8957: add vyconf support for comment operation #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rolling
Are you sure you want to change the base?
Changes from all commits
9d30fe8
fe996b9
d634d50
0968a21
cb6f730
0d19a0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,6 +227,14 @@ let delete world token (req: request_delete) = | |
| response_tmpl | ||
| with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)} | ||
|
|
||
| let comment world token (req: request_comment) = | ||
| try | ||
| let () = (Lwt_log.debug @@ Printf.sprintf "[%s]\n" (Vyos1x.Util.string_of_list req.path)) |> Lwt.ignore_result in | ||
| let session = Session.comment world (find_session token) req.path req.comment in | ||
| Hashtbl.replace sessions token session; | ||
| response_tmpl | ||
| with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)} | ||
|
|
||
| let aux_set world token (req: request_aux_set) = | ||
| try | ||
| let () = (Lwt_log.debug @@ Printf.sprintf "[%s]\n" (Vyos1x.Util.string_of_list req.path)) |> Lwt.ignore_result in | ||
|
|
@@ -313,9 +321,14 @@ let commit world token (req: request_commit) = | |
| | Error msg -> | ||
| Lwt.return {response_tmpl with status=Internal_error; error=(Some msg)} | ||
| | Ok c_data -> | ||
| let%lwt received_commit_data = VC.do_commit c_data in | ||
| let%lwt result_commit_data = | ||
| Lwt.return (CC.commit_update received_commit_data) | ||
| match c_data.node_list with | ||
| | [] -> (* commit consists of comments only *) | ||
| let comm_data = { c_data with init = Some { success = true; out = "" } } in | ||
| Lwt.return (Session.apply_commit world comm_data) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| | _ -> | ||
| let%lwt received_commit_data = VC.do_commit c_data in | ||
| Lwt.return (Session.apply_commit world received_commit_data) | ||
| in | ||
| match result_commit_data.init with | ||
| | None -> | ||
|
|
@@ -523,6 +536,7 @@ let rec handle_connection world ic oc () = | |
| | Some t, Get_completion_env r -> get_completion_env world t r | ||
| | Some t, Copy r -> copy world t r | ||
| | Some t, Rename r -> rename world t r | ||
| | Some t, Comment r -> comment world t r | ||
| | _ -> failwith "Unimplemented" | ||
| ) |> Lwt.return | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return an error for an empty argument list.
If a library caller invokes
comment client [],lastis-1. This access raisesInvalid_argumentbefore the function returns its asynchronous result. The CLI guard does not protect the exported client method.Check for
[]before indexing and returnLwt.return (Error ...). Preserve a final empty-string argument because it removes a comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevented in caller. Moreover, a path of one element, split to empty path and value, is caught as well and returns error from session.ml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analysis chain
Script executed:
Length of output: 19891
@jestabroThanks. The CLI rejects an empty argument list atsrc/vyconf_cli.ml, Line 119. A single argument reaches the session with an empty path, whichsrc/session.ml, Line 263 rejects.The original concern applies only to direct calls to the exported client method:
comment client []still raises before it reaches the session. I’m not marking the finding as addressed.You are interacting with an AI system.