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

Improve DSL function UX #1295

Closed
3 tasks done
forgedhallpass opened this issue Nov 26, 2021 · 2 comments · Fixed by #1296
Closed
3 tasks done

Improve DSL function UX #1295

forgedhallpass opened this issue Nov 26, 2021 · 2 comments · Fixed by #1296
Assignees
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Enhancement Most issues will probably ask for additions or changes.
Milestone

Comments

@forgedhallpass
Copy link
Contributor

forgedhallpass commented Nov 26, 2021

Proposed features:

  • Show meaningful error message, when a user provides an nonexistent DSL function name
  • Show meaningful error message, when a user give an incorrect number of arguments for a specific DSL function
  • Provide option to show all DSL methods and their signatures
@forgedhallpass forgedhallpass added Status: In Progress This issue is being worked on, and has someone assigned. Type: Enhancement Most issues will probably ask for additions or changes. labels Nov 26, 2021
@forgedhallpass forgedhallpass self-assigned this Nov 26, 2021
@forgedhallpass forgedhallpass linked a pull request Nov 26, 2021 that will close this issue
forgedhallpass added a commit that referenced this issue Dec 7, 2021
Added support for letting people know if:
* the DSL expression does not return a boolean value
* an invalid custom function signature was provided and then display all available function signatures
* an invalid function was provided and then display the correct signature

Unified the DSL function names to use snake case. The old signatures are also kept for backward compatibility.
@forgedhallpass forgedhallpass removed the Status: In Progress This issue is being worked on, and has someone assigned. label Dec 7, 2021
@forgedhallpass
Copy link
Contributor Author

Template test cases:

id: test-dsl

info:
  name: DSL test
  author: forgedhallpass
  severity: info

file:
  - extensions:
    - txt

    matchers:
      - type: dsl
        dsl:
#          - print_debu()               # invalid DSL function. Display available options
#          - 'to_lower("a", "b", "c")'  # invalid method signature. Display correct one
#          - 'to_lower("a")'            # DSL expression should return a boolean
#          - 'to_lower("a") == "a"'     # positive test case
#          - 'tolower("a") == "a"'      # positive test case, backwards compatible

Case 1: pint_debu() invalid DSL function
image

Case 2: to_lower("a", "b", "c")
image

Case 3: to_lower("a")
image

@ehsandeep ehsandeep added this to the v2.5.4 milestone Dec 9, 2021
forgedhallpass added a commit that referenced this issue Dec 9, 2021
Sort the output signatures
forgedhallpass added a commit that referenced this issue Dec 9, 2021
Sort the output signatures.
Lint: simplified the sorting.
ehsandeep pushed a commit that referenced this issue Dec 9, 2021
* feat: Improve DSL function UX #1295

Sort the output signatures

* feat: Improve DSL function UX #1295

Sort the output signatures.
Lint: simplified the sorting.
@ehsandeep ehsandeep added the Status: Completed Nothing further to be done with this issue. Awaiting to be closed. label Dec 9, 2021
@forgedhallpass
Copy link
Contributor Author

Related documentation ticket: projectdiscovery/nuclei-docs#27

ehsandeep pushed a commit that referenced this issue Dec 15, 2021
* feat: Improve DSL function UX #1295

Sort the output signatures

* feat: Improve DSL function UX #1295

Sort the output signatures.
Lint: simplified the sorting.

* bug: fixed couple of bugs in the DSL functions

Input number parameters are stored as float64 types, hence the type conversion should happen accordingly. Affected functions:
* rand_int
* wait_for
* unix_time
* rand_text_numeric

Added tests for all functions.
Related: #1261

* bug: fixed couple of bugs in the DSL functions

Handle cases when the optional input character set is an empty string. Affected methods:
* rand_char
* rand_base

* bug: fixed couple of bugs in the DSL functions

Change rand_char to return a one character string, instead of the character code

* refactor: Minor integration test changes to show the actual and expected result numbers

* test: Added integration test for all existing DSL functions

* test: Added integration test for all existing DSL functions

Fixing linter issues.

* feat: Add "repeat" DSL function

* test: Add "repeat" DSL function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants