python / protected_text.py
python / protected_text.py
"""Reviewed translations of rule-owned text; never translate page observations."""
TRANSLATIONS = {
"Browser accesses an HTTP URL without an applicable cached or preloaded HSTS policy": "ブラウザが、適用されるキャッシュ済みまたはpreload済みのHSTSポリシーなしでHTTP URLへアクセスすること。",
"An attacker can interfere with that HTTP connection": "攻撃者がそのHTTP接続に干渉できること。",
"HTTP traffic could be modified or disclosed on that path.": "そのHTTP経路で通信内容が改変または露出する可能性があります。",
"Attacker-controlled content is served with an unsuitable MIME type": "攻撃者が制御するコンテンツが、不適切なMIMEタイプで配信されること。",
"Browser interprets that content as executable": "ブラウザがそのコンテンツを実行可能と解釈すること。",
"Content could execute under affected MIME handling rules.": "該当するMIME処理規則の下で、コンテンツが実行される可能性があります。",
"Sensitive data is present in a referring URL": "参照元URLに機微な情報が含まれること。",
"Effective browser referrer policy allows disclosure to a recipient": "ブラウザに適用されるReferrer-Policyが、その情報の受信者への開示を許可すること。",
"Sensitive URL data could reach the recipient.": "URL内の機微な情報が受信者へ送られる可能性があります。",
"A browser feature is available to untrusted content": "信頼できないコンテンツがブラウザ機能を利用可能であること。",
"Browser and user permissions allow its use": "ブラウザの権限設定とユーザーの許可が、その機能の利用を認めること。",
"Unneeded feature access may expand the impact of untrusted content.": "不要な機能へのアクセスが、信頼できないコンテンツの影響を拡大する可能性があります。",
"Application needs this isolation boundary": "アプリケーションがこの分離境界を必要とすること。",
"An attack depends on the absent boundary": "攻撃の成立が、その分離境界の欠如に依存すること。",
"The missing boundary could contribute to that attack; no attack was tested.": "分離境界の欠如がその攻撃に寄与する可能性があります。攻撃の検証は行っていません。",
"Hint is accurate": "製品ヒントが正確であること。",
"A separately verified weakness affects the deployed product": "別途検証された弱点が、実際に配備された製品に影響すること。",
"The hint could assist reconnaissance for that weakness.": "製品ヒントが、その弱点に関する偵察を助ける可能性があります。",
"A separate XSS or HTML injection exists": "別途XSSまたはHTMLインジェクションが存在すること。",
"Browser permits the injected script under all effective policies": "ブラウザが、適用されるすべてのポリシーの下で、注入されたスクリプトの実行を許可すること。",
"If injection exists, missing CSP restrictions may increase script execution or data disclosure.": "注入が存在する場合、CSPによる制限の欠如がスクリプト実行や情報露出を拡大する可能性があります。",
"Injection impact may increase if scripts are unrestricted.": "スクリプト実行が制限されない場合、注入による影響が拡大する可能性があります。",
"An existing injection may execute inline script.": "既に存在する注入経路により、インラインスクリプトが実行される可能性があります。",
"A separate injection or attacker-controlled script input exists": "別途注入経路、または攻撃者が制御するスクリプト入力が存在すること。",
"All effective policies and application code permit the relevant execution": "適用されるすべてのポリシーとアプリケーションコードが、該当する実行を許可すること。",
"That separate weakness may have greater script execution impact.": "その別の弱点によるスクリプト実行の影響が拡大する可能性があります。",
"Cookie contains sensitive state and is accepted by the browser": "Cookieが機微な状態を含み、ブラウザに受け入れられていること。",
"A matching HTTP request occurs without applicable HSTS upgrade": "適用されるHSTSによるHTTPSへの切り替えなしで、当該Cookieの送信対象となるHTTPリクエストが発生すること。",
"An attacker can observe or alter that HTTP traffic": "攻撃者がそのHTTP通信を観測または改変できること。",
"Sensitive cookie data could be exposed on that HTTP path.": "そのHTTP経路で、Cookie内の機微な情報が露出する可能性があります。",
"Attacker-controlled JavaScript executes in the cookie's accessible origin/scope": "攻撃者が制御するJavaScriptが、当該Cookieにアクセス可能なオリジン・スコープで実行されること。",
"Browser accepts this cookie and script can access it": "ブラウザが当該Cookieを受け入れ、スクリプトから読み取れること。",
"Cookie disclosure may occur; account takeover additionally requires reusable valid session credentials and no effective compensating controls.": "Cookieの情報露出が生じる可能性があります。アカウント乗っ取りには、さらに再利用可能な有効なセッション認証情報と、有効な補完対策の不在が必要です。これらの追加条件も未検証です。",
"Browser sends the cookie on the relevant cross-site request": "ブラウザが該当するクロスサイトリクエストで当該Cookieを送信すること。",
"Endpoint changes sensitive state": "エンドポイントが機微な状態を変更すること。",
"Effective CSRF token/origin checks are absent or bypassed": "有効なCSRFトークン・オリジン検査が存在しない、または回避されること。",
"A cross-site request could change sensitive state if all conditions hold.": "すべての成立条件を満たす場合、クロスサイトリクエストで機微な状態が変更される可能性があります。",
"Browser rejects this combination": "ブラウザがこのCookie属性の組み合わせを拒否すること。",
"Application depends on the cookie": "アプリケーションが当該Cookieに依存すること。",
"Cookie-dependent functionality may fail.": "当該Cookieに依存する機能が動作しなくなる可能性があります。",
"Browser sends cookie in a cross-site state-changing request": "ブラウザが、クロスサイトの状態変更リクエストで当該Cookieを送信すること。",
"Other CSRF checks are absent or bypassed": "その他のCSRF対策による検査が存在しない、または回避されること。",
"CSRF may be possible under these conditions.": "これらの成立条件を満たす場合、CSRFが成立する可能性があります。",
"Third-party bytes are compromised or unexpectedly changed": "サードパーティが配信するファイルの内容が改ざん、または予期せず変更されること。",
"Browser loads and executes those bytes under effective CSP and other controls": "ブラウザが、適用されるCSPやその他の制御の下で、その変更された内容を読み込み・実行すること。",
"Changed script may execute with page privileges.": "変更されたスクリプトが、そのページの権限で実行される可能性があります。",
"CDN content changes at this URL": "当該URLでCDNが配信するファイルの内容が変更されること。",
"Application relies on fixed integrity or unchanged script behavior": "アプリケーションが、固定された整合性または変わらないスクリプト動作に依存すること。",
"SRI may block changed bytes or application behavior may change; compromise is not established.": "SRIが変更された内容の読み込みをブロックする、またはアプリケーションの動作が変わる可能性があります。侵害の有無は未確認です。",
"Request does not satisfy SRI cross-origin CORS requirements": "リクエストが、SRIのクロスオリジン読み込みに必要なCORS要件を満たさないこと。",
"Browser may reject the script, affecting functionality.": "ブラウザがスクリプトの読み込みを拒否し、機能に影響する可能性があります。",
"Browser loads a referenced resource over HTTP without upgrading or blocking": "ブラウザが、HTTPSへの切り替えやブロックを行わず、参照されたリソースをHTTPで読み込むこと。",
"Attacker can interfere with that HTTP connection": "攻撃者がそのHTTP接続に干渉できること。",
"Resource data may be disclosed or modified; executable resources have greater potential impact.": "リソースの内容が露出または改変される可能性があります。実行可能なリソースの場合は、影響がさらに大きくなる可能性があります。",
"Browser permits attacker-origin framing under all effective policies": "ブラウザが、適用されるすべてのポリシーの下で、攻撃者のオリジンからのフレーム埋め込みを許可すること。",
"Page exposes sensitive actionable UI": "ページに機微な操作を行えるUIがあること。",
"A user can be induced to interact with the framed UI": "ユーザーを、そのフレーム内のUI操作へ誘導できること。",
"A user could trigger unintended UI actions.": "ユーザーが意図しないUI操作を行う可能性があります。",
}
def protected_block(finding, level_label, escape):
"""Exact lookup avoids silently applying stale translations to changed rules."""
original = finding["required_conditions"] + [finding["conditional_impact"]["description"]]
complete = all(text in TRANSLATIONS for text in original)
translated = [TRANSLATIONS.get(text, "日本語定型文未登録。原文(未検証): " + escape(text)) for text in original]
lines = ["**成立条件(未検証)**", ""]
lines.extend(f"{n}. {text}" for n, text in enumerate(translated[:-1], 1))
lines.extend(["", "**条件付き影響**", "",
f"条件成立時の影響: {level_label}({escape(finding['conditional_impact']['level'])})。",
"上記の成立条件をすべて満たす場合に限る説明です。成立条件はすべて未検証です。",
translated[-1], "",
"severityは設定上の改善優先度です。条件付き影響は条件成立時の影響であり、侵害確率やサイトの安全性ではありません。",
"単独の攻撃成立は未実証です。攻撃不可能という判定ではありません。"])
return "\n".join(lines) + "\n", "reviewed" if complete else "untranslated_source_preserved"
"""Reviewed translations of rule-owned text; never translate page observations."""
TRANSLATIONS = {
"Browser accesses an HTTP URL without an applicable cached or preloaded HSTS policy": "ブラウザが、適用されるキャッシュ済みまたはpreload済みのHSTSポリシーなしでHTTP URLへアクセスすること。",
"An attacker can interfere with that HTTP connection": "攻撃者がそのHTTP接続に干渉できること。",
"HTTP traffic could be modified or disclosed on that path.": "そのHTTP経路で通信内容が改変または露出する可能性があります。",
"Attacker-controlled content is served with an unsuitable MIME type": "攻撃者が制御するコンテンツが、不適切なMIMEタイプで配信されること。",
"Browser interprets that content as executable": "ブラウザがそのコンテンツを実行可能と解釈すること。",
"Content could execute under affected MIME handling rules.": "該当するMIME処理規則の下で、コンテンツが実行される可能性があります。",
"Sensitive data is present in a referring URL": "参照元URLに機微な情報が含まれること。",
"Effective browser referrer policy allows disclosure to a recipient": "ブラウザに適用されるReferrer-Policyが、その情報の受信者への開示を許可すること。",
"Sensitive URL data could reach the recipient.": "URL内の機微な情報が受信者へ送られる可能性があります。",
"A browser feature is available to untrusted content": "信頼できないコンテンツがブラウザ機能を利用可能であること。",
"Browser and user permissions allow its use": "ブラウザの権限設定とユーザーの許可が、その機能の利用を認めること。",
"Unneeded feature access may expand the impact of untrusted content.": "不要な機能へのアクセスが、信頼できないコンテンツの影響を拡大する可能性があります。",
"Application needs this isolation boundary": "アプリケーションがこの分離境界を必要とすること。",
"An attack depends on the absent boundary": "攻撃の成立が、その分離境界の欠如に依存すること。",
"The missing boundary could contribute to that attack; no attack was tested.": "分離境界の欠如がその攻撃に寄与する可能性があります。攻撃の検証は行っていません。",
"Hint is accurate": "製品ヒントが正確であること。",
"A separately verified weakness affects the deployed product": "別途検証された弱点が、実際に配備された製品に影響すること。",
"The hint could assist reconnaissance for that weakness.": "製品ヒントが、その弱点に関する偵察を助ける可能性があります。",
"A separate XSS or HTML injection exists": "別途XSSまたはHTMLインジェクションが存在すること。",
"Browser permits the injected script under all effective policies": "ブラウザが、適用されるすべてのポリシーの下で、注入されたスクリプトの実行を許可すること。",
"If injection exists, missing CSP restrictions may increase script execution or data disclosure.": "注入が存在する場合、CSPによる制限の欠如がスクリプト実行や情報露出を拡大する可能性があります。",
"Injection impact may increase if scripts are unrestricted.": "スクリプト実行が制限されない場合、注入による影響が拡大する可能性があります。",
"An existing injection may execute inline script.": "既に存在する注入経路により、インラインスクリプトが実行される可能性があります。",
"A separate injection or attacker-controlled script input exists": "別途注入経路、または攻撃者が制御するスクリプト入力が存在すること。",
"All effective policies and application code permit the relevant execution": "適用されるすべてのポリシーとアプリケーションコードが、該当する実行を許可すること。",
"That separate weakness may have greater script execution impact.": "その別の弱点によるスクリプト実行の影響が拡大する可能性があります。",
"Cookie contains sensitive state and is accepted by the browser": "Cookieが機微な状態を含み、ブラウザに受け入れられていること。",
"A matching HTTP request occurs without applicable HSTS upgrade": "適用されるHSTSによるHTTPSへの切り替えなしで、当該Cookieの送信対象となるHTTPリクエストが発生すること。",
"An attacker can observe or alter that HTTP traffic": "攻撃者がそのHTTP通信を観測または改変できること。",
"Sensitive cookie data could be exposed on that HTTP path.": "そのHTTP経路で、Cookie内の機微な情報が露出する可能性があります。",
"Attacker-controlled JavaScript executes in the cookie's accessible origin/scope": "攻撃者が制御するJavaScriptが、当該Cookieにアクセス可能なオリジン・スコープで実行されること。",
"Browser accepts this cookie and script can access it": "ブラウザが当該Cookieを受け入れ、スクリプトから読み取れること。",
"Cookie disclosure may occur; account takeover additionally requires reusable valid session credentials and no effective compensating controls.": "Cookieの情報露出が生じる可能性があります。アカウント乗っ取りには、さらに再利用可能な有効なセッション認証情報と、有効な補完対策の不在が必要です。これらの追加条件も未検証です。",
"Browser sends the cookie on the relevant cross-site request": "ブラウザが該当するクロスサイトリクエストで当該Cookieを送信すること。",
"Endpoint changes sensitive state": "エンドポイントが機微な状態を変更すること。",
"Effective CSRF token/origin checks are absent or bypassed": "有効なCSRFトークン・オリジン検査が存在しない、または回避されること。",
"A cross-site request could change sensitive state if all conditions hold.": "すべての成立条件を満たす場合、クロスサイトリクエストで機微な状態が変更される可能性があります。",
"Browser rejects this combination": "ブラウザがこのCookie属性の組み合わせを拒否すること。",
"Application depends on the cookie": "アプリケーションが当該Cookieに依存すること。",
"Cookie-dependent functionality may fail.": "当該Cookieに依存する機能が動作しなくなる可能性があります。",
"Browser sends cookie in a cross-site state-changing request": "ブラウザが、クロスサイトの状態変更リクエストで当該Cookieを送信すること。",
"Other CSRF checks are absent or bypassed": "その他のCSRF対策による検査が存在しない、または回避されること。",
"CSRF may be possible under these conditions.": "これらの成立条件を満たす場合、CSRFが成立する可能性があります。",
"Third-party bytes are compromised or unexpectedly changed": "サードパーティが配信するファイルの内容が改ざん、または予期せず変更されること。",
"Browser loads and executes those bytes under effective CSP and other controls": "ブラウザが、適用されるCSPやその他の制御の下で、その変更された内容を読み込み・実行すること。",
"Changed script may execute with page privileges.": "変更されたスクリプトが、そのページの権限で実行される可能性があります。",
"CDN content changes at this URL": "当該URLでCDNが配信するファイルの内容が変更されること。",
"Application relies on fixed integrity or unchanged script behavior": "アプリケーションが、固定された整合性または変わらないスクリプト動作に依存すること。",
"SRI may block changed bytes or application behavior may change; compromise is not established.": "SRIが変更された内容の読み込みをブロックする、またはアプリケーションの動作が変わる可能性があります。侵害の有無は未確認です。",
"Request does not satisfy SRI cross-origin CORS requirements": "リクエストが、SRIのクロスオリジン読み込みに必要なCORS要件を満たさないこと。",
"Browser may reject the script, affecting functionality.": "ブラウザがスクリプトの読み込みを拒否し、機能に影響する可能性があります。",
"Browser loads a referenced resource over HTTP without upgrading or blocking": "ブラウザが、HTTPSへの切り替えやブロックを行わず、参照されたリソースをHTTPで読み込むこと。",
"Attacker can interfere with that HTTP connection": "攻撃者がそのHTTP接続に干渉できること。",
"Resource data may be disclosed or modified; executable resources have greater potential impact.": "リソースの内容が露出または改変される可能性があります。実行可能なリソースの場合は、影響がさらに大きくなる可能性があります。",
"Browser permits attacker-origin framing under all effective policies": "ブラウザが、適用されるすべてのポリシーの下で、攻撃者のオリジンからのフレーム埋め込みを許可すること。",
"Page exposes sensitive actionable UI": "ページに機微な操作を行えるUIがあること。",
"A user can be induced to interact with the framed UI": "ユーザーを、そのフレーム内のUI操作へ誘導できること。",
"A user could trigger unintended UI actions.": "ユーザーが意図しないUI操作を行う可能性があります。",
}
def protected_block(finding, level_label, escape):
"""Exact lookup avoids silently applying stale translations to changed rules."""
original = finding["required_conditions"] + [finding["conditional_impact"]["description"]]
complete = all(text in TRANSLATIONS for text in original)
translated = [TRANSLATIONS.get(text, "日本語定型文未登録。原文(未検証): " + escape(text)) for text in original]
lines = ["**成立条件(未検証)**", ""]
lines.extend(f"{n}. {text}" for n, text in enumerate(translated[:-1], 1))
lines.extend(["", "**条件付き影響**", "",
f"条件成立時の影響: {level_label}({escape(finding['conditional_impact']['level'])})。",
"上記の成立条件をすべて満たす場合に限る説明です。成立条件はすべて未検証です。",
translated[-1], "",
"severityは設定上の改善優先度です。条件付き影響は条件成立時の影響であり、侵害確率やサイトの安全性ではありません。",
"単独の攻撃成立は未実証です。攻撃不可能という判定ではありません。"])
return "\n".join(lines) + "\n", "reviewed" if complete else "untranslated_source_preserved"