Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove use of iterate() in flow #4688

Merged
merged 1 commit into from
Jan 28, 2024
Merged

remove use of iterate() in flow #4688

merged 1 commit into from
Jan 28, 2024

Conversation

tarunKoyalwar
Copy link
Member

@tarunKoyalwar tarunKoyalwar commented Jan 26, 2024

Proposed changes

  • Earlier it was required to use iterate function in flow when it is unknown if array contains one or more value due to flattening of single value array's to string
  • this is now fixed by preserving array type in flow and flattening at protocol level instead of doing it in flow
  • added integration test for this case
  • closes fix iteration in flow if array contained only 1 value #4689

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@tarunKoyalwar
Copy link
Member Author

tarunKoyalwar commented Jan 26, 2024

example template

id: flow-iterate-one-value-flow

info:
  name: Test Flow Iterate One Value Flow
  author: pdteam
  severity: info

flow: |
  http(1)
  for(let value of template.extracted){
    set("value", value)
    http(2)
  }
http:
  - method: GET
    path:
      - "{{BaseURL}}"

    extractors:
      - type: regex
        name: extracted
        internal: true
        regex:
          - "[ok]+"

  - method: GET
    path:
      - "{{BaseURL}}/{{value}}"

    matchers:
      - type: word
        words:
          - "ok"

Incorrect behaviour ( in latest nuclei)

  • if one value was extracted then nuclei was iterating over each character
$ nuclei -u scanme.sh -t integration_tests/flow/iterate-one-value-flow.yaml 

                     __     _
   ____  __  _______/ /__  (_)
  / __ \/ / / / ___/ / _ \/ /
 / / / / /_/ / /__/ /  __/ /
/_/ /_/\__,_/\___/_/\___/_/   v3.1.7

		projectdiscovery.io

[INF] Current nuclei version: v3.1.7 (latest)
[INF] Current nuclei-templates version: v9.7.4 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 6
[INF] Templates loaded for current scan: 1
[WRN] Executing 1 unsigned templates. Use with caution.
[INF] Targets loaded for current scan: 1
[INF] Running httpx on input host
[INF] Found 1 URL from httpx
[flow-iterate-one-value-flow] [http] [info] https://scanme.sh/o
[flow-iterate-one-value-flow] [http] [info] https://scanme.sh/k

After fix / this PR

$ ./nuclei -u scanme.sh -t integration_tests/flow/iterate-one-value-flow.yaml

                     __     _
   ____  __  _______/ /__  (_)
  / __ \/ / / / ___/ / _ \/ /
 / / / / /_/ / /__/ /  __/ /
/_/ /_/\__,_/\___/_/\___/_/   v3.1.7

		projectdiscovery.io

[INF] Current nuclei version: v3.1.7 (latest)
[INF] Current nuclei-templates version: v9.7.4 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 6
[INF] Templates loaded for current scan: 1
[WRN] Executing 1 unsigned templates. Use with caution.
[INF] Targets loaded for current scan: 1
[INF] Running httpx on input host
[INF] Found 1 URL from httpx
[flow-iterate-one-value-flow] [http] [info] https://scanme.sh/ok

@tarunKoyalwar tarunKoyalwar linked an issue Jan 26, 2024 that may be closed by this pull request
@tarunKoyalwar tarunKoyalwar self-assigned this Jan 26, 2024
@ehsandeep ehsandeep merged commit 0371846 into dev Jan 28, 2024
9 of 12 checks passed
@ehsandeep ehsandeep deleted the issue-skip-iterate branch January 28, 2024 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix iteration in flow if array contained only 1 value
2 participants