fix(catalog): preserve template names with config substrings - #7598
fix(catalog): preserve template names with config substrings#7598james-yusuke wants to merge 6 commits into
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 selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughKnown config-file detection now compares exact filenames or path basenames rather than substrings. Template classification and discovery tests cover filenames containing known config names. ChangesTemplate filename detection
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
|
@coderabbitai create an issue to track this PR (do not assign it to me) |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="projectdiscovery/nuclei"
pr_number="7598"
pr_url="https://github.com/${repo}/pull/${pr_number}"
comment_url="$(
gh api "repos/${repo}/issues/${pr_number}/comments" --paginate \
--jq '.[] | select(.user.login == "Mzack9999" and (.body | contains("`@coderabbitai` create an issue to track this PR"))) | .html_url' \
| tail -n 1
)"
if [[ -z "$comment_url" ]]; then
echo "Could not find the requesting comment URL on ${pr_url}." >&2
exit 1
fi
body="$(cat <<EOF
## Summary
Track the template-discovery behavior corrected in pull request #${pr_number}: valid template filenames that contain a known configuration filename, such as \`cves.json.yaml\`, must not be excluded.
## Required changes
Ensure both catalog-level template detection and disk catalog traversal identify known configuration files by an exact basename match rather than substring matching.
## Rationale
Substring matching incorrectly filters valid templates whose names merely include a known configuration-file name.
## Affected areas
- \`pkg/catalog/config/template.go\`
- \`pkg/catalog/disk/find.go\`
- Regression tests covering direct template paths and directory traversal
## Acceptance criteria
- A template such as \`http/cves.json.yaml\` is discovered when supplied directly.
- The same template is discovered during directory traversal.
- Actual known configuration files continue to be excluded.
- Relevant catalog tests and \`go vet\` pass.
## Backlinks
- Pull request: ${pr_url}
- Request: ${comment_url}
- Requested by: `@Mzack9999`
EOF
)"
issue_url="$(gh issue create \
--repo "$repo" \
--title "Track exact-basename matching for known template configuration files" \
--body "$body")"
echo "Created issue: ${issue_url}"Length of output: 1968
|
Summary
Fix template discovery when a valid template filename contains a known configuration filename, such as
cves.json.yaml.Root cause
The catalog and shared template predicate used substring matching to skip known configuration files. This also excluded valid YAML or JSON templates whose names merely contained
cves.json,contributors.json, orTEMPLATES-STATS.json.Changes
Validation
/usr/local/go/bin/go test ./pkg/catalog/... -count=1/usr/local/go/bin/go vet ./pkg/catalog/...Summary by CodeRabbit
Bug Fixes
cves.json.yaml.Tests