max module restriction

Showcase you can limit the number of layers of module calls in case there are programming recursive problem

source

How to configure

Use MaxModuelCallLayers in upconfig.yml to define how many max call number is allowed

For example, the default value is 256

MaxModuelCallLayers: 256

In case there are recursive problem, or evil code execution, then it will halt when there are actually higer number of module calls then defined MaxModuelCallLayers

config file - upconfig.yml

    
    version: 1.0.0
    Verbose: vvv
    MaxCallLayers: 8
    MaxModuelCallLayers: 8
    RefDir: .
    TaskFile: up.yml
    ConfigDir: .
    ConfigFile: upconfig.yml
    
    Modules:
    
      - #if there is no repo, then it will use the dir as module and incorporate as module
        dir: hello-module/
        alias: hello-module
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: crosstalk1
        version: crosstalk1
        pullpolicy: always
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: crosstalk2
        version: crosstalk2
        pullpolicy: always
    

up task - up.yml

    tasks:
      -
        name: Main
        desc: main entry
        task:
          -
            func: call
            do: hello-module.Say_hello
    

up module task - up.yml

    
    tasks:
      -
        name: Main
        desc: main entry
        task:
          -
            func: shell
            desc: main job
            do:
              - echo "hello "
      -
        name: Say_hello
        task:
          -
            func: cmd
            vars:
              a: aaa
            do:
              - name: print
                cmd: "... hello"
    
          -
            func: call
            do: crosstalk1.Cross_call1
    

up module config - upconfig.yml

    RefDir: .
    TaskFile: up.yml
    
    Modules:
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: crosstalk1
        version: crosstalk1
        pullpolicy: always
    

crosstalk1 - up.yml

    
    tasks:
    
      -
        name: Main
        desc: main entry
        task:
          -
            func: shell
            desc: main job
            do:
              - echo "hello "
    
          -
            func: call
            do: Say_world
    
    
      -
        name: Say_world
        task:
          -
            func: cmd
            do:
              -
                name: print
                cmd: " .... world from Say_world"
    
    
      -
        name: Cross_call1
        task:
          -
            func: cmd
            do:
              -
                name: print
                cmd: " .... cross call 1"
    
          -
            func: call
            do: crosstalk2.Cross_call2
    
    

crosstalk1 - upconfig.yml

    RefDir: .
    TaskFile: up.yml
    
    Modules:
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: crosstalk2
        version: crosstalk2
        pullpolicy: always
    

crosstalk2 - up.yml

    
    tasks:
    
      -
        name: Main
        desc: main entry
        task:
          -
            func: shell
            desc: main job
            do:
              - echo "hello "
    
          -
            func: call
            do: Say_world
    
    
      -
        name: Say_world
        task:
          -
            func: cmd
            do:
              -
                name: print
                cmd: " .... world from Say_world"
    
    
      -
        name: Cross_call1
        task:
          -
            func: cmd
            do:
              -
                name: print
                cmd: " .... cross call 1"
    
          -
            func: call
            do: crosstalk2.Cross_call2
    
    

crosstalk2 - upconfig.yml

    RefDir: .
    TaskFile: up.yml
    
    Modules:
    
      - repo: https://github.com/upcmd/hello-module.git
        alias: crosstalk1
        version: crosstalk1
        pullpolicy: always
    
Main log file
    loading [Config]:  ./tests/modtests/f0012/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/modtests/f0012
                 WorkDir -> refdir
              AbsWorkDir -> /up_project/up/tests/modtests/f0012
                TaskFile -> up.yml
                 Verbose -> v
              ModuleName -> self
               ShellType -> /bin/sh
           MaxCallLayers -> 8
                 Timeout -> 3600000
     MaxModuelCallLayers -> 8
               EntryTask -> Main
      ModRepoUsernameRef -> 
      ModRepoPasswordRef -> 
    work dir: /up_project/up/tests/modtests/f0012
    -exec task: Main
    loading [Task]:  ./up.yml
    module: [self], instance id: [dev], exec profile: []
    Task1: [Main ==> Main: main entry ]
    -Step1:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [hello-module], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [hello-module] task: [Say_hello]
    Task2: [TODO: Main Caller Taskname ==> Say_hello:  ]
    -Step1:
    ~SubStep1: [print:  ]
    ... hello
    -Step2:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [crosstalk1], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [crosstalk1] task: [Cross_call1]
    Task3: [TODO: Main Caller Taskname ==> Cross_call1:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... cross call 1
    -Step2:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [crosstalk2], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [crosstalk2] task: [Cross_call2]
    Task3: [TODO: Main Caller Taskname ==> Cross_call2:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... cross call 2
    -Step2:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [crosstalk1], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [crosstalk1] task: [Cross_call1]
    Task3: [TODO: Main Caller Taskname ==> Cross_call1:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... cross call 1
    -Step2:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [crosstalk2], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [crosstalk2] task: [Cross_call2]
    Task3: [TODO: Main Caller Taskname ==> Cross_call2:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... cross call 2
    -Step2:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [crosstalk1], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [crosstalk1] task: [Cross_call1]
    Task3: [TODO: Main Caller Taskname ==> Cross_call1:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... cross call 1
    -Step2:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [crosstalk2], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [crosstalk2] task: [Cross_call2]
    Task3: [TODO: Main Caller Taskname ==> Cross_call2:  ]
    -Step1:
    ~SubStep1: [print:  ]
     .... cross call 2
    -Step2:
    loading [Config]:  ./upconfig.yml
    loading [Task]:  ./up.yml
    module: [crosstalk1], instance id: [nonamed], exec profile: []
     WARN: [*be aware*] - [both instance id and exec profile are not set]
    =>call module: [crosstalk1] task: [Cross_call1]
     WARN: [Not rescued in task level] - [please assess the panic problem and cause, fix it before re-run the task]
    task finally -> runtime error: invalid memory address or nil pointer dereference
    
Logs with different verbose level
Raw logs with different verbose level