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

define variable doesn't work in backquotes #55

Open
JaveleyQAQ opened this issue Jul 17, 2023 · 5 comments
Open

define variable doesn't work in backquotes #55

JaveleyQAQ opened this issue Jul 17, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@JaveleyQAQ
Copy link
Contributor

run for each doesn't work 😀



  #     method: DELETE
  #     path: /nacos/v1/auth/users?username=



metadata:
    language: v1-beta
    name: "Nacos Create User"
    description: "Nacos Create User"
    tags: "Unauthorized","Nacos"
    author: "JaveleyQAQ"

define:
		user = {random_str(5)}

run for each:
    nacos_detect = 
		`/nacos/v1/auth/users?username={user}&password={user}`

    

given request then
    send request called nacos:
        method: "POST"
        path: {nacos_detect}
				headers:
				 "User-Agent": "Nacos-Server"
			
    if {nacos.response.status_code} is "200" and
         "create user ok!" in {nacos.response.body} then
	            report issue:
		            severity: high
		            confidence: certain
		            detail: ` Nacos create user:{user}/{user}`
		            remediation: "."
    end if
@Hannah-PortSwigger
Copy link
Contributor

Hi

It looks like you're using run for each when you don't need to be.

Could you try the following instead?

define:
        user = {random_str(5)}
        nacos_detect = 
                `/nacos/v1/auth/users?username={user}&password={user}`

@olliewuk
Copy link
Contributor

an example of this approach is here - https://github.com/PortSwigger/BChecks/blob/main/examples/log4shell.bcheck

@JaveleyQAQ
Copy link
Contributor Author

I just want to point out that this is an issue, define cannot be used together with backticks in "run for each:" @olliewuk @Hannah-PortSwigger

@olliewuk
Copy link
Contributor

olliewuk commented Jul 19, 2023

@JaveleyQAQ this is today how the language is designed to work. The for each is the outer scope whilst the define is inner scope. We are exploring what we might do to further evolve the language and/or compiler behaviour here.

@olliewuk olliewuk added the enhancement New feature or request label Jul 19, 2023
@JaveleyQAQ
Copy link
Contributor Author

@JaveleyQAQ this is today how the language is designed to work. The for each is the outer scope whilst the define is inner scope. We are exploring what we might do to further evolve the language and/or compiler behaviour here.

I understand now, I thought the variables were global.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants