Generate Nuclei security templates from OpenAPI (Swagger) specifications using AI-assisted scripting.
Manual: @create_nuclei.
glob: *.yaml, *.yml, *.json, .yml, .yaml, .json
- Always create a
Changelog.mdto keep track of changes made to the codebase. Changelog.mdshould also include the changes made to Windsurf's workspace rules.
- CREATE or MODIFY
Changelog.md. - RUN Workflow 1.
- RUN Workflow 2.
- RUN Workflow 3.
- RUN Workflow 4.
- RUN Workflow 5.
- AIM: This workflow focuses on learning how to better nuclei templates with proper structure, syntax and best practices.
- IMPORTANT: USE
CascadeProjects/nuclei-openapi-templates/nuclei_refs/http_doc.mdto understand how to write Nuclei DAST Templates. - IMPORTANT: Use
config.jsonfile to get the list of directories to save the nuclei templates and OpenAPI Swagger location. - DO NOT make any changes to
CascadeProjects/nuclei-openapi-templates/nuclei_refs/http_doc.mdfile. - IMPORTANT: This directory and file should only be used as a reference to understand how to write nuclei templates
- IMPORTANT: USE
- WRITE Workflow 1 Completed.
-
AIM: This workflow focuses on getting a list of endpoints and their details. These details are required to create more extensive nuclei templates in workflow 3.
-
When user asks to generate a nuclei template, do the following steps everytime:
- IF user asks to create a nuclei template then ASK whether user wants to provide a list of endpoints or RUN the
openapi_parser.pyto extract the endpoints. - IMPORTANT: RETRIEVE details of each endpoint from the swagger file given in
config.json - HOW TO RETREIVE ENDPOINT DETAILS
- NEVER Assume anything, always query the given swagger file.
- GET the endpoint details from the "paths" section of the swagger file.
- EACH POST/PUT/DELETE might have a field "requestBody" which is the request body.
- "requestBody" will contain the "$refs" which are the fields required in request body.
- FOLLOW the path of "$refs" separated by '/' to get the fields required in request body.
- WRITE "Request Body" section in the template.
- EXAMPLES
- Good Example of details includes:
- What's the method used by endpoint
- What are the fields required in request (required)
- What are the headers
- If there is any security authentication being used
- What's the base URL or Authentication URL
- Bad Example of details includes:
- No information about security authentication.
- No information about headers.
- No information about fields required in request body.
- IF user asks to create a nuclei template then ASK whether user wants to provide a list of endpoints or RUN the
-
ASK: ONCE "HOW TO RETRIEVE DETAILS" point is completed, then only ask the user to "which specific endpoint you want to generate nuclei templates for and which set of parameters to test for".
-
RECEIVE endpoint and parameter from user.
-
WRITE "Workflow 2 Completed".
-
AIM: This workflow focuses on generating, efficient, accurate Nuclei DAST Templates to identify vulnerabilities in the API and web applications. Templates should be alinged with standard security testing practices, should avoid duplication and should be optimized for reusability and clarity.
-
GOOD TEMPLATE EXAMPLE:
- REFER
CascadeProjects/nuclei-openapi-templates/nuclei_refs/REFERENCE_INDEX.mdfor good template examples. - DO NOT modify this file, use this as a reference for how to write good and efficient nuclei templates
- REFER
-
BAD TEMPLATE EXAMPLE:
- REFER
CascadeProjects/nuclei-openapi-templates/nuclei_refs/BAD_REFERENCE_INDEX.mdfor bad template examples. - DO NOT modify this file, use this as a reference for how not to write bad, inefficient, inaccurate nuclei templates.
- REFER
-
CRITICAL: Store the Nuclei DAST Templates in their respective directories as defined in "config.json". For example, if a vulnerability belongs to "PII data disclosure, it should come under
CascadeProjects/nuclei-openapi-templates/dast/data_disclosure/directory. -
ALWAYS ask user to verify the template before saving.
-
ALWAYS: If the nuclei template contains any placeholders in the request body then do the following steps:
- CHECK if the placeholder is already defined in
configurations/user_data.json. - IF the placeholder is defined in
configurations/user_data.json, then populate the placeholder with the value fromconfigurations/user_data.json. - IF the placeholder is not defined in
configurations/user_data.json, then WAIT until the user provides the data to be populated in the request body.
- CHECK if the placeholder is already defined in
-
WRITE "Workflow 3 Completed".
- AIM: Your goal is to test the generated templates for any security vulnerabilities or loopholes
- Once all the nuclei templates or nuclei workflows are generated, perform the following steps and REMEMBER you should not ask user to run these commands, run it by yourself and always take user input after each command is completed.
- RUN command
python nuclei-openapi-templates/nuclei.py <filename> <vulnerability_name>to format the nuclei templates. - RUN command
nuclei -validate -t <filename>to validate the nuclei templates. - ASK user about the BaseURL value. Ask this always.
- ALWAYS provide command to user in case they want to test out the Nuclei DAST templates.
- Includes:
- template location (Example:
{{PWD}}/template_name) - target name (Example:
base_url) - any other parameters required as per the generated nuclei template.
- template location (Example:
- In case of Nuclei workflow, execute the command
nuclei -w <workflow_name> -target {{BaseURL}} -debugto run nuclei workflows. - In case of Nuclei templates, execute the nuclei command
nuclei -t <template_name> -target {{BaseURL}} -debugto run nuclei templates.
- RUN command
- WRITE "Workflow 4 Completed".
- AIM: Your goal is to generate Nuclei Workflows
- IMPORTANT: USE
CascadeProjects/nuclei-openapi-templates/nuclei_refs/workflows.mdto understand how to write Nuclei DAST Workflows. - IMPORTANT: You should create a workflow of templates you've created in the previous steps and let the user review it first.
- WRITE "Workflow 5 Completed".