Page MenuHomeVyOS Platform

SNMP Script-extensions allows names with spaces, but commit fails
Closed, ResolvedPublic

Description

When adding a SNMP script with spaces in the name (which the CLI accepts), the commit fails. Also, the autocomplete doesn't work properly as the name will get split up on every space.

vyos@vyos001# set service snmp script-extensions extension-name 'hello world' script test.sh
[edit]
vyos@vyos001# compare
[edit service snmp]
+script-extensions {
+    extension-name "hello world" {
+        script test.sh
+    }
+}
[edit]
vyos@vyos001# commit
[ service snmp ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/conf_mode/snmp.py", line 790, in <module>
    c = get_config()
  File "/usr/libexec/vyos/conf_mode/snmp.py", line 350, in get_config
    snmp['script_ext'][extname] = '/config/user-data/' + conf.return_value('script-extensions extension-name ' + extname + ' script')
TypeError: Can't convert 'NoneType' object to str implicitly

[[service snmp]] failed
Commit failed
[edit]
vyos@vyos001# set service snmp script-extensions extension-name 
Possible completions:
 > <text>       Extension name
 > hello        
 > world        

      
[edit]
vyos@vyos001:~$ show vers
Version:          VyOS 1.2.4
Built by:         Sentrium S.L.
Built on:         Wed 01 Jan 2020 20:02 UTC
Build UUID:       78b0438c-d465-440b-a904-e99eff35f88b
Build Commit ID:  f0ba322338bdb0

Details

Difficulty level
Unknown (require assessment)
Version
1.2.4
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

Xesxen created this task.Jan 15 2020, 4:34 PM
Xesxen created this object in space S1 VyOS Public.
c-po added a subscriber: c-po.Jan 16 2020, 8:22 AM

This should be restricted by a regex

hagbard claimed this task.Jan 16 2020, 3:47 PM
hagbard triaged this task as Normal priority.
hagbard changed the task status from Open to In progress.Jan 16 2020, 4:14 PM
hagbard moved this task from Need Triage to In Progress on the VyOS 1.3 Equuleus board.
pasik added a subscriber: pasik.Jan 16 2020, 7:32 PM
hagbard changed the task status from Backport candidate to Needs testing.Jan 16 2020, 7:55 PM
hagbard moved this task from In Progress to Finished on the VyOS 1.3 Equuleus board.
c-po added a comment.Jan 26 2020, 11:04 AM
vyos@vyos# set service snmp script-extensions extension-name 'foo' script /usr/bin/echo
vyos@vyos# set service snmp script-extensions extension-name 'foo bar' script /usr/bin/echo

  Script extension contains invalid characters
  Value validation failed
  Set failed

Works as expected

c-po added a comment.Jan 26 2020, 11:04 AM

Maybe for future CLI designs, the following would be cleaner: set service snmp extension name 'foo bar' script /usr/bin/echo

c-po closed this task as Resolved.Jan 26 2020, 11:05 AM