spring-shell icon indicating copy to clipboard operation
spring-shell copied to clipboard

Built-in commands aren't disabled using properties as described in documentation

Open stellirin opened this issue 1 year ago • 2 comments

Tested with 3.2.0-RC1 and 3.1.0, older versions were not tested because I'm using functionality introduced in 3.1.0.

Documentation states that I can add properties to disable functionality, e.g.:

spring:
  shell:
    history.enabled: false
    interactive.enabled: false
    script.enabled: false

However, of these three only interactive.enabled: false actually disables the feature. Easy to see it with the help command

AVAILABLE COMMANDS

Built-In Commands
       help: Display help about available commands
       history: Display or save the history of previously run commands
       version: Show version info
       script: Read and execute commands from a file.

I found that history and script require different properties:

spring:
  shell:
    interactive.enabled: false
    command:
      history.enabled: false
      script.enabled: false
AVAILABLE COMMANDS

Built-In Commands
       help: Display help about available commands
       version: Show version info

Either documentation has been wrong for some time and the correct properties are spring.shell.command.*.enabled=false or A bug was introduced sometime ago that made the properties spring.shell.*.enabled=false to stop working.

  • https://docs.spring.io/spring-shell/reference/3.2/commands/builtin/history.html
  • https://docs.spring.io/spring-shell/docs/3.0.10/docs/index.html#built-in-commands-history

stellirin avatar Dec 02 '23 10:12 stellirin

After further testing it seems that, at least in some cases, both properties are required to fully disable a feature. History is easy to test when run as a user without permission to write to spring-shell.log:

Test 1

No properties set. history command is enabled and app does seem to use spring-shell.log

  • help command works but errors with java.nio.file.AccessDeniedException: /**/spring-shell.log
  • history command visible in help
  • history command is enabled, errors with java.nio.file.AccessDeniedException: /**/spring-shell.log

Test 2

spring.shell.history.enabled=false

history command is enabled but app doesn't seem to use spring-shell.log

  • help command works without issue
  • history command visible in help
  • history command is enabled, returns []

Test 3

spring.shell.command.history.enabled=false

history command is not enabled but app does seem to use spring-shell.log

  • help command works but errors with java.nio.file.AccessDeniedException: /**/spring-shell.log
  • history command not visible in help
  • history command is not enabled, returns No command found for 'history'

Test 4

spring.shell.history.enabled=false
spring.shell.command.history.enabled=false

history command is not enabled and app doesn't seem to use spring-shell.log

  • help command works without issue
  • history command not visible in help
  • history command is not enabled, returns No command found for 'history'

stellirin avatar Dec 02 '23 12:12 stellirin

Looks like we should document these better. If looking history, spring.shell.history.enabled and spring.shell.command.history.enabled are two different things. Former disabling history functionality in an interactive(i.e arrows up/down) shell and latter disabling the history command itself. You don't need to have history command to have history feature enabled in an interactive mode.

jvalkeal avatar Dec 08 '23 13:12 jvalkeal