summaryrefslogtreecommitdiff
path: root/src/session.ml
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2025-12-19 21:50:08 +0000
committerGitHub <noreply@github.com>2025-12-19 21:50:08 +0000
commita013378c3237e727ed39df55dc3c70f87190ed1d (patch)
tree17d5ac73d4208b774664de932ff470a47a13def2 /src/session.ml
parent0f36d5a2650238d3bbd2b5837ec51fc0c01962aa (diff)
parentbbcbdf0e8620323fdfce9707cd97a4b756a5baf3 (diff)
downloadvyconf-a013378c3237e727ed39df55dc3c70f87190ed1d.tar.gz
vyconf-a013378c3237e727ed39df55dc3c70f87190ed1d.zip
Merge pull request #40 from jestabro/fix-show-leaf
T8091: sanitize path of leaf values for show command
Diffstat (limited to 'src/session.ml')
-rw-r--r--src/session.ml11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/session.ml b/src/session.ml
index 0bd3d95..00d47c0 100644
--- a/src/session.ml
+++ b/src/session.ml
@@ -590,15 +590,20 @@ let exists w s path =
let show_config w s path =
let path_total = s.edit_level @ path in
+ let path_show =
+ match RT.get_path_type w.reference_tree path_total with
+ | `Leaf_value -> Vyos1x.Util.drop_last path_total
+ | _ -> path_total
+ in
let proposed_config = get_proposed_config w s in
- if not (Vyos1x.Util.is_empty path_total) &&
- not ((VT.exists[@alert "-exn"]) proposed_config path_total)
+ if not (Vyos1x.Util.is_empty path_show) &&
+ not ((VT.exists[@alert "-exn"]) proposed_config path_show)
then raise (Session_error "Path does not exist")
else
let res =
(CD.diff_show[@alert "-exn"])
w.reference_tree
- path_total
+ path_show
w.running_config
proposed_config
in res