Projects STRLCPY Osmedeus Commits 4ff33fbd
🤬
  • ■ ■ ■ ■ ■ ■
    core/module.go
    skipped 255 lines
    256 256   step.Parallel = 1
    257 257   }
    258 258   
    259  - // skip concurrency part
    260  - if step.Parallel == 1 {
    261  - for index, line := range data {
    262  - customParams := make(map[string]string)
    263  - customParams["line"] = line
    264  - customParams["line_id"] = fmt.Sprintf("%v-%v", path.Base(line), index)
    265  - customParams["_id_"] = fmt.Sprintf("%v", index)
    266  - customParams["_line_"] = execution.StripName(line)
    267  - 
    268  - if len(step.Commands) > 0 {
    269  - r.RunCommands(step.Commands, step.Std)
    270  - }
    271  - 
    272  - if len(step.Ose) > 0 {
    273  - for _, ose := range step.Ose {
    274  - r.RunOse(ose)
    275  - }
    276  - }
    277  - 
    278  - if len(step.Scripts) > 0 {
    279  - r.RunScripts(step.Scripts)
    280  - }
    281  - 
    282  - // post scripts
    283  - if len(step.PConditions) > 0 || len(step.PScripts) > 0 {
    284  - err := r.CheckCondition(step.PConditions)
    285  - if err == nil {
    286  - if len(step.PScripts) > 0 {
    287  - r.RunScripts(step.PScripts)
    288  - }
    289  - }
    290  - }
    291  - 
    292  - }
    293  - 
    294  - if step.Label != "" {
    295  - utils.BlockF("Done-Step", color.HiCyanString(step.Label))
    296  - }
    297  - return out, nil
    298  - }
    299  - 
    300  - /////////////
    301  - // run multiple steps in concurrency mode
    302  - 
    303  - utils.DebugF("Run step in Parallel: %v", step.Parallel)
    304  - var wg sync.WaitGroup
    305  - p, _ := ants.NewPoolWithFunc(step.Parallel, func(i interface{}) {
    306  - r.startStepJob(i)
    307  - wg.Done()
    308  - }, ants.WithPreAlloc(true))
    309  - defer p.Release()
    310  - 
    311  - //var mu sync.Mutex
     259 + // prepare the data first
     260 + var newGeneratedSteps []libs.Step
    312 261   for index, line := range data {
    313  - //mu.Lock()
    314 262   customParams := make(map[string]string)
    315  - //localOptions := libs.Options{}
    316 263   customParams["line"] = line
    317 264   customParams["line_id"] = fmt.Sprintf("%v-%v", path.Base(line), index)
    318 265   customParams["_id_"] = fmt.Sprintf("%v", index)
    skipped 30 lines
    349 296   localStep.PScripts = append(localStep.PScripts, AltResolveVariable(script, customParams))
    350 297   }
    351 298   
     299 + newGeneratedSteps = append(newGeneratedSteps, localStep)
     300 + }
     301 + 
     302 + // skip concurrency part
     303 + if step.Parallel == 1 {
     304 + for _, newGeneratedStep := range newGeneratedSteps {
     305 + out, err = r.RunStep(newGeneratedStep)
     306 + if err != nil {
     307 + continue
     308 + }
     309 + }
     310 + if step.Label != "" {
     311 + utils.BlockF("Done-Step", color.HiCyanString(step.Label))
     312 + }
     313 + }
     314 + 
     315 + /////////////
     316 + // run multiple steps in concurrency mode
     317 + 
     318 + utils.DebugF("Run step in Parallel: %v", step.Parallel)
     319 + var wg sync.WaitGroup
     320 + p, _ := ants.NewPoolWithFunc(step.Parallel, func(i interface{}) {
     321 + r.startStepJob(i)
     322 + wg.Done()
     323 + }, ants.WithPreAlloc(true))
     324 + defer p.Release()
     325 + 
     326 + for _, newGeneratedStep := range newGeneratedSteps {
    352 327   wg.Add(1)
    353  - err = p.Invoke(localStep)
     328 + err = p.Invoke(newGeneratedStep)
    354 329   if err != nil {
    355 330   utils.ErrorF("Error in parallel: %v", err)
    356 331   }
    357  - //mu.Unlock()
    358 332   }
    359 333   
    360 334   wg.Wait()
    skipped 46 lines
  • ■ ■ ■ ■ ■ ■
    core/parse.go
    skipped 50 lines
    51 51   return buf.String()
    52 52  }
    53 53   
    54  - 
    55 54  // ParseFlow parse mode file
    56 55  func ParseFlow(flowFile string) (libs.Flow, error) {
    57 56   utils.DebugF("Parsing workflow at: %v", color.HiGreenString(flowFile))
    skipped 124 lines
    182 181   
    183 182   return ROptions
    184 183  }
    185  - 
    186 184   
    187 185  // ParseParams parse more params from cli
    188 186  func ParseParams(rawParams []string) map[string]string {
    skipped 103 lines
  • ■ ■ ■ ■ ■
    core/runner.go
    skipped 42 lines
    43 43   RuntimeFile string
    44 44   
    45 45   RoutineModules []string
    46  - Reports []string
     46 + Reports []string
    47 47   Routines []libs.Routine
    48 48   
    49 49   VM *otto.Otto
    skipped 261 lines
    311 311   utils.BlockF("Done", fmt.Sprintf("scan for %v -- %v", r.Input, color.HiMagentaString("%vs", r.RunningTime)))
    312 312   utils.WriteToFile(r.DoneFile, "done")
    313 313  }
    314  - 
    315 314   
    316 315  // StartRoutines start the scan
    317 316  func (r *Runner) StartRoutines() {
    skipped 29 lines
  • ■ ■ ■ ■ ■
    core/step.go
    skipped 68 lines
    69 69   return module
    70 70  }
    71 71   
    72  - 
    73 72  // print all report
    74 73  func printReports(module libs.Module) {
    75 74   var files []string
    skipped 94 lines
  • ■ ■ ■ ■
    test-workflows/sample/parallel.yaml
    skipped 1 lines
    2 2  desc: Run dirbscan scan on list of HTTP file
    3 3   
    4 4  params:
    5  -- limit: '5000'
     5 + - limit: '5000'
    6 6   
    7 7  steps:
    8 8   - label: 'Start step 111'
    skipped 12 lines
Please wait...
Page is in error, reload to recover