tbotnz / cisshgo

simple concurrent ssh server posing as cisco ios
131 stars 26 forks source link

Allow for "Longest Match" style input to command matching #9

Closed lykinsbd closed 4 years ago

lykinsbd commented 4 years ago

It should be fairly trivial to introduce a helper function in utils that evaluates any non-matching input against the keys from the FakeDevice[SupportedCommands] map. This would allow us to not have to have duplicate entries, but to simply search for any string with the most matches from the beginning of the line.

Psuedo-code:

func LongestMatch(input string, SupportedCommands slice) (matched bool, matched_command string):
    for command in SupportedCommands:
        \\ Do Regex to match start of string against user input
        return (matched, matched_command)
lykinsbd commented 4 years ago

This is closed by https://github.com/tbotnz/cisgo-ios/pull/13