Improve template JSON schema for editor validation - #7579
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (22)
🚧 Files skipped from review as they are similar to previous changes (22)
WalkthroughThe change adds shared JSON Schema composition helpers and metadata for templates, Info sections, workflows, operators, and protocol requests. It updates schema serialization with stable identifiers and description conversion, and adds a Makefile target for JSON-schema-only regeneration. ChangesJSON Schema generation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Makefile
participant docgen
participant jsonschemaReflector
Makefile->>docgen: build and run genschema
docgen->>jsonschemaReflector: reflect schema with stable BaseSchemaID
jsonschemaReflector-->>docgen: encoded schema
docgen->>docgen: update $id and description keys
docgen-->>Makefile: write nuclei-jsonschema.json
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/docgen/docgen.go`:
- Around line 89-91: Update the description handling in the docgen map
transformation so it retains the original "description" entry while also adding
the "markdownDescription" Monaco extension; remove the deletion from the branch
guarded by parent != "properties", preserving the existing conversion scope.
In `@pkg/protocols/http/http_schema.go`:
- Line 383: Correct the spelling of “concurreny” to “concurrency” in the Threads
description string, leaving the rest of the text unchanged.
In `@pkg/protocols/network/network_schema.go`:
- Around line 92-95: Update networkRequestAnyOfRequired to use a single
schema.RequiredCombos entry that requires both “host” and “inputs” together,
replacing the separate schema.Require entries so requests containing only one
field no longer validate.
In `@pkg/templates/templates_schema.go`:
- Line 428: Update the workflow template schema requirement near
schema.Require("workflows") to use the same base requirement as protocol
templates, enforcing the documented id + info + workflows contract while
retaining workflows as required.
In `@pkg/utils/schema/helpers.go`:
- Around line 53-65: Update ExtendSchema’s oneOf construction to preserve array
item schemas for referenced array properties such as info.author and info.tags.
When building each branch, carry over the original array Items constraint (or
expose it through PropertyMetadata) so string-array branches still reject
non-string elements, while retaining the existing parent Ref and Type clearing
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a752a221-e54a-4576-87f6-6bf3c9c0e316
⛔ Files ignored due to path filters (1)
nuclei-jsonschema.jsonis excluded by!**/*.json
📒 Files selected for processing (22)
Makefilecmd/docgen/docgen.gopkg/model/model.gopkg/model/model_schema.gopkg/operators/extractors/extractors_schema.gopkg/operators/matchers/matchers_schema.gopkg/protocols/code/code_schema.gopkg/protocols/dns/dns_schema.gopkg/protocols/file/file_schema.gopkg/protocols/headless/headless_schema.gopkg/protocols/http/http.gopkg/protocols/http/http_method_types.gopkg/protocols/http/http_schema.gopkg/protocols/javascript/js_schema.gopkg/protocols/network/network_schema.gopkg/protocols/ssl/ssl_schema.gopkg/protocols/websocket/websocket_schema.gopkg/protocols/whois/whois_schema.gopkg/templates/templates.gopkg/templates/templates_schema.gopkg/utils/schema/helpers.gopkg/workflows/workflows_schema.go
| var networkRequestAnyOfRequired = []schema.RequiredCombos{ | ||
| schema.Require("host"), | ||
| schema.Require("inputs"), | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Require host and inputs together.
Lines 92-95 emit anyOf: [{required:["host"]}, {required:["inputs"]}], so a request with only one field validates. Use one combination requiring both fields.
Proposed fix
var networkRequestAnyOfRequired = []schema.RequiredCombos{
- schema.Require("host"),
- schema.Require("inputs"),
+ schema.Require("host", "inputs"),
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| var networkRequestAnyOfRequired = []schema.RequiredCombos{ | |
| schema.Require("host"), | |
| schema.Require("inputs"), | |
| } | |
| var networkRequestAnyOfRequired = []schema.RequiredCombos{ | |
| schema.Require("host", "inputs"), | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/protocols/network/network_schema.go` around lines 92 - 95, Update
networkRequestAnyOfRequired to use a single schema.RequiredCombos entry that
requires both “host” and “inputs” together, replacing the separate
schema.Require entries so requests containing only one field no longer validate.
1364270 to
0a0a9a1
Compare
Summary
nuclei-jsonschema.jsongeneration with richer field docs, examples, deprecations, andanyOfrequired combinations for Template/Info/HTTP and all remaining protocols (DNS, TCP, File, Headless, SSL, Websocket, Whois, Code, Javascript) plus workflows/matchers/extractors$idand emitmarkdownDescriptionfor Monaco/VS Code autocomplete; addmake genschemaCloses #4950
Summary by CodeRabbit