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

Add regexp pattern for template-id #1151

Merged
merged 6 commits into from
Oct 25, 2021

Conversation

zerodivisi0n
Copy link
Contributor

Do I understand correctly that this is enough to fix #276?
These changes produce the following json schema output in nuclei-jsonschema.json:

"id": {
  "pattern": "^(?:[a-zA-Z0-9][a-zA-Z0-9]*-?[a-zA-Z0-9]+?)+$",
  "type": "string",
  "title": "id of the template",
  "description": "The Unique ID for the template",
  "examples": [
    "cve-2021-19520"
  ]
}

Copy link
Member

@ehsandeep ehsandeep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zerodivisi0n can we also include support for underscore (_)?

@ehsandeep ehsandeep linked an issue Oct 19, 2021 that may be closed by this pull request
@forgedhallpass
Copy link
Contributor

Do I understand correctly that this is enough to fix #276?

@zerodivisi0n

  1. I don't think it's enough, but you can test it out easily. Just modify a template ID and run nuclei with the validate flag against it. The change would also require a unit test.
  2. The JSON Schema is only used for template development in an IDE context. If the pattern field is supported, you should be able to see the ID underlined/highlighted, notifying that there is a validation error.

Copy link
Contributor

@forgedhallpass forgedhallpass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment in the conversation

@zerodivisi0n
Copy link
Contributor Author

  • Updated regexp to a simpler one
  • Added a custom validation code as the simplest solution because the current jsonschema module does not support validation
  • Added some tests for the parser

@Ice3man543 Ice3man543 merged commit 1deedf5 into projectdiscovery:dev Oct 25, 2021
@ehsandeep ehsandeep added Status: Completed Nothing further to be done with this issue. Awaiting to be closed. hacktoberfest-accepted labels Oct 25, 2021
@Ice3man543
Copy link
Member

Thanks for the PR @zerodivisi0n. Merged it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Status: Completed Nothing further to be done with this issue. Awaiting to be closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation for template ID
4 participants