# ------------------------------------------------------------------- # task.check – Redis configuration validator # Regexps capture values generically; generators validate them. # ------------------------------------------------------------------- # =================================================================== # MANDATORY (HARD) CHECKS # =================================================================== # ------------------------------------------------------------------- # 1. bind – must be present and loopback-only # ------------------------------------------------------------------- note: bind – the server should listen on loopback only regexp: ^^ \s* bind \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} dir must be non-empty, got '{path}'") CODE # ------------------------------------------------------------------- # 6. dbfilename – must be set # ------------------------------------------------------------------- note: dbfilename – RDB filename should be set regexp: ^^ \s* dbfilename \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} dbfilename must be non-empty, got '{name}'") CODE # ------------------------------------------------------------------- # 7. stop-writes-on-bgsave-error – normally yes (checked in generator) # ------------------------------------------------------------------- note: stop-writes-on-bgsave-error – should normally be yes regexp: ^^ \s* stop\-writes\-on\-bgsave\-error \s+ (\S+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} databases > 0, got {num}") CODE # ------------------------------------------------------------------- # 13. loglevel – recognised level (checked in generator) # ------------------------------------------------------------------- note: loglevel – must be one of debug, verbose, notice, warning regexp: ^^ \s* loglevel \s+ (\S+) \s* $$ generator: <= 8 state = get_state() state['requirepass_set'] = True update_state(state) print(f"assert: {1 if ok else 0} requirepass length >= 8, got {len(pwd)} chars") CODE # ------------------------------------------------------------------- # 15. maxmemory – soft: if set, value must be non-empty # ------------------------------------------------------------------- note: maxmemory – (optional) memory limit should be set ~regexp: ^^ \s* maxmemory \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} maxmemory set, got '{val}'") CODE # ------------------------------------------------------------------- # 16. maxmemory-policy – soft: if set, must be known (checked in generator) # ------------------------------------------------------------------- note: maxmemory-policy – (optional) valid policy name ~regexp: ^^ \s* maxmemory\-policy \s+ (\S+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} save policy defined, got '{args}'") CODE # ------------------------------------------------------------------- # 18. logfile – soft: if set, path must be non-empty # ------------------------------------------------------------------- note: logfile – (optional) log file path must be provided ~regexp: ^^ \s* logfile \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} logfile must be non-empty, got '{path}'") CODE # ------------------------------------------------------------------- # 19. tcp-keepalive – soft: if set, value > 0 # ------------------------------------------------------------------- note: tcp-keepalive – (optional) should be a positive number ~regexp: ^^ \s* tcp\-keepalive \s+ (\d+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} tcp-keepalive > 0, got {val}") CODE # ------------------------------------------------------------------- # 20. include – soft: if used, path must be non-empty # ------------------------------------------------------------------- note: include – (optional) include path must be non-empty ~regexp: ^^ \s* include \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} include path valid, got '{path}'") CODE # ------------------------------------------------------------------- # 21. loadmodule – soft: if used, path must be non-empty # ------------------------------------------------------------------- note: loadmodule – (optional) module path must be non-empty ~regexp: ^^ \s* loadmodule \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} loadmodule path valid, got '{path}'") CODE # ------------------------------------------------------------------- # 22. replicaof – soft: if used, host and port must be valid # ------------------------------------------------------------------- note: replicaof – (optional) master host and port ~regexp: ^^ \s* replicaof \s+ (.+) \s+ (\d+) \s* $$ generator: < 0 and 1 <= port <= 65535 print(f"assert: {1 if ok else 0} replicaof {host}:{port} valid") CODE # ------------------------------------------------------------------- # 23. masterauth – soft: if used, non-empty password # ------------------------------------------------------------------- note: masterauth – (optional) master authentication ~regexp: ^^ \s* masterauth \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} masterauth set, got {len(auth)} chars") CODE # ------------------------------------------------------------------- # 24. aclfile – soft: if used, path must be valid # ------------------------------------------------------------------- note: aclfile – (optional) ACL file path ~regexp: ^^ \s* aclfile \s+ (.+) \s* $$ generator: < 0 print(f"assert: {1 if ok else 0} aclfile path valid, got '{path}'") CODE # ------------------------------------------------------------------- # 25. user – soft: if present, status must be on/off (checked in generator) # ------------------------------------------------------------------- note: user – (optional) ACL user status ~regexp: ^^ \s* user \s+ \S+ \s+ (\S+) \s* $$ generator: <= 0 # ------------------------------------------------------------------- note: timeout – (optional) client idle timeout ~regexp: ^^ \s* timeout \s+ (\d+) \s* $$ generator: <= 0 print(f"assert: {1 if ok else 0} timeout >= 0, got {val}") CODE # ------------------------------------------------------------------- # 27. supervised – soft: valid mode (checked in generator) # ------------------------------------------------------------------- note: supervised – (optional) must be no, upstart, systemd, auto ~regexp: ^^ \s* supervised \s+ (\S+) \s* $$ generator: <