alibaba / alibaba/open-code-review
feat(allowlist): add Jinja template support
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 1.8k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 105
Description
## Description
Add first-class review support for Jinja templates as a focused subtask of #470.
Jinja templates currently fall outside the file allowlist, so OpenCodeReview cannot select `.jinja2` or `.j2` files and they cannot receive template-specific review guidance. This contribution will add those two extensions from the tracker and route them to a dedicated Jinja rule.
## Scope
- Add `.jinja2` and `.j2` to `internal/config/allowlist/supported_file_types.json`.
- Add case-insensitive positive coverage to `internal/config/allowlist/allowed_ext_test.go`.
- Add `internal/config/rules/rule_docs/jinja.md` with Jinja-specific correctness and security guidance.
- Register `**/*.{jinja2,j2}` in `internal/config/rules/system_rules.json`.
- Add resolver coverage in `internal/config/rules/system_rules_test.go`.
No test-file exclusion pattern is planned: Jinja template projects do not have one broadly accepted template-test path convention, and application test source usually uses the host language's extension instead.
## Review focus
The Jinja rule will cover high-signal, Jinja-specific risks rather than repeating generic review advice:
- autoescaping, `Markup`, `|safe`, and HTML/attribute/URL/JavaScript context boundaries;
- template injection and untrusted template source;
- `StrictUndefined` versus silent undefined values;
- sandbox limitations and unsafe object exposure;
- include/import context and macro parameter correctness;
- repeated expensive filters or lookups inside loops;
- whitespace and escaping behavior that changes rendered output.
## Acceptance criteria
- [ ] `.jinja2`, `.JINJA2`, `.j2`, and `.J2` are recognized.
- [ ] Jinja paths resolve to the dedicated review rule.
- [ ] Existing default and language-specific resolution remains unchanged.
- [ ] `make test` passes.
- [ ] `make check` passes.
This issue is claimed in #470 before implementation to avoid duplicate work.
Contributor guide
Research direction
Start with internal/config/allowlist/supported_file_types.json and allowed_ext_test.go, then read the rule registration and resolver tests in internal/config/rules/. Add the named Jinja rule documentation and registrations, verify case-insensitive resolution and unchanged defaults, then run make test and make check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100