Add missing Hindi locale translations#1345
Add missing Hindi locale translations#1345xovishnukosuri wants to merge 3 commits intoOWASP:masterfrom
Conversation
Summary by CodeRabbit
WalkthroughThis PR refactors file I/O operations across the codebase by replacing Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@nettacker/core/messages.py`:
- Around line 24-25: The code currently calls yaml.load(StringIO(yaml_text),
Loader=yaml.FullLoader) which can deserialize arbitrary Python objects; replace
this with yaml.safe_load to restrict parsing to basic YAML types. Update the
call to use yaml.safe_load(StringIO(yaml_text)) (or yaml.safe_load(yaml_text))
and remove the Loader=yaml.FullLoader usage so the locale/translation data is
parsed safely; adjust any surrounding code that expects loader-specific behavior
if needed. Ensure you modify the occurrence of yaml.load and remove references
to yaml.FullLoader in nettacker/core/messages.py while keeping Path.read_text
and StringIO usage intact.
In `@nettacker/locale/hi.yaml`:
- Around line 124-125: Add the missing Hindi localization key
"finish_build_report" to the hi.yaml locale file (near the existing keys
build_compare_report and user_wordlist) with an appropriate Hindi translation so
that calls to finish_build_report used by nettacker/core/graph.py resolve;
ensure the key is formatted like the other entries (key: "translated string")
and follows YAML quoting/spacing conventions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 01eeb935-d6bc-456d-bd0b-7bab724a9b70
📒 Files selected for processing (8)
nettacker/core/app.pynettacker/core/fuzzer.pynettacker/core/messages.pynettacker/core/utils/common.pynettacker/lib/compare_report/engine.pynettacker/lib/graph/d3_tree_v1/engine.pynettacker/lib/html_log/log_data.pynettacker/locale/hi.yaml
| yaml_text = Path(filename).read_text(encoding="utf-8") | ||
| return yaml.load(StringIO(yaml_text), Loader=yaml.FullLoader) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n nettacker/core/messages.py | head -35Repository: OWASP/Nettacker
Length of output: 1090
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Detect custom/python-specific YAML tags that might require unsafe loaders
rg -n --type=yaml '!!python|!python|!<|tag:yaml.org,2002:python' nettacker/locale || true
# 2) Verify all locale YAML files parse with safe_load
python3 - <<'PY'
from pathlib import Path
import yaml, sys
failed = []
for p in Path("nettacker/locale").glob("*.yaml"):
try:
yaml.safe_load(p.read_text(encoding="utf-8"))
except Exception as e:
failed.append((str(p), str(e)))
if failed:
for path, err in failed:
print(f"{path}: {err}")
sys.exit(1)
print("All locale YAML files parse successfully with yaml.safe_load.")
PYRepository: OWASP/Nettacker
Length of output: 120
🏁 Script executed:
# Check the structure of locale YAML files
find nettacker/locale -name "*.yaml" -type f | head -5 | xargs -I {} sh -c 'echo "File: {}"; head -20 {}'Repository: OWASP/Nettacker
Length of output: 4895
🏁 Script executed:
# Check current imports in messages.py
head -10 nettacker/core/messages.pyRepository: OWASP/Nettacker
Length of output: 226
Use yaml.safe_load instead of yaml.load(..., FullLoader) for locale data.
Line 25 uses an unsafe loader that can deserialize arbitrary Python objects. These locale files contain only translation data, so safe_load is sufficient and safer.
🔧 Proposed fix
def load_yaml(filename):
yaml_text = Path(filename).read_text(encoding="utf-8")
- return yaml.load(StringIO(yaml_text), Loader=yaml.FullLoader)
+ return yaml.safe_load(StringIO(yaml_text))🧰 Tools
🪛 Ruff (0.15.2)
[error] 25-25: Probable use of unsafe loader FullLoader with yaml.load. Allows instantiation of arbitrary objects. Consider yaml.safe_load.
(S506)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@nettacker/core/messages.py` around lines 24 - 25, The code currently calls
yaml.load(StringIO(yaml_text), Loader=yaml.FullLoader) which can deserialize
arbitrary Python objects; replace this with yaml.safe_load to restrict parsing
to basic YAML types. Update the call to use yaml.safe_load(StringIO(yaml_text))
(or yaml.safe_load(yaml_text)) and remove the Loader=yaml.FullLoader usage so
the locale/translation data is parsed safely; adjust any surrounding code that
expects loader-specific behavior if needed. Ensure you modify the occurrence of
yaml.load and remove references to yaml.FullLoader in nettacker/core/messages.py
while keeping Path.read_text and StringIO usage intact.
| build_compare_report: "तुलना रिपोर्ट बनाई जा रही है" | ||
| finish_build_report: "तुलना रिपोर्ट तैयार हो गई" No newline at end of file | ||
| user_wordlist: उपयोगकर्ताओं को अपना स्वयं का वर्डलिस्ट दर्ज करने की अनुमति देता है |
There was a problem hiding this comment.
Missing Hindi translation for finish_build_report.
Line 124 has build_compare_report, but finish_build_report is still absent even though it is used by nettacker/core/graph.py (Line 71). This leaves a localization gap for Hindi users.
🌐 Proposed fix
build_compare_report: "तुलना रिपोर्ट बनाई जा रही है"
+finish_build_report: तुलना रिपोर्ट तैयार हो गई
user_wordlist: उपयोगकर्ताओं को अपना स्वयं का वर्डलिस्ट दर्ज करने की अनुमति देता है📝 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.
| build_compare_report: "तुलना रिपोर्ट बनाई जा रही है" | |
| finish_build_report: "तुलना रिपोर्ट तैयार हो गई" | |
| \ No newline at end of file | |
| user_wordlist: उपयोगकर्ताओं को अपना स्वयं का वर्डलिस्ट दर्ज करने की अनुमति देता है | |
| build_compare_report: "तुलना रिपोर्ट बनाई जा रही है" | |
| finish_build_report: तुलना रिपोर्ट तैयार हो गई | |
| user_wordlist: उपयोगकर्ताओं को अपना स्वयं का वर्डलिस्ट दर्ज करने की अनुमति देता है |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@nettacker/locale/hi.yaml` around lines 124 - 125, Add the missing Hindi
localization key "finish_build_report" to the hi.yaml locale file (near the
existing keys build_compare_report and user_wordlist) with an appropriate Hindi
translation so that calls to finish_build_report used by nettacker/core/graph.py
resolve; ensure the key is formatted like the other entries (key: "translated
string") and follows YAML quoting/spacing conventions.
Fixes #1289 (partial - Hindi only)
Adds 18 missing Hindi translations that were present in en.yaml but missing from hi.yaml:
Note: Japanese (ja.yaml) translations for these keys were already present.