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.

[email protected]# set service snmp script-extensions extension-name 'hello world' script test.sh
[edit]
[email protected]# compare
[edit service snmp]
+script-extensions {
+    extension-name "hello world" {
+        script test.sh
+    }
+}
[edit]
[email protected]# 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]
[email protected]# set service snmp script-extensions extension-name 
Possible completions:
 > <text>       Extension name
 > hello        
 > world        

      
[edit]
[email protected]:~$ 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 object in space S1 VyOS Public.

This should be restricted by a regex

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.
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.
[email protected]# set service snmp script-extensions extension-name 'foo' script /usr/bin/echo
[email protected]# 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

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