local-triage 0.0.0-stage → 0.10.0-dev.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +90 -2
- package/THIRD-PARTY-NOTICES.md +48 -0
- package/app/__init__.py +3 -0
- package/app/affiliation.py +137 -0
- package/app/ask.py +300 -0
- package/app/build_info.py +98 -0
- package/app/capec.py +168 -0
- package/app/capec_view.py +27 -0
- package/app/codecmp.py +59 -0
- package/app/config.py +411 -0
- package/app/context.py +1451 -0
- package/app/cvss.py +357 -0
- package/app/db.py +6234 -0
- package/app/defect.py +670 -0
- package/app/defect_check.py +323 -0
- package/app/defect_drafts.py +612 -0
- package/app/defect_dto.py +149 -0
- package/app/defect_fields.py +248 -0
- package/app/defect_form.py +124 -0
- package/app/defect_links.py +107 -0
- package/app/defect_local_text.py +103 -0
- package/app/defect_references.py +164 -0
- package/app/defect_where.py +147 -0
- package/app/ecosystem.py +51 -0
- package/app/executors.py +660 -0
- package/app/feeds.py +1231 -0
- package/app/guard.py +164 -0
- package/app/hub_block_builder.py +200 -0
- package/app/hub_block_version.py +220 -0
- package/app/hub_defects.py +4469 -0
- package/app/hub_effects.py +421 -0
- package/app/hub_entity_versions.py +108 -0
- package/app/hub_import.py +2054 -0
- package/app/hub_onboarding.py +114 -0
- package/app/hub_ops.py +330 -0
- package/app/hub_pull.py +1195 -0
- package/app/hub_state.py +255 -0
- package/app/hub_status.py +237 -0
- package/app/hub_sync.py +619 -0
- package/app/hub_sync_api.py +241 -0
- package/app/hub_sync_compare.py +1054 -0
- package/app/hub_sync_contract.py +75 -0
- package/app/hub_template_model.py +74 -0
- package/app/hub_text_scale.py +159 -0
- package/app/journal.py +250 -0
- package/app/llm.py +850 -0
- package/app/llm_chat.py +596 -0
- package/app/llm_http.py +319 -0
- package/app/llm_messages.py +401 -0
- package/app/llm_net.py +764 -0
- package/app/llm_ollama.py +571 -0
- package/app/lockfile.py +505 -0
- package/app/logsafe.py +54 -0
- package/app/main.py +367 -0
- package/app/mask_display.py +132 -0
- package/app/masking.py +814 -0
- package/app/metrics.py +194 -0
- package/app/model_traffic.py +519 -0
- package/app/models.py +483 -0
- package/app/navigation.py +121 -0
- package/app/osv.py +279 -0
- package/app/package_identity.py +189 -0
- package/app/package_transition.py +824 -0
- package/app/profile_gate.py +71 -0
- package/app/prompts.py +1108 -0
- package/app/provider_keys.py +189 -0
- package/app/providers.py +511 -0
- package/app/routes/__init__.py +10 -0
- package/app/routes/api.py +153 -0
- package/app/routes/capec.py +186 -0
- package/app/routes/common.py +407 -0
- package/app/routes/components.py +1499 -0
- package/app/routes/cwe.py +168 -0
- package/app/routes/decision_selected.py +153 -0
- package/app/routes/defect_add.py +223 -0
- package/app/routes/defect_card_routes.py +363 -0
- package/app/routes/defect_selected.py +342 -0
- package/app/routes/feeds.py +155 -0
- package/app/routes/findings.py +2736 -0
- package/app/routes/hub.py +402 -0
- package/app/routes/hub_bulk.py +288 -0
- package/app/routes/hub_defect_routes.py +1945 -0
- package/app/routes/hub_status_routes.py +1132 -0
- package/app/routes/hub_sync_routes.py +463 -0
- package/app/routes/journal.py +132 -0
- package/app/routes/projects.py +1601 -0
- package/app/routes/providers.py +336 -0
- package/app/routes/references.py +26 -0
- package/app/routes/runs.py +219 -0
- package/app/routes/sca.py +2722 -0
- package/app/routes/settings.py +163 -0
- package/app/run_errors.py +151 -0
- package/app/sca.py +1662 -0
- package/app/sca_contract.py +1289 -0
- package/app/sca_research.py +1089 -0
- package/app/sca_research_net.py +1007 -0
- package/app/sca_text.py +965 -0
- package/app/serve.py +70 -0
- package/app/settings_store.py +262 -0
- package/app/static/app.css +2802 -0
- package/app/static/app.js +3772 -0
- package/app/static/capec-license.txt +9 -0
- package/app/static/favicon.svg +1 -0
- package/app/static/fonts/Golos-Text_DemiBold.woff2 +0 -0
- package/app/static/fonts/Golos-Text_Regular.woff2 +0 -0
- package/app/static/fonts/OFL.txt +90 -0
- package/app/static/navigation.js +234 -0
- package/app/static/observability.js +121 -0
- package/app/static/theme.js +49 -0
- package/app/storage/__init__.py +16 -0
- package/app/storage/local_state.py +246 -0
- package/app/storage/migrate.py +110 -0
- package/app/storage/migrations/postgresql/0001_baseline.sql +896 -0
- package/app/storage/migrations/postgresql/0002_feeds_and_secrets.sql +55 -0
- package/app/storage/migrations/postgresql/0003_project_mask_display.sql +5 -0
- package/app/storage/migrations/postgresql/0004_package_identity.sql +36 -0
- package/app/storage/postgresql.py +573 -0
- package/app/storage/schema.py +619 -0
- package/app/storage/sql.py +57 -0
- package/app/storage/tools.py +254 -0
- package/app/telemetry.py +307 -0
- package/app/templates/base.html +91 -0
- package/app/templates/capec/context.html +3 -0
- package/app/templates/capec/detail.html +27 -0
- package/app/templates/capec/index.html +128 -0
- package/app/templates/components/_archive.html +11 -0
- package/app/templates/components/archived.html +19 -0
- package/app/templates/components/batch.html +35 -0
- package/app/templates/components/detail.html +332 -0
- package/app/templates/components/index.html +338 -0
- package/app/templates/components/research_preview.html +80 -0
- package/app/templates/components/research_run.html +54 -0
- package/app/templates/cwe/bdu.html +56 -0
- package/app/templates/cwe/detail.html +233 -0
- package/app/templates/cwe/index.html +97 -0
- package/app/templates/error.html +8 -0
- package/app/templates/feeds/index.html +65 -0
- package/app/templates/findings/card.html +639 -0
- package/app/templates/findings/decision_selected.html +41 -0
- package/app/templates/findings/defect_add.html +46 -0
- package/app/templates/findings/defect_selected.html +47 -0
- package/app/templates/findings/list.html +153 -0
- package/app/templates/findings/send_selected.html +53 -0
- package/app/templates/findings/trace.html +72 -0
- package/app/templates/journal/detail.html +19 -0
- package/app/templates/journal/index.html +19 -0
- package/app/templates/macros.html +440 -0
- package/app/templates/navigation-fields.html +1 -0
- package/app/templates/navigation.html +11 -0
- package/app/templates/projects/_identity_summary.html +42 -0
- package/app/templates/projects/defect_card.html +153 -0
- package/app/templates/projects/defect_create_preview.html +17 -0
- package/app/templates/projects/defect_fields_diff.html +6 -0
- package/app/templates/projects/defect_fields_form.html +40 -0
- package/app/templates/projects/defect_references.html +17 -0
- package/app/templates/projects/defect_sync_preview.html +28 -0
- package/app/templates/projects/defect_update_actions.html +6 -0
- package/app/templates/projects/defect_update_preview.html +24 -0
- package/app/templates/projects/defects.html +126 -0
- package/app/templates/projects/delete.html +31 -0
- package/app/templates/projects/external.html +61 -0
- package/app/templates/projects/folders.html +64 -0
- package/app/templates/projects/hub_accepted.html +10 -0
- package/app/templates/projects/hub_assignment.html +50 -0
- package/app/templates/projects/hub_pending.html +20 -0
- package/app/templates/projects/hub_pending_list.html +17 -0
- package/app/templates/projects/hub_state_note.html +23 -0
- package/app/templates/projects/hub_step_note.html +5 -0
- package/app/templates/projects/hub_sync.html +105 -0
- package/app/templates/projects/hub_sync_confirm.html +32 -0
- package/app/templates/projects/hub_sync_worker.html +5 -0
- package/app/templates/projects/hub_text_rules.html +64 -0
- package/app/templates/projects/identity_report.html +74 -0
- package/app/templates/projects/list.html +90 -0
- package/app/templates/projects/project.html +433 -0
- package/app/templates/reference-missing.html +14 -0
- package/app/templates/runs/run.html +166 -0
- package/app/templates/sca/card.html +476 -0
- package/app/templates/sca/index.html +321 -0
- package/app/templates/settings/hub_url.html +31 -0
- package/app/templates/settings/index.html +216 -0
- package/app/templates/settings/provider.html +229 -0
- package/app/templates/settings/providers.html +37 -0
- package/app/templates/worklists.html +52 -0
- package/app/textsafe.py +117 -0
- package/app/timing.py +245 -0
- package/app/triage.py +1743 -0
- package/app/view.py +430 -0
- package/app/worklists.py +204 -0
- package/examples/demo/demo-hub-report-v2.xlsx +0 -0
- package/examples/demo/demo-hub-report.xlsx +0 -0
- package/examples/demo/repos/billing-core/pom.xml +30 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/Invoice.java +9 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/InvoiceRepository.java +51 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/InvoiceStatus.java +11 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/config/DatabaseSettings.java +18 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/payment/PaymentTokenService.java +35 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/web/InvoiceExportController.java +57 -0
- package/examples/demo/repos/catalog-api/catalog_api/__init__.py +1 -0
- package/examples/demo/repos/catalog-api/catalog_api/products.py +24 -0
- package/examples/demo/repos/catalog-api/catalog_api/tasks.py +24 -0
- package/examples/demo/repos/catalog-api/catalog_api/views.py +17 -0
- package/examples/demo/repos/catalog-api/requirements.txt +3 -0
- package/npm/build.json +5 -0
- package/npm/cli.js +346 -0
- package/npm/files.manifest +224 -0
- package/npm/lib/binding.js +64 -0
- package/npm/lib/cluster.js +330 -0
- package/npm/lib/env.js +88 -0
- package/npm/lib/fsx.js +125 -0
- package/npm/lib/http.js +53 -0
- package/npm/lib/metrics.js +73 -0
- package/npm/lib/paths.js +150 -0
- package/npm/lib/pg.js +351 -0
- package/npm/lib/proc.js +101 -0
- package/npm/lib/python.js +133 -0
- package/npm/lib/stand.js +46 -0
- package/npm/lib/supervisor.js +1141 -0
- package/npm/lib/version.js +21 -0
- package/npm/requirements.txt +476 -0
- package/npm-shrinkwrap.json +111 -0
- package/package.json +37 -4
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"""Ключи профилей провайдеров моделей (ADR-0102 п. 8).
|
|
2
|
+
|
|
3
|
+
Ключ лежит в базе (app_state.secrets, ADR-0133) вместе с привязкой: адрес сервера (base_url) и
|
|
4
|
+
подтверждённые адреса, для которых он задан. В базе, снимке исполнителя, экспорте и интерфейсе ключа нет – в
|
|
5
|
+
интерфейсе только «задан, …последние 4 знака»; из журнала обмена вырезается заголовок авторизации, а ключ, который
|
|
6
|
+
сервер отразил в теле ответа, журнал хранит как есть (журнал – байт в байт, ADR-0102 п. 8). Заголовок авторизации уходит, только если адрес снимка совпадает
|
|
7
|
+
с привязкой; иначе запрос не отправляется вовсе (SendNotAllowed). Права файла – только владелец (0600 в контейнере
|
|
8
|
+
Linux); в Windows права файла не проверяются – это сказано в руководстве. Замена ключа – перезапись файла: она
|
|
9
|
+
действует и для незавершённых исполнений (ключа в снимке нет). Смена адреса или подтверждённых адресов профиля и
|
|
10
|
+
выключение профиля удаляют файл (app/providers.py). В резервные копии папки данных ключи входят.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import re
|
|
17
|
+
import secrets
|
|
18
|
+
import threading
|
|
19
|
+
import time
|
|
20
|
+
from typing import Any
|
|
21
|
+
|
|
22
|
+
from app.llm import SendNotAllowed
|
|
23
|
+
from app.llm_net import normalize_addresses
|
|
24
|
+
|
|
25
|
+
KEY_NOTE_MISSING = "Прогон на паузе. Задайте ключ профиля на странице «Настройки» и нажмите «Продолжить»."
|
|
26
|
+
KEY_NOTE_OTHER = ("Прогон на паузе. Ключ профиля задан для другого адреса сервера: нажмите «Продолжить» – "
|
|
27
|
+
"неразобранные находки пойдут новым прогоном на действующем профиле проекта.")
|
|
28
|
+
# Ключ – знаки token68 (RFC 7235): латиница, цифры и - . _ ~ + / =. Такой ключ годится для заголовка и в JSON не
|
|
29
|
+
# экранируется (кроме «/», который иные кодировщики пишут как «\/» – очистка учитывает и этот вид)
|
|
30
|
+
# Не короче 16 знаков: короткий ключ совпадал бы со словами ответов модели, и проверка ответа перед сохранением
|
|
31
|
+
# (model_traffic.shows_secret) отвергала бы обычные ответы
|
|
32
|
+
_KEY = re.compile(r"[A-Za-z0-9\-._~+/=]{16,4096}")
|
|
33
|
+
KEY_FORMAT = "Ключ – от 16 до 4096 знаков: латиница, цифры и - . _ ~ + / = (без пробелов и кавычек)."
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class KeyRejected(ValueError):
|
|
37
|
+
"""Ключ не подходит для заголовка авторизации; текст – по-русски."""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class PendingKeys:
|
|
41
|
+
"""Ключ, введённый в форму профиля, до «Сохранить» (после «Проверить» ключ второй раз не
|
|
42
|
+
вводится). Хранится только в памяти процесса по случайной метке формы вместе с привязкой – владелец метки
|
|
43
|
+
(профиль или черновик нового профиля – отдельная случайная метка черновика), адрес сервера и подтверждённые адреса,
|
|
44
|
+
для которых ключ введён: та же привязка, что у сохранённого ключа (save_key). Изменились адрес или подтверждённые
|
|
45
|
+
адреса – ключ по метке не выдаётся, его вводят заново (ревью A8: иначе ключ ушёл бы на адрес, который человек не
|
|
46
|
+
подтверждал при вводе). В страницу, базу и журнал ключ не попадает. Метка живёт 15 минут, «Сохранить» забирает
|
|
47
|
+
ключ после успешной записи; перезапуск приложения метки стирает."""
|
|
48
|
+
|
|
49
|
+
TTL_S = 900
|
|
50
|
+
LIMIT = 16
|
|
51
|
+
|
|
52
|
+
def __init__(self) -> None:
|
|
53
|
+
self._lock = threading.Lock()
|
|
54
|
+
self._items: dict[str, tuple[str, tuple, float]] = {}
|
|
55
|
+
self._claimed: set[str] = set() # метки, которые сейчас сохраняются: вторая попытка ключа не получит
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def binding(owner: str, base_url: str, addresses: Any) -> tuple:
|
|
59
|
+
return (str(owner or ""), _base(base_url), tuple(sorted(normalize_addresses(addresses))))
|
|
60
|
+
|
|
61
|
+
def _prune(self, now: float) -> None:
|
|
62
|
+
for handle in [h for h, (_k, _b, until) in self._items.items() if until <= now]:
|
|
63
|
+
del self._items[handle]
|
|
64
|
+
self._claimed.discard(handle)
|
|
65
|
+
|
|
66
|
+
def _owned(self, handle: str, owner: str) -> bool:
|
|
67
|
+
item = self._items.get(str(handle or ""))
|
|
68
|
+
return bool(item) and item[1][0] == str(owner or "")
|
|
69
|
+
|
|
70
|
+
def remember(self, key: str, owner: str, base_url: str, addresses: Any = (), previous: str = "") -> str:
|
|
71
|
+
"""Новая метка для ключа с привязкой (прежняя метка этой формы отменяется)."""
|
|
72
|
+
now = time.monotonic()
|
|
73
|
+
with self._lock:
|
|
74
|
+
self._prune(now)
|
|
75
|
+
if previous and self._owned(previous, owner) and previous not in self._claimed:
|
|
76
|
+
del self._items[previous] # заменить можно только свою метку, и не ту, что сейчас сохраняется
|
|
77
|
+
while len(self._items) >= self.LIMIT: # старейшая метка уступает место
|
|
78
|
+
oldest = min(self._items, key=lambda h: self._items[h][2])
|
|
79
|
+
del self._items[oldest]
|
|
80
|
+
self._claimed.discard(oldest)
|
|
81
|
+
handle = secrets.token_urlsafe(24)
|
|
82
|
+
self._items[handle] = (key, self.binding(owner, base_url, addresses), now + self.TTL_S)
|
|
83
|
+
return handle
|
|
84
|
+
|
|
85
|
+
def peek(self, handle: str, owner: str, base_url: str, addresses: Any = ()) -> str:
|
|
86
|
+
"""Ключ по метке с той же привязкой, без изъятия (проверка, сохранение); иначе пустая строка."""
|
|
87
|
+
with self._lock:
|
|
88
|
+
self._prune(time.monotonic())
|
|
89
|
+
item = self._items.get(str(handle or ""))
|
|
90
|
+
return item[0] if item and item[1] == self.binding(owner, base_url, addresses) else ""
|
|
91
|
+
|
|
92
|
+
def claim(self, handle: str, owner: str, base_url: str, addresses: Any = ()) -> str:
|
|
93
|
+
"""Ключ по метке для сохранения – атомарно: метка резервируется, второе одновременное сохранение по той же
|
|
94
|
+
метке ключа не получит (ревью A8, круг 2). После записи – forget (успех) или release (отказ)."""
|
|
95
|
+
with self._lock:
|
|
96
|
+
self._prune(time.monotonic())
|
|
97
|
+
item = self._items.get(str(handle or ""))
|
|
98
|
+
if not item or item[1] != self.binding(owner, base_url, addresses) or str(handle) in self._claimed:
|
|
99
|
+
return ""
|
|
100
|
+
self._claimed.add(str(handle))
|
|
101
|
+
return item[0]
|
|
102
|
+
|
|
103
|
+
def release(self, handle: str, owner: str) -> None:
|
|
104
|
+
"""Сохранение не удалось: метка снова доступна, ключ остаётся в памяти."""
|
|
105
|
+
with self._lock:
|
|
106
|
+
if self._owned(handle, owner):
|
|
107
|
+
self._claimed.discard(str(handle))
|
|
108
|
+
|
|
109
|
+
def forget(self, handle: str, owner: str) -> None:
|
|
110
|
+
"""Метка больше не нужна: ключ сохранён или человек от ключа отказался. Только своя метка."""
|
|
111
|
+
with self._lock:
|
|
112
|
+
if self._owned(handle, owner):
|
|
113
|
+
del self._items[str(handle)]
|
|
114
|
+
self._claimed.discard(str(handle))
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _base(url: Any) -> str:
|
|
118
|
+
return str(url or "").strip().rstrip("/")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def secret_name(provider_id: int) -> str:
|
|
122
|
+
return f"provider:{int(provider_id)}"
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def save_key(keys: Any, provider_id: int, key: str, base_url: str, addresses: Any) -> None:
|
|
126
|
+
"""Записать (или заменить) ключ профиля с привязкой к адресу и подтверждённым адресам. keys – база (Database.put_secret)."""
|
|
127
|
+
key = str(key or "").strip()
|
|
128
|
+
if not _KEY.fullmatch(key):
|
|
129
|
+
raise KeyRejected(KEY_FORMAT)
|
|
130
|
+
keys.put_secret(secret_name(provider_id), json.dumps(
|
|
131
|
+
{"addresses": sorted(normalize_addresses(addresses)), "base_url": _base(base_url), "key": key, "version": 1},
|
|
132
|
+
ensure_ascii=True, sort_keys=True))
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def parse_entry(raw: Any) -> dict[str, Any] | None:
|
|
136
|
+
"""{"key", "base_url", "addresses", "version"} из записанного значения; повреждено – None (ключ считается не заданным)."""
|
|
137
|
+
try:
|
|
138
|
+
if len(raw) > 16384:
|
|
139
|
+
return None
|
|
140
|
+
data = json.loads(raw.decode("ascii") if isinstance(raw, bytes) else raw)
|
|
141
|
+
except (ValueError, TypeError):
|
|
142
|
+
return None
|
|
143
|
+
if not isinstance(data, dict) or not _KEY.fullmatch(str(data.get("key") or "")):
|
|
144
|
+
return None
|
|
145
|
+
return {"key": str(data["key"]), "base_url": _base(data.get("base_url")),
|
|
146
|
+
"addresses": normalize_addresses(data.get("addresses") or []), "version": 1}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def load_key(keys: Any, provider_id: int) -> dict[str, Any] | None:
|
|
150
|
+
"""{"key", "base_url", "addresses"} или None: ключа нет или значение повреждено (тогда ключ считается не заданным)."""
|
|
151
|
+
raw = keys.secret(secret_name(provider_id))
|
|
152
|
+
entry = parse_entry(raw) if raw is not None else None
|
|
153
|
+
if entry is None:
|
|
154
|
+
return None
|
|
155
|
+
return {"key": entry["key"], "base_url": entry["base_url"], "addresses": entry["addresses"]}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def delete_key(keys: Any, provider_id: int) -> bool:
|
|
159
|
+
"""Удалить ключ профиля; True – ключ был."""
|
|
160
|
+
return keys.drop_secret(secret_name(provider_id))
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def key_hint(keys: Any, provider_id: int) -> str:
|
|
164
|
+
"""Для интерфейса: «задан, …abcd» или "" (ключа нет)."""
|
|
165
|
+
entry = load_key(keys, provider_id)
|
|
166
|
+
return f"задан, …{entry['key'][-4:]}" if entry else ""
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def key_headers(kind: str, key: str) -> dict[str, str]:
|
|
170
|
+
"""Секретные заголовки ключа по протоколу (ADR-0106): API чат-завершений и Ollama за ключом –
|
|
171
|
+
«Authorization: Bearer», Messages API – «x-api-key». Служебные заголовки протокола (версия API) сюда не входят:
|
|
172
|
+
их отдаёт клиент (ServerClient.protocol_headers), они не секрет."""
|
|
173
|
+
if str(kind or "") == "messages":
|
|
174
|
+
return {"x-api-key": str(key)}
|
|
175
|
+
return {"Authorization": f"Bearer {key}"}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def auth_headers(keys: Any, provider_id: int, base_url: str, addresses: Any,
|
|
179
|
+
kind: str = "chat_completions") -> dict[str, str]:
|
|
180
|
+
"""Заголовок авторизации для запроса по снимку (адрес base_url, подтверждённые адреса addresses): только если
|
|
181
|
+
привязка ключа совпадает. Ключа нет или он задан для другого адреса – SendNotAllowed, запрос не отправляется."""
|
|
182
|
+
entry = load_key(keys, provider_id) if keys is not None else None
|
|
183
|
+
if entry is None:
|
|
184
|
+
raise SendNotAllowed("Ключ профиля провайдера модели не задан: запрос к модели не отправлен.",
|
|
185
|
+
note=KEY_NOTE_MISSING)
|
|
186
|
+
if entry["base_url"] != _base(base_url) or set(entry["addresses"]) != set(normalize_addresses(addresses)):
|
|
187
|
+
raise SendNotAllowed("Ключ профиля провайдера модели задан для другого адреса сервера: запрос к модели не "
|
|
188
|
+
"отправлен.", note=KEY_NOTE_OTHER)
|
|
189
|
+
return key_headers(kind, entry["key"])
|